//private void Updating() //{ // while (_UpdateThread != Thread.CurrentThread) // { // // Invoke Update. // Thread.Sleep(20); // } //} private void connectButton_Click(object sender, EventArgs e) { UIDevice uiDevice = devicesBox.SelectedItem as UIDevice; Connect(uiDevice); devicesBox.Invalidate(); }
private void DeviceFound(object sender, DeviceInfoEventArgs args) { UIDevice uiDevice = Add(args.DeviceInfo); if (autoconnectBox.Checked) { Connect(uiDevice); } }
public UIDevice Add(IDevice device) { UIDevice uiDevice = Add(device.DeviceInfo); uiDevice.Device = device; devicesBox.Invalidate(); devicesBox.Update(); return(uiDevice); }
public UIDevice Add(IDeviceInfo deviceInfo) { UIDevice uiDevice; if (!deviceinfoLookup.TryGetValue(deviceInfo, out uiDevice)) { uiDevice = new UIDevice(); uiDevice.DeviceInfo = deviceInfo; deviceinfoLookup.Add(deviceInfo, uiDevice); devices.Add(uiDevice); Invoke(new Action<UIDevice>(delegate(UIDevice ud) { devicesBox.Items.Add(ud); devicesBox.SelectedIndex = devicesBox.Items.Count - 1; }), uiDevice); } else uiDevice.DeviceInfo = deviceInfo; devicesBox.Invalidate(); return uiDevice; }
public IDevice Connect(UIDevice uiDevice) { IDevice device = _Provider.Connect(uiDevice.DeviceInfo); device.Disconnected += new EventHandler(device_Disconnected); if (device is IWiimote) { ((IWiimote)device).Leds = WiimoteLeds.Led1; ((IWiimote)device).IsRumbling = true; System.Threading.Thread.Sleep(500); ((IWiimote)device).IsRumbling = false; } uiDevice.Device = device; deviceLookup[device] = uiDevice; if (device is IWiimote) { Invoke(new Action <IWiimote>(delegate(IWiimote wiimote) { WiimoteUserControl ucontrol = new WiimoteUserControl(); ucontrol.Wiimote = wiimote; uiDevice.Control = ucontrol; wiidevicePanel.Controls.Add(ucontrol); }), device); } else if (device is IBalanceBoard) { Invoke(new Action <IBalanceBoard>(delegate(IBalanceBoard balanceBoard) { BalanceBoardUserControl ucontrol = new BalanceBoardUserControl(); ucontrol.BalanceBoard = balanceBoard; uiDevice.Control = ucontrol; wiidevicePanel.Controls.Add(ucontrol); }), device); } return(device); }
public UIDevice Add(IDeviceInfo deviceInfo) { UIDevice uiDevice; if (!deviceinfoLookup.TryGetValue(deviceInfo, out uiDevice)) { uiDevice = new UIDevice(); uiDevice.DeviceInfo = deviceInfo; deviceinfoLookup.Add(deviceInfo, uiDevice); devices.Add(uiDevice); Invoke(new Action <UIDevice>(delegate(UIDevice ud) { devicesBox.Items.Add(ud); devicesBox.SelectedIndex = devicesBox.Items.Count - 1; }), uiDevice); } else { uiDevice.DeviceInfo = deviceInfo; } devicesBox.Invalidate(); return(uiDevice); }
public IDevice Connect(UIDevice uiDevice) { IDevice device = _Provider.Connect(uiDevice.DeviceInfo); device.Disconnected += new EventHandler(device_Disconnected); if (device is IWiimote) { ((IWiimote)device).Leds = WiimoteLeds.Led1; ((IWiimote)device).IsRumbling = true; System.Threading.Thread.Sleep(500); ((IWiimote)device).IsRumbling = false; } uiDevice.Device = device; deviceLookup[device] = uiDevice; if (device is IWiimote) { Invoke(new Action<IWiimote>(delegate(IWiimote wiimote) { WiimoteUserControl ucontrol = new WiimoteUserControl(); ucontrol.Wiimote = wiimote; uiDevice.Control = ucontrol; wiidevicePanel.Controls.Add(ucontrol); }), device); } else if (device is IBalanceBoard) { Invoke(new Action<IBalanceBoard>(delegate(IBalanceBoard balanceBoard) { BalanceBoardUserControl ucontrol = new BalanceBoardUserControl(); ucontrol.BalanceBoard = balanceBoard; uiDevice.Control = ucontrol; wiidevicePanel.Controls.Add(ucontrol); }), device); } return device; }