Exemplo n.º 1
0
 private void LoadDeviceSetting(object sender, MouseButtonEventArgs e)
 {
     if (sender is TreeViewItem treeViewItem)
     {
         selectdevice = (MonchaDevice)treeViewItem.DataContext;
         DeviceChange?.Invoke(this, (MonchaDevice)treeViewItem.DataContext);
     }
 }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public void OnDeviceChange()
 {
     DeviceChange?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 6
0
 private void OnCDChange(DeviceChangeEventArgs ea)
 {
     DeviceChange?.Invoke(this, ea);
 }