示例#1
0
        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);
        }
示例#2
0
        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;
        }