Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DstBrowserHeaderViewModel"/>
        /// </summary>
        /// <param name="dstController">The <see cref="IDstController"/></param>
        /// <param name="statusBarControlViewModel">The <see cref="IStatusBarControlViewModel"/></param>
        /// <param name="navigationService">The <see cref="INavigationService"/></param>
        public DstBrowserHeaderViewModel(IDstController dstController, IStatusBarControlViewModel statusBarControlViewModel,
                                         INavigationService navigationService)
        {
            this.dstController             = dstController;
            this.statusBarControlViewModel = statusBarControlViewModel;
            this.navigationService         = navigationService;

            this.WhenAnyValue(x => x.dstController.IsSessionOpen)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(_ => this.UpdateProperties());

            CDPMessageBus.Current.Listen <OpcVariableChangedEvent>().Where(x => Equals(x.Id, this.currentServerTimeNodeId.Identifier))
            .Subscribe(e => this.CurrentServerTime = (DateTime)e.Value);

            this.WhenAnyValue(x => x.SelectedStepping, x => x.SelectedStopStep)
            .Subscribe(_ => this.UpdateCanRunExperiment());

            this.CallRunMethodCommand = ReactiveCommand.Create(
                this.WhenAnyValue(x => x.CanRunExperiment));

            this.CallRunMethodCommand.Subscribe(_ => this.RunExperiment());

            this.CallResetMethodCommand = ReactiveCommand.Create(
                this.WhenAnyValue(vm => vm.dstController.IsSessionOpen));

            this.CallResetMethodCommand.Subscribe(_ => this.Reset());

            this.WhenAny(x => x.ExperimentTime,
                         x => x.dstController.IsSessionOpen,
                         (time, isConnected)
                         => Math.Abs(time.Value) <= 0 && isConnected.Value)
            .Subscribe(x => this.AreTimeStepAnStepTimeEditable = x);
        }
        /// <summary>
        /// Initializes a new <see cref="DstNetChangePreviewViewModel"/>
        /// </summary>
        /// <param name="dstController">The <see cref="IDstController"/></param>
        /// <param name="navigationService">The <see cref="INavigationService"/></param>
        /// <param name="hubController">The <see cref="IHubController"/></param>
        /// <param name="statusBar">The <see cref="IStatusBarControlViewModel"/></param>
        public DstNetChangePreviewViewModel(IDstController dstController, INavigationService navigationService,
                                            IHubController hubController, IStatusBarControlViewModel statusBar) : base(dstController, navigationService, hubController, statusBar)
        {
            CDPMessageBus.Current.Listen <UpdateDstVariableTreeEvent>()
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => this.UpdateTree(x.Reset));

            CDPMessageBus.Current.Listen <UpdateDstPreviewBasedOnSelectionEvent>()
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => this.UpdateTreeBasedOnSelectionHandler(x.Selection.ToList()));
        }
        /// <summary>
        /// Initializes a new <see cref="MainWindowViewModel"/>
        /// </summary>
        /// <param name="hubHubDataSourceViewModelViewModel">A <see cref="IHubDataSourceViewModel"/></param>
        /// <param name="dstSourceViewModelViewModel">A <see cref="IHubDataSourceViewModel"/></param>
        /// <param name="dstController">The <see cref="IDstController"/></param>
        /// <param name="hubNetChangePreviewViewModel">The <see cref="IHubNetChangePreviewViewModel"/></param>
        /// <param name="mappingViewModel">The <see cref="IMappingViewModel"/></param>
        /// <param name="transferControlViewModel">The <see cref="ITransferControlViewModel"/></param>
        /// <param name="statusBarControlViewModel">The <see cref="IStatusBarControlViewModel"/></param>
        /// <param name="navigationService">The <see cref="INavigationService"/></param>
        public MainWindowViewModel(IHubDataSourceViewModel hubHubDataSourceViewModelViewModel,
                                   IDstDataSourceViewModel dstSourceViewModelViewModel,
                                   IDstController dstController,
                                   IHubNetChangePreviewViewModel hubNetChangePreviewViewModel,
                                   ITransferControlViewModel transferControlViewModel,
                                   IMappingViewModel mappingViewModel,
                                   IStatusBarControlViewModel statusBarControlViewModel,
                                   INavigationService navigationService
                                   )
        {
            this.dstController                = dstController;
            this.HubDataSourceViewModel       = hubHubDataSourceViewModelViewModel;
            this.DstSourceViewModel           = dstSourceViewModelViewModel;
            this.HubNetChangePreviewViewModel = hubNetChangePreviewViewModel;
            this.MappingViewModel             = mappingViewModel;
            this.TransferControlViewModel     = transferControlViewModel;
            this.StatusBarControlViewModel    = statusBarControlViewModel;
            this.navigationService            = navigationService;

            this.InitializeCommands();
        }