/// <summary> /// Closes the Wirekite devices. /// </summary> /// <remarks> /// A closed device can no longer be used. It must be disconnected and connected again, /// or the Wirekite service must be restarted. /// </remarks> public void Close() { if (_deviceState == DeviceState.Closed) { return; } _ports.Clear(); _throttler.Clear(); _pendingRequests.Clear(); _service.RemoveDevice(this); WinUsb_Free(_interfaceHandle); _interfaceHandle = IntPtr.Zero; _deviceHandle.Dispose(); _deviceHandle = null; _deviceState = DeviceState.Closed; }
/// <summary> /// Rescans and updates ports in combo box /// </summary> public void Rescan() { ports = SerialPort.GetPortNames(); PortSelected = null; PortList.Clear(); foreach (string port in ports) { PortList.Add(port); } }
public SetPortViewModel( ModalWindowManager modalWindowManager, IAppConfigService appConfigService) { _modalWindowManager = modalWindowManager; _appConfigService = appConfigService; RefreshPortList = ReactiveCommand.Create(() => { PortList?.Clear(); PortList = new ObservableCollection <string>(SerialPort.GetPortNames()); }); AppyPort = ReactiveCommand.Create(() => { _appConfigService.Config.Port = SelectedPort; MessageBus.Current.SendMessage <ModalActions>(ModalActions.Close); }); RefreshPortList.Execute().Subscribe(); }