示例#1
0
        private void DeviceListener_Paired(object sender, PairedEventArgs e)
        {
            Contract.Requires <ArgumentNullException>(sender != null, "sender");

            if (_myos.ContainsKey(e.MyoHandle))
            {
                return;
            }

            var myoDeviceBridge = CreateMyoDeviceBridge();

            // TODO: replace this obsolete call with the one below
#pragma warning disable 0618
            var myoDeviceDriver = CreateMyoDeviceDriver(
                e.MyoHandle,
                myoDeviceBridge);
#pragma warning restore 0618

            // TODO: use this call once the obsolete method is removed
            ////var myoErrorHandlerDriver = MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create());
            ////var myoDeviceDriver = CreateMyoDeviceDriver(
            ////    e.MyoHandle,
            ////    myoDeviceBridge,
            ////    myoErrorHandlerDriver);

            var myo = CreateMyo(
                ((IDeviceListener)sender).ChannelListener,
                myoDeviceDriver);

            _myos[myo.Handle] = myo;
            HookMyoEvents(myo);
        }
示例#2
0
        private void DeviceListener_Paired(object sender, PairedEventArgs e)
        {
            var myo = CreateMyo(
                e.MyoHandle,
                ((IDeviceListener)sender).ChannelListener);

            HookMyoEvents(myo);
        }
示例#3
0
        private void DeviceListener_Unpaired(object sender, PairedEventArgs e)
        {
            IMyo myo;

            if (!_myos.TryGetValue(e.MyoHandle, out myo) || myo == null)
            {
                return;
            }

            UnhookMyoEvents(myo);
            _myos.Remove(myo.Handle);
            myo.Dispose();
        }
示例#4
0
        private void DeviceListener_Unpaired(object sender, PairedEventArgs e)
        {
            Contract.Requires <ArgumentNullException>(sender != null, "sender");

            IMyo myo;

            if (!_myos.TryGetValue(e.MyoHandle, out myo) || myo == null)
            {
                return;
            }

            UnhookMyoEvents(myo);
            _myos.Remove(myo.Handle);
            myo.Dispose();
        }