Advertisement
Guest User

Untitled

a guest
Jun 1st, 2012
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Text.RegularExpressions;
  10. using System.Runtime.InteropServices;
  11.  
  12. namespace PAWNCoder
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         private const int EM_SETTABSTOPS = 0x00CB;
  17.  
  18.         [DllImport("User32.dll")]
  19.         static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int[] lParam);
  20.         bool check = false;
  21.         public Form1()
  22.         {
  23.             Timer timer = new Timer();
  24.             timer.Interval = 750;
  25.             timer.Tick += new EventHandler(timerevent);
  26.             timer.Start();
  27.             InitializeComponent();
  28.             textBox1.Text = "Dein Dialogcode hier";
  29.             label2.Text = textBox1.Text.Length.ToString() + " Zeichen";
  30.             var pos = this.PointToScreen(label1.Location);
  31.             pos = pictureBox2.PointToClient(pos);
  32.             label1.Parent = pictureBox2;
  33.             label1.Location = pos;
  34.             label1.BackColor = Color.Transparent;
  35.  
  36.             pos = this.PointToScreen(pictureBox2.Location);
  37.             pos = pictureBox1.PointToClient(pos);
  38.             pictureBox2.Parent = pictureBox1;
  39.             pictureBox2.Location = pos;
  40.             pictureBox2.BackColor = Color.Transparent;
  41.  
  42.             this.textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown);
  43.             this.textBox2.KeyDown += new KeyEventHandler(textBox2_KeyDown);
  44.             int[] tabstops = new int[] { 26 };
  45.             SendMessage(textBox1.Handle, EM_SETTABSTOPS, tabstops.Length, tabstops);
  46.             textBox1.Invalidate();
  47.            
  48.         }
  49.         private void timerevent(Object e, EventArgs unused)
  50.         {
  51.             if (!check)
  52.             {
  53.                 label1.Text = textBox1.Text;
  54.                 label1.Text = Regex.Replace(label1.Text,"\t", "             ");
  55.                 Size test = new Size(label1.Width + 30, label1.Height + 60);
  56.                 if (test.Width < 180) test.Width = 180;
  57.                 pictureBox2.Size = test;
  58.                 test.Height = 21;
  59.                 pictureBox3.Size = test;
  60.                 Point p = new Point(pictureBox1.Location.X + pictureBox2.Location.X + pictureBox2.Width/2-50,
  61.                     pictureBox1.Location.Y + pictureBox2.Location.Y + pictureBox2.Height - 35);
  62.                 pictureBox4.Location = p;
  63.                 string[] lines = Regex.Split(label1.Text, "\r\n");
  64.             }
  65.             check = false;
  66.         }
  67.         private void textBox1_TextChanged(object sender, EventArgs e)
  68.         {
  69.             //label1.Text = textBox1.Text;
  70.             int index = label1.Text.IndexOf('\t');
  71.             label2.Text = textBox1.Text.Length.ToString() + " Zeichen";
  72.         }
  73.         private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
  74.         {
  75.             check = true;
  76.             if (e.Control && e.KeyValue == 65)
  77.                 textBox1.SelectAll();
  78.             /*if (e.KeyValue == 9)
  79.             {
  80.                
  81.                 string[] lines = Regex.Split(label1.Text, "\r\n");
  82.                 for (int i = 0; i < lines.Length; i++)
  83.                 {
  84.                     if (lines[i].Length < 1) continue;
  85.                     for (int u = 0; u < lines[i].Length; u++)
  86.                     {
  87.                         if (lines[i][u] == '\t')
  88.                         {
  89.                             label2.Text = lines[i].Remove(u, 0);
  90.                             string blubb = "";
  91.                             for (int a = u; a < lines[i].Length; a++)
  92.                             {
  93.                                 blubb = blubb + " ";
  94.                             }
  95.                             lines[i] = lines[i].Insert(u, blubb);
  96.                         }
  97.                     }
  98.                 }
  99.                 //label1.Text = label1.Text.Replace('\t'.ToString(),blubb );
  100.             }*/
  101.         }
  102.         private void textBox2_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
  103.         {
  104.             if (e.Control && e.KeyValue == 65)
  105.                 textBox2.SelectAll();
  106.         }
  107.         private void pictureBox1_Click(object sender, EventArgs e)
  108.         {
  109.  
  110.         }
  111.  
  112.         private void button1_Click(object sender, EventArgs e)
  113.         {
  114.             //string blubb = textBox1.Text.Replace('\t'.ToString(), ";");
  115.             string[] lines = Regex.Split(textBox1.Text, "\r\n");
  116.             lines[0] = lines[0].Replace('\t'.ToString(), "\\t");
  117.             lines[0] = Regex.Replace(lines[0], '"'.ToString(), "\\\"");
  118.             lines[0] = Regex.Replace(lines[0], '"'.ToString(), "\\\"");
  119.             lines[0] = Regex.Replace(lines[0], '%'.ToString(), "%%");
  120.             textBox2.Text = "new str[" + textBox1.Text.Length + "];\r\nformat(str,sizeof str,\"" + lines[0] + ""+ ( ( lines.Length > 1 ) ? "\\n" : "" )+"\");";
  121.             for (int i = 1; i < lines.Length; i++)
  122.             {
  123.                 lines[i] = lines[i].Replace('\t'.ToString(), "\\t");
  124.                 lines[i] = Regex.Replace(lines[i], '"'.ToString(), "\\\"");
  125.                 lines[i] = Regex.Replace(lines[i], '%'.ToString(), "%%");
  126.                 if (lines[i].Length < 1 && i != lines.Length -1) lines[i+1] = "\\n"+lines[i+1];
  127.                 else if(lines[i].Length < 1 && i == lines.Length - 1) continue;
  128.                 else
  129.                     textBox2.Text = textBox2.Text + "\r\nformat(str,sizeof str,\"%s" + lines[i] + "" + ((i == lines.Length - 1) ? "" : "\\n") + "\",str);";
  130.             }
  131.             textBox2.Text = textBox2.Text + "\r\nShowPlayerDialog(playerid,dialogid,DIALOG_STYLE_MSGBOX,\"Headline\",str,\"Ok!\",\"\");";
  132.  
  133.            
  134.  
  135.  
  136.         }
  137.  
  138.         private void label2_Click(object sender, EventArgs e)
  139.         {
  140.  
  141.         }
  142.  
  143.         private void Form1_Load(object sender, EventArgs e)
  144.         {
  145.  
  146.         }
  147.  
  148.         private void pictureBox2_Click(object sender, EventArgs e)
  149.         {
  150.  
  151.         }
  152.  
  153.         private void pictureBox4_Click(object sender, EventArgs e)
  154.         {
  155.  
  156.         }
  157.     }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement