private void FHub_OnDeviceDetached(object Sender, wclWeDoIo Device) { if (Device.DeviceType == wclWeDoIoDeviceType.iodColorSensor && FColor != null && Device.ConnectionId == FColor.ConnectionId) { FColor = null; EnableControl(false); } if (Device.DeviceType == wclWeDoIoDeviceType.iodRgb) { FRgb = null; } }
private void fmMain_Load(object sender, EventArgs e) { FManager = new wclBluetoothManager(); FWatcher = new wclWeDoWatcher(); FWatcher.OnHubFound += FWatcher_OnHubFound; FHub = new wclWeDoHub(); FHub.OnConnected += FHub_OnConnected; FHub.OnDisconnected += FHub_OnDisconnected; FHub.OnDeviceAttached += FHub_OnDeviceAttached; FHub.OnDeviceDetached += FHub_OnDeviceDetached; FColor = null; FRgb = null; }
private void FHub_OnDeviceAttached(object Sender, wclWeDoIo Device) { if (FColor == null) { if (Device.DeviceType == wclWeDoIoDeviceType.iodColorSensor) { FColor = (wclWeDoColorSensor)Device; FColor.OnColorDetected += FColor_OnColorDetected; EnableControl(true); } } if (Device.DeviceType == wclWeDoIoDeviceType.iodRgb) { FRgb = (wclWeDoRgbLight)Device; } }