Exemple #1
0
        static void deviceProvider_DeviceFound(object sender, DeviceInfoEventArgs e)
        {
            IDeviceProvider deviceProvider = (IDeviceProvider)sender;

            Console.WriteLine("A device has been found.");
            IDeviceInfo foundDeviceInfo = e.DeviceInfo;

            // Example 2. Connecting to a discovered device.
            // When you connect to a discovered device, it will result in a IDevice.
            // IDevice represents the device when connected.
            Console.WriteLine("Connecting to the device...");
            IDevice device = deviceProvider.Connect(foundDeviceInfo);

            Console.WriteLine("Connected to the device.");

            // You have connected to the device,
            // and can now use 'device' to interact with the connected device.
            // Note that 'device.DeviceInfo' is refering to 'foundDeviceInfo', which we used to connect to the device.
            // We can use the Disconnected event to stay informed if we can still use the device.
            device.Disconnected += device_Disconnected;

            // When the 'device' is an 'IDevice' you can only access properties that are common to
            // all Devices (Wiimote, BalanceBoard, etc...).
            // These devices have their own types in WiiDeviceLibrary: IWiimote and IBalanceBoard. Both of these types inherit from IDevice.
            // To use properties specific to the devices you will have to cast the 'device' to the proper interface.

            // First we check if the device is the desired type.
            if (device is IWiimote)
            {
                IWiimote wiimote = (IWiimote)device;
                Console.WriteLine("We have connected to a Wiimote device.");
                // Here we have access to all the operations that we can perform on a Wiimote.
                // That's it for connecting to Wii devices.
            }
            else if (device is IBalanceBoard)
            {
                IBalanceBoard balanceboard = (IBalanceBoard)device;
                Console.WriteLine("We have connected to a BalanceBoard device.");
                // Here we have access to all the operations that we can perform on a BalanceBoard.
            }

            // If we don't want to be connected to the device, we can disconnect like this:
            device.Disconnect();
        }
 private void upnpDiscovery_DeviceConnected(object sender, DeviceInfoEventArgs e)
 {
     if (e.DeviceInfo.DeviceType != "urn:dial-multiscreen-org:device:dialreceiver:1")
     {
         Logger   instance   = Logger.Instance;
         object[] deviceType = new object[] { e.DeviceInfo.DeviceType, e.DeviceInfo.DeviceAddress };
         instance.LogMessageFormat("upnpDiscovery_DeviceConnected Device is not Dial Receiver, TV type is {0}, with address: {1}.", deviceType);
         return;
     }
     TvDiscovery.Tv2014InitInfo tv2014Data = TvDiscovery.GetTv2014Data(e.DeviceInfo);
     if (tv2014Data != null)
     {
         Console.WriteLine("Model 2014 Samsung TV found.");
         this.foundTvs.Add(tv2014Data);
         return;
     }
     Console.WriteLine("Pre 2014 Samsung TV found");
     this.devicePool.Add(e.DeviceInfo);
 }
 private void upnpDiscovery_DeviceConnected(object sender, DeviceInfoEventArgs e)
 {
     Logger.Instance.LogMessageFormat("[SmartView2][TvDiscovery]upnpDiscovery_DeviceConnected started... ", new object[0]);
     if (e.DeviceInfo.DeviceType != "urn:dial-multiscreen-org:device:dialreceiver:1")
     {
         Logger   instance   = Logger.Instance;
         object[] deviceType = new object[] { e.DeviceInfo.DeviceType, e.DeviceInfo.DeviceAddress };
         instance.LogMessageFormat("[SmartView2][TvDiscovery]upnpDiscovery_DeviceConnected Device is not Dial Receiver, TV type is {0}, with address: {1}.", deviceType);
         return;
     }
     TvDiscovery.Tv2014InitInfo tv2014Data = TvDiscovery.GetTv2014Data(e.DeviceInfo);
     if (tv2014Data != null)
     {
         Logger.Instance.LogMessageFormat("[SmartView2][TvDiscovery]upnpDiscovery_DeviceConnected TV 2014 found.", new object[0]);
         this.foundTvs.Add(tv2014Data);
         return;
     }
     Logger.Instance.LogMessageFormat("[SmartView2][TvDiscovery]upnpDiscovery_DeviceConnected Earlier TV found", new object[0]);
     this.devicePool.Add(e.DeviceInfo);
 }
        static void deviceProvider_DeviceFound(object sender, DeviceInfoEventArgs e)
        {
            IDeviceProvider deviceProvider = (IDeviceProvider)sender;

            Console.WriteLine("A device has been found.");
            IDeviceInfo foundDeviceInfo = e.DeviceInfo;

            IDevice device = deviceProvider.Connect(foundDeviceInfo);
            Console.WriteLine("Connected to the device.");

            device.Disconnected += device_Disconnected;

            if (device is IWiimote)
            {
                IWiimote wiimote = (IWiimote)device;
                Console.WriteLine("We have connected to a Wiimote device.");
                // Here we have access to all the operations that we can perform on a Wiimote.

                OnWiimoteConnected(wiimote);
            }
        }
Exemple #5
0
        void DeviceFound(object sender, DeviceInfoEventArgs args)
        {
            IDevice device = deviceProvider.Connect(args.DeviceInfo);

            Console.WriteLine("Found device: " + device.ToString());

            board = (IBalanceBoard)device;

            connected(sender, args);

            Console.WriteLine("Waiting 2 seconds for tare...");
            Thread.Sleep(2000);
            Console.WriteLine("Tare done.");

            tare[0] = board.TopLeftWeight;
            tare[1] = board.BottomLeftWeight;

            tare[2] = board.TopRightWeight;
            tare[3] = board.BottomRightWeight;

            board.Updated += Updated;
        }
 protected virtual void OnDeviceLost(DeviceInfoEventArgs e)
 {
     if (DeviceLost == null)
         return;
     DeviceLost(this, e);
 }
 protected virtual void OnDeviceFound(DeviceInfoEventArgs e)
 {
     if (DeviceFound == null)
         return;
     DeviceFound(this, e);
 }
Exemple #8
0
 private void DeviceLost(object sender, DeviceInfoEventArgs args)
 {
     Gtk.Application.Invoke(delegate { LogLine("Lost a device"); });
 }
Exemple #9
0
 void DeviceLost(object sender, DeviceInfoEventArgs args)
 {
     Console.WriteLine("Lost device: " + args.DeviceInfo.ToString());
     disconnected(sender, args);
 }
Exemple #10
0
 private void DeviceLost(object sender, DeviceInfoEventArgs args)
 {
     Remove(args.DeviceInfo);
 }
Exemple #11
0
 /// <summary>
 /// Event invocation method for handling discovered devices
 /// </summary>
 /// <param name="e">Event arguments containing a <see cref="DeviceInfo"/> instance</param>
 private void OnRaiseDeviceDiscoveredEvent(DeviceInfoEventArgs e)
 {
     DeviceDiscoveredEvent?.Invoke(this, e);
 }
 private void devicePool_DeviceRemoved(object sender, DeviceInfoEventArgs e)
 {
     this.OnDeviceDisconnected(this, e);
 }
 private void devicePool_DeviceAdded(object sender, DeviceInfoEventArgs e)
 {
     this.OnDeviceConnected(this, e);
 }