public SharedStateViewModel(IAppState appState, IAppService appService) { _appState = appState; OpenView = ReactiveCommand.Create( HandleOpenView, this.WhenAny( vm => vm.IsViewOpen, vm => vm.ActiveSharedStateProvider, (_, __) => !_isViewOpen && _activeSharedStateProvider != null ) ); ApplyParametersState = ReactiveCommand.Create(HandleApplyParametersState); ShareParametersState = ReactiveCommand.Create(HandleShareParametersState); ApplyOutputsState = ReactiveCommand.Create(HandleApplyOutputsState); ShareOutputsState = ReactiveCommand.Create(HandleShareOutputsState); ApplyObservationsState = ReactiveCommand.Create(HandleApplyObservationsState); ShareObservationsState = ReactiveCommand.Create(HandleShareObservationsState); ApplyState = ReactiveCommand.Create(HandleApplyState); ShareState = ReactiveCommand.Create(HandleShareState); _applySingleParameterState = ReactiveCommand.Create <SimParameterSharedState>(HandleApplySingleParameterState); _applySingleOutputState = ReactiveCommand.Create <SimElementSharedState>(HandleApplySingleOutputState); _applySingleObservationsState = ReactiveCommand.Create <SimObservations>(HandleApplySingleObservationsState); CloseView = ReactiveCommand.Create(HandleCloseView); _appState .ObservableForProperty(s => s.ActiveUIComponent) .Subscribe(appService.SafeInvoke <object>(ObserveActiveUIComponent)); _appState.SimSharedState .ObservableForProperty(ss => ss.ParameterSharedStates) .Subscribe(appService.SafeInvoke <object>(ObserveParameterSharedStates)); _appState.SimSharedState .ObservableForProperty(ss => ss.ElementSharedStates) .Subscribe(appService.SafeInvoke <object>(ObserveElementSharedStates)); _appState.SimSharedState .ObservableForProperty(ss => ss.ObservationsSharedStates) .Subscribe(appService.SafeInvoke <object>(ObserveObservationsSharedStates)); UpdateSharedStateTarget(); UpdateSharedParameters(); UpdateSharedOutputs(); UpdateSharedObservations(); }
public RunControlViewModel(IAppState appState, IAppService appService) { _appState = appState; _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); _subscriptions = new CompositeDisposable( _appState .ObservableForProperty(@as => @as.RunControl) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke<object>( ObserveAppStateRunControl ) ) ); }
public SimulationHomeViewModel(IAppState appState, IAppService appService) { _appState = appState; _appService = appService; SharedStateViewModel = new SharedStateViewModel(appState, appService); BusyCancel = ReactiveCommand.Create(HandleBusyCancel); ChangeCommonConfiguration = ReactiveCommand.Create(HandleChangeCommonConfiguration); Export = ReactiveCommand.Create( HandleExport, appState.WhenAny( @as => @as.ActiveUIComponent, _ => appState.ActiveUIComponent.ViewModel is IExportedDataProvider )); Close = ReactiveCommand.Create(HandleClose); _appState.Simulation.Subscribe( appService.SafeInvoke <Option <Simulation> >( ObserveSimulation ) ); _appState .ObservableForProperty(s => s.UIComponents) .Subscribe(appService.SafeInvoke <object>(ObserveUIComponents)); _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); _appState .WhenAny(s => s.ActiveUIComponent, _ => default(object)) .Subscribe(ObserveActiveUIComponent); this .ObservableForProperty(vm => vm.UIComponentIndex) .Subscribe(_reactiveSafeInvoke.SuspendAndInvoke <object>(ObserveUIComponentIndex)); MonitorTaskRunners(); }