public TraceViewModel( IAppState appState, IAppService appService, IAppSettings appSettings, Arr <ParameterViewModel> parameterViewModels, ModuleState moduleState, OutputGroupStore outputGroupStore ) { RequireNotNull(SynchronizationContext.Current); _appState = appState; _appService = appService; _parameterViewModels = parameterViewModels; _moduleState = moduleState; _outputGroupStore = outputGroupStore; _simulation = appState.Target.AssertSome("No simulation"); TraceDataPlotViewModels = Range(1, ModuleState.N_TRACES) .Map(i => new TraceDataPlotViewModel( appState, appService, appSettings, moduleState.TraceDataPlotStates[i - 1] ) ) .ToArr <ITraceDataPlotViewModel>(); var nTracesVisible = _moduleState.TraceDataPlotStates.Count(s => s.IsVisible); ChartGridLayout = nTracesVisible - 1; WorkingSet = new ObservableCollection <IParameterViewModel>( parameterViewModels.Filter(vm => vm.IsSelected) ); UndoWorkingChange = ReactiveCommand.Create( HandleUndoWorkingChange, this.WhenAny(vm => vm.SessionEdits, _ => SessionEdits.Count > 1) ); PlotWorkingChanges = ReactiveCommand.Create( HandlePlotWorkingChanges, this.WhenAny(vm => vm.HasPendingWorkingChanges, _ => HasPendingWorkingChanges) ); _isWorkingSetPanelOpen = _moduleState.TraceState.IsWorkingSetPanelOpen ? 0 : -1; var(ms, _) = _appState.SimData .GetExecutionInterval(_simulation) .IfNone((304, default));
public OutputsViewModel(IAppState appState, OutputGroupStore outputGroupStore) { RequireNotNull(SynchronizationContext.Current); _simulation = appState.Target.AssertSome(); _simData = appState.SimData; _outputGroupStore = outputGroupStore; LogEntryViewModels = new ObservableCollection <ILogEntryViewModel>(); LoadLogEntry = ReactiveCommand.Create( HandleLoadLogEntry, this.WhenAny( vm => vm.SelectedLogEntryViewModels, _ => SelectedLogEntryViewModels?.Length == 1 ) ); CreateOutputGroup = ReactiveCommand.Create( HandleCreateOutputGroup, this.WhenAny( vm => vm.SelectedLogEntryViewModels, _ => SelectedLogEntryViewModels?.Length > 1 ) ); FollowKeyboardInLogEntries = ReactiveCommand.Create <(Key Key, bool Control, bool Shift)>( HandleFollowKeyboardInLogEntries ); OutputGroupViewModels = new ObservableCollection <IOutputGroupViewModel>( outputGroupStore.OutputGroups.Map(og => new OutputGroupViewModel(og)) ); LoadOutputGroup = ReactiveCommand.Create( HandleLoadOutputGroup, this.WhenAny(vm => vm.SelectedOutputGroupViewModel, _ => SelectedOutputGroupViewModel != null) ); FollowKeyboardInOutputGroups = ReactiveCommand.Create <(Key Key, bool Control, bool Shift)>( HandleFollowKeyboardInOutputGroups ); _subscriptions = new CompositeDisposable( appState.SimDataSessionLog.LogEntries .ObserveOn(SynchronizationContext.Current) .Subscribe(ObserveLogEntry), outputGroupStore.ActivatedOutputGroups .ObserveOn(SynchronizationContext.Current) .Subscribe(ObserveActivateOutputGroup) ); }
internal ViewModel(IAppState appState, IAppService appService, IAppSettings appSettings) { _appState = appState; _sharedState = appState.SimSharedState; _simulation = appState.Target.AssertSome("No simulation"); _evidence = appState.SimEvidence; _moduleState = ModuleState.LoadOrCreate(_simulation); _outputGroupStore = new OutputGroupStore(_simulation); _parameters = new Parameters(_simulation, appService, _moduleState); _traceViewModel = new TraceViewModel(appState, appService, appSettings, _parameters.ViewModels, _moduleState, _outputGroupStore); _parametersViewModel = new ParametersViewModel(_parameters.ViewModels); _outputsViewModel = new OutputsViewModel(appState, _outputGroupStore); _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); _subscriptions = new CompositeDisposable(SubscribeToObservables()); TraceViewModel.IsSelected = true; }