// You can use this eventhandler the same way as deviceProvider_DeviceFound.
        static void deviceProvider_DeviceLost(object sender, DeviceInfoEventArgs e)
        {
            Console.WriteLine("A device has been lost.");
            IDeviceInfo lostDeviceInfo = e.DeviceInfo;

            if (lostDeviceInfo is IBluetoothDeviceInfo)
            {
                Console.WriteLine("The address of the Bluetooth device is {0}", ((IBluetoothDeviceInfo)lostDeviceInfo).Address);
            }
        }
        static void deviceProvider_DeviceFound(object sender, DeviceInfoEventArgs e)
        {
            // You can get the IDeviceProvider that found the device by doing the following:
            // IDeviceProvider deviceProvider = (IDeviceProvider)sender;

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

            // You can check if the found device is a bluetooth device (and retrieve its address).
            // This is kind of trivial, because 'all' Wii devices are bluetooth devices.
            // The Bluetooth-address can be used to only use Wii devices with a specific Bluetooth-address.
            if (foundDeviceInfo is IBluetoothDeviceInfo)
            {
                Console.WriteLine("The address of the Bluetooth device is {0}", ((IBluetoothDeviceInfo)foundDeviceInfo).Address);
                // That's it for discovering Wii devices, the next step can be found in 'ConnectExample'.
            }
        }
        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();
        }
        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);
            }
        }
 private void DeviceLost(object sender, DeviceInfoEventArgs args)
 {
     Gtk.Application.Invoke(delegate { LogLine("Lost a device"); });
 }
 private void DeviceFound(object sender, DeviceInfoEventArgs args)
 {
     Gtk.TreeIter iter = default(Gtk.TreeIter);
     Gtk.Application.Invoke(delegate {
         LogLine("Found a device, trying to connect...");
         string details = "unavailable";
         if(args.DeviceInfo is IBluetoothDeviceInfo)
             details = ((IBluetoothDeviceInfo)(args.DeviceInfo)).Address.ToString();
         iter = _ListStore.AppendValues("Device", details);
     } );
     try
     {
         IDevice device = _Provider.Connect(args.DeviceInfo);
         Gtk.Application.Invoke(delegate { LogLine("Successfully connected to the device!");
             AddDevice(device, iter); });
     }
     catch(DeviceConnectException e)
     {
         Gtk.Application.Invoke(delegate {
             LogLine(e.Message);
             _ListStore.Remove(ref iter);
         });
     }
 }
Exemple #7
0
 private void DeviceLost(object sender, DeviceInfoEventArgs args)
 {
     Remove(args.DeviceInfo);
 }
Exemple #8
0
 private void DeviceFound(object sender, DeviceInfoEventArgs args)
 {
     UIDevice uiDevice = Add(args.DeviceInfo);
     if (autoconnectBox.Checked)
         Connect(uiDevice);
 }