Exemple #1
0
 public async void Connect(DeviceListEntry device)
 {
     if (device != null)
     {
         EventHandlerForDevice.CreateNewEventHandlerForDevice();
         EventHandlerForDevice.Current.OnDeviceConnected = this.OnDeviceConnected;
         EventHandlerForDevice.Current.OnDeviceClose     = this.OnDeviceClosing;
         Boolean openSuccess = await EventHandlerForDevice.Current.OpenDeviceAsync(device.DeviceInformation, device.DeviceSelector);
     }
 }
Exemple #2
0
        private void AddDeviceToList(DeviceInformation deviceInformation, String deviceSelector)
        {
            var match = FindDevice(deviceInformation.Id);

            if (match == null)
            {
                match = new DeviceListEntry(deviceInformation, deviceSelector);
                listOfDevices.Add(match);
            }
        }
        private void DisconnectBtn_Clicked(Object sender, RoutedEventArgs eventArgs)
        {
            isActive = false;
            var             selection = ConnectDevices.SelectedItems;
            DeviceListEntry entry     = null;

            EventHandlerForDevice.Current.IsEnabledAutoReconnect = false;

            if (selection.Count > 0)
            {
                var obj = selection[0];
                entry = (DeviceListEntry)obj;

                if (entry != null)
                {
                    EventHandlerForDevice.Current.CloseDevice();
                }
            }
            UpdateConnectDisconnectButtonsAndList(true);
        }
        private async void ConnectBtn_Clicked(Object sender, RoutedEventArgs eventArgs)
        {
            var             selection = ConnectDevices.SelectedItems;
            DeviceListEntry entry     = null;

            if (selection.Count > 0)
            {
                var obj = selection[0];
                entry = (DeviceListEntry)obj;

                if (entry != null)
                {
                    EventHandlerForDevice.CreateNewEventHandlerForDevice();
                    EventHandlerForDevice.Current.OnDeviceConnected = this.OnDeviceConnected;
                    EventHandlerForDevice.Current.OnDeviceClose     = this.OnDeviceClosing;
                    Boolean openSuccess = await EventHandlerForDevice.Current.OpenDeviceAsync(entry.DeviceInformation, entry.DeviceSelector);

                    UpdateConnectDisconnectButtonsAndList(!openSuccess);
                }
            }
        }