public static void RefreshAutoDetectPreference(bool autoDetect) { if (autoDetect && _devicePort == null) { FindDevice(SerialPortService.GetAvailableSerialPorts()); } }
public static void UpdateAvailablePorts() { MenuItem item = nIcon.ContextMenu.MenuItems[2]; item.MenuItems.Clear(); foreach (string portName in SerialPortService.GetAvailableSerialPorts().OrderBy(s => s)) { item.MenuItems.Add(portName).Click += async(s, c) => { bool isChecked = (s as MenuItem).Checked; RemoteSerialListener.ClearCurrentPort(); if (!isChecked) { if (!(await RemoteSerialListener.TestPort(portName))) { System.Windows.MessageBox.Show($"Port {portName} has not been recognized"); } } }; } }