public static void DiscoverDevices()
 {
     Log.WriteLine("COMMFACTORY: Device Discovery initiated.");
     _available.Clear();
     _handlers.ForEach(handler => handler.DiscoverDeviceInstances((device) =>
     {
         Log.WriteLine("COMMFACTORY: Device found: " + device);
         WpfUtilities.RunOnUiThread(() =>
         {
             _available.Add(device);
         },
                                    System.Windows.Application.Current.Dispatcher);
     }));
 }
Exemplo n.º 2
0
        public async Task OnDiscoverDevices()
        {
            WpfUtilities.RunOnUiThread(() => { AvailableDevices.Clear(); }, Application.Current.Dispatcher);

            CommunicationHandlerFactory.DiscoverDevices();
            await Task.Delay(500);

            foreach (var device in CommunicationHandlerFactory.AvailableDevices)
            {
                var handler = CommunicationHandlerFactory.AvailableHandlers.First(h => h.IsDriverForDevice(device));
                var driver  = new DeviceDriver(device, handler.SupportsSetupDialog, new DelegateCommand((p) => OnRunDeviceHandlerSetup(handler, p)));
                WpfUtilities.RunOnUiThread(() => { AvailableDevices.Add(driver); }, Application.Current.Dispatcher);
            }
        }
Exemplo n.º 3
0
        private async void OnTimer(object s, EventArgs e)
        {
            _timerStatus.Stop();
            if (_mountVM.ConnectionState.StartsWith("Connected"))
            {
                bool restartTimer = true;
                var  gxDoneEvent  = new AsyncAutoResetEvent();
                _sendCommand(":GX#,#", (result) =>
                {
                    if (result.Success)
                    {
                        var parts = result.Data.Split(',');
                        if (!_currentStatusFunc(parts))
                        {
                            restartTimer = false;
                            WpfUtilities.RunOnUiThread(() => { this.DialogResult = true; this.Close(); }, Application.Current.Dispatcher);
                        }
                    }
                    else
                    {
                        if (!_currentStatusFunc(null))
                        {
                            restartTimer = false;
                            WpfUtilities.RunOnUiThread(() => { this.DialogResult = true; this.Close(); }, Application.Current.Dispatcher);
                        }
                    }
                    gxDoneEvent.Set();
                });

                await gxDoneEvent.WaitAsync();

                if (restartTimer)
                {
                    _timerStatus.Start();
                }
            }
            else
            {
                WpfUtilities.RunOnUiThread(() => { this.DialogResult = true; this.Close(); }, Application.Current.Dispatcher);
            }
        }
 private void OnClose()
 {
     WpfUtilities.RunOnUiThread(() => { this.DialogResult = false; this.Close(); }, Application.Current.Dispatcher);
 }
Exemplo n.º 5
0
 private void OnCancel()
 {
     _timerStatus.Stop();
     WpfUtilities.RunOnUiThread(() => { this.DialogResult = false; this.Close(); }, Application.Current.Dispatcher);
 }
Exemplo n.º 6
0
 private static void OnWifiClientFound(object sender, ClientFoundEventArgs e) => WpfUtilities.RunOnUiThread(
     () =>
 {
     Log.WriteLine($"COMMFACTORY: Wifi device {e.Name} replied from {e.Address}:4030!");
     _available.Insert(0, $"WiFi : {e.Name} ({e.Address}:4030)");
 },
     System.Windows.Application.Current.Dispatcher);