Пример #1
0
        private async void ShadowDriverDeviceWatcher_Added(DeviceWatcher sender, DeviceInformation args)
        {
            System.Diagnostics.Debug.WriteLine(args.Id);
            sender.Stop();
            _shadowDevice = await CustomDevice.FromIdAsync(args.Id, DeviceAccessMode.ReadWrite, DeviceSharingMode.Shared);

            IsFilterReady = true;
            FilterReady?.Invoke();
        }
Пример #2
0
        private async void ShadowDriverDeviceWatcher_Added(Windows.Devices.Enumeration.DeviceWatcher sender, Windows.Devices.Enumeration.DeviceInformation args)
        {
            ShadowDriverDevice = await CustomDevice.FromIdAsync(args.Id, DeviceAccessMode.ReadWrite, DeviceSharingMode.Exclusive);

            if (ShadowDriverDevice != null)
            {
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    ViewModel.DeviceConnectStatus = "Connected";
                });
            }
        }
        private async Task OpenFx2DeviceAsync(string Id)
        {
            System.Diagnostics.Debug.Assert(DeviceList.Current.GetSelectedDevice() == null);

            try
            {
                var device = await CustomDevice.FromIdAsync(Id, DeviceAccessMode.ReadWrite, DeviceSharingMode.Exclusive);

                DeviceList.Current.SetSelectedDevice(Id, device);
            }
            catch (Exception e)
            {
                rootPage.NotifyUser($"Error opening Fx2 device @{Id}: {e.Message}", NotifyType.ErrorMessage);
                return;
            }
            rootPage.NotifyUser($"Fx2 {Id} opened", NotifyType.StatusMessage);
            return;
        }
Пример #4
0
 private async System.Threading.Tasks.Task <bool> SetCDDeviceAsync()
 {
     try
     {
         if (CDReaderDevice == null)
         {
             CDReaderDevice = await CustomDevice.FromIdAsync(DeviceID, DeviceAccessMode.Read, DeviceSharingMode.Exclusive);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception while getting CDREaderDevice: " + ex.Message);
     }
     if (CDReaderDevice != null)
     {
         return(true);
     }
     return(false);
 }