Exemple #1
0
 private void buttonX_send_Click(object sender, EventArgs e)
 {
     if (!this.isend.IsStarted)
     {
         this.isend.SetLog(new LogData("尚未启动服务或未连接", 3));
     }
     else
     {
         if (!this.textBoxX_ip.Visible)
         {
             if (this.isend.GetClientsForSend().Count == 0)
             {
                 this.isend.SetLog(new LogData("请在先在左边列表框里选中要发送的列表", 3));
                 return;
             }
         }
         else if (this.textBoxX_ip.Text.Length == 0)
         {
             this.isend.SetLog(new LogData("请输入目标IP和端口号", 3));
             return;
         }
         if (this.textBoxX1.Text.Length == 0)
         {
             this.isend.SetLog(new LogData("请输入要发送的数据", 3));
         }
         else if (this.checkBoxX1.Checked)
         {
             try
             {
                 this.isend.Send(CVT.StrToHexByte(this.textBoxX1.Text));
             }
             catch
             {
                 this.isend.SetLog(new LogData("非法十六进制表示方式,请确认所输入字符为(0-9)(a-z)(A-Z)", 3));
             }
         }
         else
         {
             this.isend.Send(Encoding.Default.GetBytes(this.textBoxX1.Text));
         }
     }
 }
Exemple #2
0
 private void checkBoxX1_CheckedChanged(object sender, EventArgs e)
 {
     if (this.textBoxX1.Text.Length != 0)
     {
         if (this.checkBoxX1.Checked)
         {
             this.textBoxX1.Text = CVT.ByteToHexStr(Encoding.Default.GetBytes(this.textBoxX1.Text));
         }
         else
         {
             try
             {
                 this.textBoxX1.Text = Encoding.Default.GetString(CVT.StrToHexByte(this.textBoxX1.Text));
             }
             catch
             {
                 MessageBoxEx.Show("非法十六进制表示方式,请确认所输入字符为(0-9)(a-z)(A-Z)");
             }
         }
     }
 }