private void ToggleAutomation_OnChecked(object sender, RoutedEventArgs e) { if (portControl is null) { return; } if ((AutoSwitchOn?.IsChecked ?? false) && !portControl.IsSimulating) { SetInteractive(false); portControl.StartSimulation(); } else if ((AutoSwitchOff?.IsChecked ?? false) && portControl.IsSimulating) { portControl.StopSimulation(); SetInteractive(true); } }