private void UpdatePorts(bool scan = true) { _ports = SerialPort.GetPortNames(); if (comports.Items.Count == _ports.Length) { return; } if (_ports.Length > comports.Items.Count && !scan) { scan = true; } comports.DataSource = _ports; if (comports.Items.Count > 0 && scan) { DeviceControl.SetNORWayPort(); if (comports.SelectedIndex < comports.Items.Count) { comports.SelectedIndex = 0; } } else if (scan) { comports.Text = ""; } }
public MainForm() { InitializeComponent(); var ver = Assembly.GetExecutingAssembly().GetName().Version; #if DEBUG Text = string.Format(Text, ver.Major, ver.Minor, "DEBUG Build"); #elif BETA Text = string.Format(Text, ver.Major, ver.Minor, ver.Revision > 0 ? string.Format("BETA{0}", ver.Revision) : "BETA"); #elif ALPHA Text = string.Format(Text, ver.Major, ver.Minor, ver.Revision > 0 ? string.Format("ALPHA{0}", ver.Revision) : "ALPHA"); #else Text = string.Format(Text, ver.Major, ver.Minor, ""); #endif #if DEBUG || BETA || ALPHA donateToolStripMenuItem.Visible = false; #else donateToolStripMenuItem.Visible = true; #endif PythonHandler.Error += ProcOut; PythonHandler.Output += ProcOut; Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath); DeviceControl.SetUpReceive(Handle); }
private void UpdatePorts() { _ports = SerialPort.GetPortNames(); if (comports.Items.Count == _ports.Length) { return; } comports.DataSource = _ports; if (_ports.Length > comports.Items.Count) { DeviceControl.SetNORWayPort(); } }
protected override void WndProc(ref Message m) { base.WndProc(ref m); switch (m.Msg) { case 0x219: if (DeviceControl.CheckIfWayDeviceArrived(ref m)) { UpdatePorts(); } else { UpdatePorts(false); } break; } }
private void MainFormFormClosing(object sender, FormClosingEventArgs e) { DeviceControl.RemoveReceive(); }