private void MainPageLoaded(object sender, RoutedEventArgs e) { ProgrammatorDevice.UsbDeviceFound += async(o, args) => { _programmator = args.ProgrammatorDevice; await _programmator.SendRandomMessage(); }; ProgrammatorDevice.SearchForUsbDevices(Dispatcher); }
private void MainPageLoaded(object sender, RoutedEventArgs e) { ProgrammatorDevice.UsbDeviceFound += async (o, args) => { _programmator = args.ProgrammatorDevice; await _programmator.SendRandomMessage(); }; ProgrammatorDevice.SearchForUsbDevices(Dispatcher); }
public static void SearchForUsbDevices(CoreDispatcher dispatcher) { DeviceWatcher deviceWatcher = DeviceInformation.CreateWatcher(HidDevice.GetDeviceSelector(uPage, uid)); deviceWatcher.Added += (s, a) => dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => { HidDevice hidDevice = await HidDevice.FromIdAsync(a.Id, FileAccessMode.ReadWrite); var launcher = new ProgrammatorDevice(hidDevice); if (UsbDeviceFound != null) { UsbDeviceFound(null, new ProgrammatorDeviceEventArgs(launcher)); } deviceWatcher.Stop(); }); deviceWatcher.Start(); }
public static void SearchForUsbDevices(CoreDispatcher dispatcher) { DeviceWatcher deviceWatcher = DeviceInformation.CreateWatcher(HidDevice.GetDeviceSelector(uPage, uid)); deviceWatcher.Added += (s, a) => dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { HidDevice hidDevice = await HidDevice.FromIdAsync(a.Id, FileAccessMode.ReadWrite); var launcher = new ProgrammatorDevice(hidDevice); if (UsbDeviceFound != null) { UsbDeviceFound(null, new ProgrammatorDeviceEventArgs(launcher)); } deviceWatcher.Stop(); }); deviceWatcher.Start(); }
public ProgrammatorDeviceEventArgs(ProgrammatorDevice programmator) { ProgrammatorDevice = programmator; }