Пример #1
0
 private void inputTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == '\r')
     {
         TextBox inputTextBox = (TextBox)sender;
         string  input        = inputTextBox.Text;
         if (SourceAddressTextBox.Text == DistanitionAddressTextBox.Text)
         {
             addOutputString(input);
             clearInput();
         }
         else
         {
             if (transmitter == null)
             {
                 MessageBox.Show("Choose COM-Port please", "ERROR!!!");
                 return;
             }
             if (transmitter.sendPackageData(input))
             {
                 clearInput();
             }
         }
     }
 }
Пример #2
0
 private void inputTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == '\r')
     {
         TextBox inputTextBox = (TextBox)sender;
         string  input        = inputTextBox.Text;
         foreach (char a in input)
         {
             if (a > 127 || a < 0)
             {
                 MessageBox.Show("You can use only standart symbols.", "Error");
                 return;
             }
         }
         if (SourceAddressTextBox.Text == DistanitionAddressTextBox.Text)
         {
             addOutputString(input);
             clearInput();
         }
         else
         {
             try
             {
                 if (transmitter == null)
                 {
                     MessageBox.Show("Choose COM-Port please", "ERROR!!!");
                     return;
                 }
                 if (transmitter.sendPackageData(input))
                 {
                     clearInput();
                 }
             }
             catch (Exception ex)
             {
                 addControlDebugString("Error sending: " + ex.Message);
             }
         }
     }
 }