public void SetElementData(string AStrDataContext) { string LStrData = string.Empty; LStrData = AStrDataContext; if (string.IsNullOrEmpty(LStrData)) { LStrData = "0.0.0.0"; } TextBoxIPAddress.SetIP(LStrData); TextBoxIPAddress.IOperationEvent += TextBoxIPAddress_IOperationEvent; }
private void Button_Click(object sender, RoutedEventArgs e) { var result = client.ConnectToPLC(TextBoxIPAddress.GetLineText(0)); TextBoxResults.Text = client.GetErrorText(result); }
private void SaveConfig(object sender, RoutedEventArgs e) { bool error = false; try { int portIn = Convert.ToInt32(TextBoxPortIn.Text); if (portIn >= 1 && portIn <= 65535) { client.PortReceive = portIn; } else { throw new ArgumentException("Invalid UDP port number"); } } catch (Exception ex) { MessageBox.Show("Please enter a valid port number between 1-65535."); TextBoxPortIn.Focus(); error = true; } try { int portOut = Convert.ToInt32(TextBoxPortOut.Text); if (portOut >= 1 && portOut <= 65535) { client.PortSend = portOut; } else { throw new ArgumentException("Invalid TCP/IP port number"); } } catch (Exception ex) { MessageBox.Show("Please enter a valid port number between 1-65535."); TextBoxPortOut.Focus(); error = true; } try { IPAddress ipAdd = IPAddress.Parse(TextBoxIPAddress.Text); client.IPAddress = ipAdd; } catch (Exception ex) { MessageBox.Show("Please enter a valid IP address such as 127.0.0.1"); TextBoxIPAddress.Focus(); error = true; } if (!error) { client.Settings.WriteConfigFile(); GridConfig.Visibility = Visibility.Collapsed; } }
public string GetElementData() { return(TextBoxIPAddress.GetIP()); }
private void UserControl_Loaded(object sender, System.Windows.RoutedEventArgs e) { // Need to be in loaded event, focusmanger won't work... TextBoxIPAddress.Focus(); }