public DefaultView(SimulationViewModel viewModel) { InitializeComponent(); this.viewModel = viewModel; }
public MainWindow() { InitializeComponent(); AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainUnhandledException; TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; Application.Current.SessionEnding += OnSessionEnding; string[] commandLineArgs = Environment.GetCommandLineArgs(); if (commandLineArgs.Length != 2) { Environment.Exit(-1); } if (!File.Exists(commandLineArgs[1])) { Environment.Exit(-1); } ConfigFile config = ConfigFile.Read(commandLineArgs[1]); TrajectorySource trajectorySource = Key.LeftShift.IsDownAsync() ? TrajectorySource.Joystick : TrajectorySource.NmeaFile; Output output = null; try { output = GetOutput(config); } catch (LabSatException ex) { MessageBox.Show(this, ex.Message, "Error"); Application.Current.Shutdown(); return; } output.Error += OnOutputError; liveOutput = (output as ILiveOutput); if (liveOutput != null) { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; } simulation = GetSimulator(config, output, trajectorySource); if (simulation == null) { Environment.Exit(-1); return; } viewModel = new SimulationViewModel(simulation); base.DataContext = viewModel; Control control = (Control)((liveOutput == null) ? ((object)new DefaultView(viewModel)) : ((object)new RealTimeView(viewModel))); control.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); preferredViewSize = control.DesiredSize; if (preferredViewSize.Width < control.MinWidth) { preferredViewSize.Width = control.MinWidth; } if (preferredViewSize.Height < control.MinHeight) { preferredViewSize.Height = control.MinHeight; } base.MinWidth = control.MinWidth + 20.0; base.MinHeight = control.MinHeight + 38.0; base.Width = preferredViewSize.Width + 20.0; base.Height = preferredViewSize.Height + 38.0; MainGrid.Children.Add(control); SystemUtils.SetThreadExecutionMode(ThreadExecutionModes.KeepSystemAwake); simulation.Completed += OnSimulationCompleted; base.Loaded += OnLoaded; }
public RealTimeView(SimulationViewModel viewModel) { InitializeComponent(); this.viewModel = viewModel; }