private void InRadio_Checked(object sender, RoutedEventArgs e) { if (_inputDevice != null) { _inputDevice.Dispose(); } StartBtn.IsEnabled = true; var radioButton = (RadioButton)sender; SerialOSRSettingsGrid.Visibility = Visibility.Hidden; if (radioButton == InputAddressRdo) { SettingsHandler.InputDevice = OSRRemoteInputMode.Address; GamepadMap.Visibility = Visibility.Hidden; if (SettingsHandler.UseUDP) { _inputDevice = InputUdpAddresshandler; } else { _inputDevice = InputTcpAddresshandler; } InitInputNetworkAddress(); } else if (radioButton == InputGamepadRdo) { SettingsHandler.InputDevice = OSRRemoteInputMode.Gamepad; GamepadMap.Visibility = Visibility.Visible; if (!GamepadHandler.IsRunning) { GamepadHandler.Init(null); } _inputDevice = GamepadHandler; } else if (radioButton == InputSerialRdo) { SettingsHandler.InputDevice = OSRRemoteInputMode.Serial; GamepadMap.Visibility = Visibility.Hidden; _inputDevice = InputSerialDeviceHandler; var selectedValue = InputSerialCmb.SelectedValue as string; if (!string.IsNullOrEmpty(selectedValue) && !InputSerialDeviceHandler.IsRunning) { InputSerialDeviceHandler.Init(new DeviceInitModel() { Address = selectedValue, Mode = OSRRemoteDeviceMode.In }); } } if (OutputSerialRdo.IsChecked.Value || BLERdo.IsChecked.Value) { SerialOSRSettingsGrid.Visibility = Visibility.Visible; } if (_outputDevice != null) { StartBtn.IsEnabled = _inputDevice.IsConnected && _outputDevice.IsConnected; } }
private void InputSerialCmb_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (InputSerialCmb.IsLoaded) { InputSerialDeviceHandler.Dispose(); InputSerialDeviceHandler.Init(new DeviceInitModel() { Address = InputSerialCmb.SelectedValue as string, Mode = OSRRemoteDeviceMode.Out }); } }