void Instance_DeviceRemoved(object sender, OmApiNet.OmDeviceEventArgs e) { this.BeginInvoke(new Om.OmDeviceEventHandler(RemoveDevice), new object[] { sender, e }); }
private void RemoveDevice(object sender, OmApiNet.OmDeviceEventArgs e) { int id = e.Device.DeviceId; if (devices.ContainsKey(id)) { // Always remove device devices.Remove(id); } UpdateDevices(); }
private void AddDevice(object sender, OmApiNet.OmDeviceEventArgs e) { int id = e.Device.DeviceId; DeviceStatus device; if (!devices.ContainsKey(id)) { devices[id] = new DeviceStatus(id); } device = devices[id]; if (device.Connected) { Console.WriteLine("WARNING: Device ID " + id + " already connected!"); return; } device.Connected = true; UpdateDevices(); }