Advertisement
Guest User

Untitled

a guest
Aug 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Windows.Forms;
  3. namespace Signature_Mask
  4. {
  5.     public partial class Form1 : Form
  6.     {
  7.         public Form1()
  8.         {
  9.             InitializeComponent();
  10.             timer1.Enabled = true;
  11.         }
  12.         private string _text_1, _text_2;
  13.         private char _char_1, _char_2;
  14.         private int _int_1, _int_2;
  15.         private void timer1_Tick(object sender, EventArgs e)
  16.         {
  17.             try
  18.             {
  19.                 if (!textBox1.Text.Contains("0x") || !textBox1.Text.Contains(","))
  20.                 {
  21.                     if (textBox1.Text.Length > 0 && textBox1.Text.Length % 2 != 1)
  22.                     {
  23.                         textBox2.Enabled = true;
  24.                         _text_1 = textBox1.Text.Replace(" ", "");
  25.                         for (int i = 0; i < _text_1.Length / 2; i++)
  26.                         {
  27.                             _int_1 = _int_1 + _int_2;
  28.                             _char_1 = _text_1[_int_1];
  29.                             _int_2 = 2;
  30.                             _char_2 = _text_1[_int_1 + 1];
  31.                             _text_2 += "0x" + _char_1 + _char_2 + ", ";
  32.                         }
  33.                         textBox2.Text = _text_2.Remove(_text_2.Length - 2);
  34.                         _int_1 = 0;
  35.                         _int_2 = 0;
  36.                         _text_2 = "";
  37.                     }
  38.                     else
  39.                     {
  40.                         textBox2.Enabled = false;
  41.                         textBox2.Text = "";
  42.                     }
  43.                 }
  44.                 else
  45.                 {
  46.                     string _text;
  47.                     _text = textBox1.Text.Replace(",", " ").Replace(" ","");
  48.                     textBox2.Text = _text.Replace("0x", " ").Remove(0, 1);
  49.                     textBox2.Enabled = true;
  50.                 }
  51.             }
  52.             catch(Exception Text_Error)
  53.             {
  54.                 timer1.Enabled = false;
  55.                 MessageBox.Show(Text_Error.Message,"Error", MessageBoxButtons.OK,MessageBoxIcon.Error);
  56.                 textBox1.Text = "";
  57.                 textBox2.Text = "";
  58.                 _int_1 = 0;
  59.                 _int_2 = 0;
  60.                 _text_1 = "";
  61.                 _text_2 = "";
  62.                 timer1.Enabled = true;
  63.             }
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement