/// <summary> /// When a user changes the device we want to change the device the meter is associating with. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void inputDevices_SelectionChanged(object sender, SelectionChangedEventArgs e) { var selectedItem = ((ComboBox)sender).SelectedItem; if (selectedItem == null) { return; } this.selectedDevice = selectedItem.ToString(); Console.WriteLine(selectedDevice); if (meterController != null) { meterController.Dispose(); } try { meterController = new Metering(selectedDevice); meterController.DeviceUpdated += meter_DeviceUpdated; } catch (ArgumentException ex) { MessageBox.Show("Could not capture this device", "Error"); Console.WriteLine(ex.StackTrace); setDefaultDevice(); } }
private void initalizeMeter() { if (selectedDevice_ != null) { if (meterController != null) { meterController.Dispose(); } try { meterController = new Metering(selectedDevice_); meterController.DeviceUpdated += meterController_DeviceUpdated; } catch (ArgumentException ex) { MessageBox.Show("Could not capture this device", "Error"); //setDefaultDirectDevice(); setDefaultDevice(); } } }