private void LoadDeviceSetting(object sender, MouseButtonEventArgs e) { if (sender is TreeViewItem treeViewItem) { selectdevice = (MonchaDevice)treeViewItem.DataContext; DeviceChange?.Invoke(this, (MonchaDevice)treeViewItem.DataContext); } }
private void AddDeviceToList(string DeviceNameString) { devices.Add(DeviceNameString.ToLowerInvariant(), new HidDevice(this, DeviceNameString)); EmitLogMessage(HidLogMessageType.Info, "Device Attach: " + DeviceNameString); if (DeviceChange != null) { DeviceChange.Invoke(this, null); } }
private void RemoveDeviceFromList(string DeviceNameString) { devices[DeviceNameString].Dispose(); devices[DeviceNameString] = null; devices.Remove(DeviceNameString); EmitLogMessage(HidLogMessageType.Info, "Device Removal: " + DeviceNameString); if (DeviceChange != null) { DeviceChange.Invoke(this, null); } }
private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == WM_DEVICECHANGE) //WM_DEVICECHANGE { DeviceChange?.Invoke(); var ports = SerialPort.GetPortNames(); var oldPorts = ComPorts.Except(ports).ToArray(); var newPorts = ports.Except(ComPorts).ToArray(); foreach (var newPort in newPorts) { comPorts.Add(newPort); } foreach (var oldPort in oldPorts) { comPorts.Remove(oldPort); } } // do stuff return(IntPtr.Zero); }
public void OnDeviceChange() { DeviceChange?.Invoke(this, EventArgs.Empty); }
private void OnCDChange(DeviceChangeEventArgs ea) { DeviceChange?.Invoke(this, ea); }