Inheritance: System.EventArgs
Exemple #1
0
 private static void DeviceRemoved(object sender, DeviceEventArgs args)
 {
     // If a device was removed which exists in our dictionary,
     // then this is the time to dispose and remove it.
     string path = args.DevicePath.ToUpper();
     if (devices.ContainsKey(path)) {
         devices[path].Dispose();
         devices.Remove(path);
     }
 }
Exemple #2
0
 private static void DeviceAdded(object sender, DeviceEventArgs args)
 {
     HidDevice hidDevice = HidDevice.Open(args.DevicePath);
     // We can be sure a hid device was be returned,
     // since we only registered device notifications
     // for hid devices.
     if (vendorId == hidDevice.VendorId
         && productIds.Contains(hidDevice.ProductId)) {
         // The device added appears to be a backlight device.
         devices.Add(args.DevicePath.ToUpper(), hidDevice);
     }
     else {
         // Not a backlight device, dispose!
         hidDevice.Dispose();
     }
 }
 private static void DeviceAdded(object sender, DeviceEventArgs args)
 {
     HidDevice hidDevice = HidDevice.Open(args.DevicePath);
     // We can be sure a hid device was be returned,
     // since we only registered device notifications
     // for hid devices.
     if (VENDOR_ID == hidDevice.VendorId && KeyboardsToListenFor.Any(d => d.ProductID == hidDevice.ProductId)) {
         // The device added appears to be a backlight device.
         LogitechKeyboard keyboard = new LogitechKeyboard(hidDevice, KeyboardsToListenFor.Where(k => k.ProductID == hidDevice.ProductId).First());
         devices.Add(keyboard);
         if (KeyboardConnected != null)
             KeyboardConnected(null, new LogitechKeyboardEventArgs(keyboard));
     }
     else {
         // Not a backlight device, dispose!
         hidDevice.Dispose();
     }
 }
 private static void DeviceRemoved(object sender, DeviceEventArgs args)
 {
     // If a device was removed which exists in our dictionary,
     // then this is the time to dispose and remove it.
     string path = args.DevicePath.ToUpper();
     if (devices.Any(d => d.Device.DevicePath.ToUpper().Equals(path))) {
         var device = devices.First(d => d.Device.DevicePath.ToUpper().Equals(path));
         device.Device.Dispose();
         devices.Remove(device);
         if (KeyboardDisconnected != null)
             KeyboardDisconnected(null, new LogitechKeyboardEventArgs(device));
     }
 }