private void RefreshSystemSerialPortList() { CmbComPort.ItemsSource = SerialPortHelper.GetSerialPorts(); if (CmbComPort.Items.Count > 0) { CmbComPort.SelectedIndex = 0; } }
bool CheckSerialPort() { if (SerialPortHelper.GetSerialPorts().Length == 0) { return(false); } return(true); }
private void RefreshSystemSerialPortList() { CmbComPort.ItemsSource = SerialPortHelper.GetSerialPorts(); if (CmbComPort.Items.Count > 0) { CmbComPort.SelectedIndex = 0; } LblPortStatus.Content = @"系统哥哥说,他就知道这几个家伙了。"; }
int getCountSerialPort() { return(SerialPortHelper.GetSerialPorts().Length); }
public MainForm() { InitializeComponent(); currentPort = SerialPortHelper.GetSerialPorts(); comboBox1.Items.Clear(); comboBox1.Items.Add("NULL"); comboBox1.Items.AddRange(currentPort); comboBox3.Items.Clear(); comboBox3.Items.Add("NULL"); comboBox3.Items.AddRange(currentPort); drivers = new MachineDrivers(Program.testLog); drivers.ReceivedResponse += reciveResponse; // инициализируем устройства drivers.InitAllDevice(); if (Globals.ClientConfiguration.Settings.comPortScanner.Contains("NULL")) { comboBox1.SelectedIndex = -1; } else if (Globals.ClientConfiguration.Settings.comPortScanner.Contains("COM")) { string index = Globals.ClientConfiguration.Settings.comPortScanner.Remove(0, 3); int int_index = 0; int.TryParse(index, out int_index); comboBox1.SelectedIndex = int_index; drivers.scaner.openPort((string)comboBox1.Items[comboBox1.SelectedIndex]); } if (Globals.ClientConfiguration.Settings.comPortBill.Contains("NULL")) { comboBox3.SelectedIndex = -1; } else if (Globals.ClientConfiguration.Settings.comPortBill.Contains("COM")) { string index = Globals.ClientConfiguration.Settings.comPortBill.Remove(0, 3); int int_index = 0; int.TryParse(index, out int_index); int counter = 0; foreach (object item in comboBox3.Items) { if ((string)item == Globals.ClientConfiguration.Settings.comPortBill) { break; } counter++; } comboBox3.SelectedIndex = counter; drivers.CCNETDriver.openPort((string)comboBox3.Items[comboBox3.SelectedIndex]); } if (Globals.ClientConfiguration.Settings.adressBill == null || Globals.ClientConfiguration.Settings.adressBill.Contains("NULL")) { drivers.CCNETDriver.BillAdr = 3; } else { string index = Globals.ClientConfiguration.Settings.adressBill; int int_index = 0; int.TryParse(index, out int_index); textBox1.Text = Globals.ClientConfiguration.Settings.adressBill; drivers.CCNETDriver.BillAdr = int_index; } comboBox4.Items.Clear(); comboBox4.Items.AddRange(drivers.printer.findAllPrinter()); }