private async void ScanTimerOnElapsed(object sender, ElapsedEventArgs e) { if (_isTimerRunning) { return; } _isTimerRunning = true; if (AvailableDevices == null) { AvailableDevices = new Dictionary <string, INuimoDevice>(); } var devices = await _pairedNuimoManager.ListPairedNuimosAsync(); foreach (var nuimoController in devices) { INuimoDevice availableDevice; if (!AvailableDevices.TryGetValue(nuimoController.Identifier, out availableDevice)) { availableDevice = new AvailableNuimoDevice(nuimoController); AvailableDevices.Add(nuimoController.Identifier, availableDevice); NuimoHub.AllClients.DeviceFound(availableDevice); } if (availableDevice.ShouldConnect && availableDevice.ConnectionState == NuimoConnectionState.Disconnected) { await availableDevice.ConnectAsync(); } } _isTimerRunning = false; }
private async void ListPairedNuimos() { PairedNuimosComboBox.Items?.Clear(); _nuimoControllers = await _pairedNuimoManager.ListPairedNuimosAsync(); foreach (var nuimoController in _nuimoControllers) { PairedNuimosComboBox.Items?.Add("Nuimo: " + nuimoController.Identifier); } ReloadButton.Content = "Reload"; if (PairedNuimosComboBox.Items?.Count > 0) { PairedNuimosComboBox.SelectedIndex = 0; } }
private async void ListPairedNuimos() { PairedNuimosComboBox.Items?.Clear(); _nuimoControllers = await _pairedNuimoManager.ListPairedNuimosAsync(); foreach (var nuimoController in _nuimoControllers) { PairedNuimosComboBox.Items?.Add("Nuimo: " + nuimoController.Identifier); } ReloadButton.Content = "Reload"; if (PairedNuimosComboBox.Items?.Count > 0) { PairedNuimosComboBox.SelectedIndex = 0; } if (PairedNuimosComboBox.Items?.Count == 1) { // automatic connect to nuimo ConnectButton_OnClick(null, null); OutputTextBox.Text = new StringBuilder(OutputTextBox.Text) .Append("autoconnect" + "\n") .ToString(); } }