private void ComConnectButton_Click(object sender, EventArgs e)
        {
            var    portName     = PortComboBox.GetSelectedItem <string>();
            string selectedPort = null;

            try
            {
                selectedPort = m_comConnector.Connect(portName);
            }
            catch (Exception ex)
            {
                s_logger.Warn(ex);
            }

            if (string.IsNullOrEmpty(selectedPort))
            {
                InfoBox.Show("Switch USB mode to COM and try again.");
                return;
            }

            ComConnectButton.Enabled    = false;
            ComDisconnectButton.Enabled = true;
        }
예제 #2
0
 private void PortComboBox_DropDownOpened(object sender, EventArgs e)
 {
     PortComboBox.SetBinding(ItemsControl.ItemsSourceProperty, new Binding {
         Source = SerialPort.GetPortNames()
     });
 }