Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            btn_Connect.IsEnabled    = false;
            btn_Disconnect.IsEnabled = true;
            Clean();
            btn_Connect.IsEnabled = false;
            IPAddress ip;

            if (IPAddress.TryParse(txt_Host.Text, out ip))
            {
                if (string.IsNullOrWhiteSpace(txt_Port.Text))
                {
                    MessageBox.Show("Invalid port", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    _client = new RVIClient(new IPEndPoint(ip, int.Parse(txt_Port.Text)), this);
                    _client.Start();
                }
            }
            else
            {
                MessageBox.Show("Invalid ip address", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
Ejemplo n.º 2
0
 // Connect button click
 private void btn_Connect_Click(object sender, RoutedEventArgs e)
 {
     Clear();
     try
     {
         IPAddress ip   = IPAddress.Parse(txt_Host.Text);
         int       port = int.Parse(txt_Port.Text);
         if (port > ushort.MaxValue)
         {
             throw new FormatException("Port number cannot be larger than " + ushort.MaxValue);
         }
         _client = new RVIClient(new IPEndPoint(ip, port), this, true);
         _client.Start();
     }
     catch (FormatException)
     {
         MessageBox.Show("Invalid host/port format!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }