private void Btn_comReconnect_Click(object sender, RoutedEventArgs e) { serialPortIO8_name = SerialPortIO8.Locate_serialPortIO8(); if (String.Equals(serialPortIO8_name, "")) { run_comState.Text = "Can't Find the COM Port for DLP-IO8!"; run_comState.Background = new SolidColorBrush(Colors.Orange); run_comState.Foreground = new SolidColorBrush(Colors.Red); run_instruction.Text = "Please connect it correctly and reCheck!"; run_instruction.Background = new SolidColorBrush(Colors.Orange); run_instruction.Foreground = new SolidColorBrush(Colors.Red); } else { btn_comReconnect.Visibility = Visibility.Hidden; btn_comReconnect.IsEnabled = false; run_comState.Text = "Found the COM Port for DLP-IO8!"; run_comState.Background = new SolidColorBrush(Colors.White); run_comState.Foreground = new SolidColorBrush(Colors.Green); run_instruction.Text = "Can start trials now"; run_instruction.Background = new SolidColorBrush(Colors.White); run_instruction.Foreground = new SolidColorBrush(Colors.Green); } if (textBox_NHPName.Text != "" && serialPortIO8_name != null) { btn_start.IsEnabled = true; } }
private void CheckIO8Connection() { // locate serial Port Name serialPortIO8_name = SerialPortIO8.Locate_serialPortIO8(); if (String.Equals(serialPortIO8_name, "")) { btn_start.IsEnabled = false; btn_comReconnect.Visibility = Visibility.Visible; btn_comReconnect.IsEnabled = true; textblock_comState.Visibility = Visibility.Visible; run_comState.Text = "Can't Find the COM Port for DLP-IO8!"; run_comState.Background = new SolidColorBrush(Colors.Orange); run_comState.Foreground = new SolidColorBrush(Colors.Red); run_instruction.Text = "Please connect it correctly and reCheck!"; run_instruction.Background = new SolidColorBrush(Colors.Orange); run_instruction.Foreground = new SolidColorBrush(Colors.Red); } else { btn_comReconnect.Visibility = Visibility.Hidden; btn_comReconnect.IsEnabled = false; run_comState.Text = "Found the COM Port for DLP-IO8!"; run_comState.Background = new SolidColorBrush(Colors.White); run_comState.Foreground = new SolidColorBrush(Colors.Green); run_instruction.Text = "Can start trials now"; run_instruction.Background = new SolidColorBrush(Colors.White); run_instruction.Foreground = new SolidColorBrush(Colors.Green); } }
private void BindSerialPortNames() { string[] ports = SerialPort.GetPortNames(); string portIO8 = SerialPortIO8.Locate_serialPortIO8(); for (int i = 0; i < ports.Length; i++) { string port = ports[i]; cboPort.Items.Add(port); if (portIO8 != "" && port == portIO8) { cboPort.SelectedIndex = i; } } if (portIO8 == "") { btn_OpenStartpad.IsEnabled = false; btn_CloseStartpad.IsEnabled = false; btn_StartJuicer.IsEnabled = false; btn_CloseJuicer.IsEnabled = false; } }