Пример #1
0
        protected Workspace(ILog log, ISchedulerProvider scheduler, IViewService viewService)
            : base(log)
        {
            Scheduler   = scheduler;
            ViewService = viewService;

            BusyViewModel = new BusyViewModel(log, scheduler);

            Disposables = new CompositeDisposable();

            CloseCommand = new DelegateCommand(Close);

            Show();
        }
Пример #2
0
        protected Workspace(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog)
        {
            _log = log;
            _scheduler = scheduler;
            _standardDialog = standardDialog;

            ClosingStrategy = new ClosingStrategy(log);
            ClosingStrategy.AddDisposable(Disposables);

            ClosingStrategy.Closing
                           .TakeUntil(ClosingStrategy.Closed)
                           .Subscribe(_ =>
                                      {
                                          Closing();

                                          CleanUp();
                                      });

            this.ExecuteOnClosed(() => Disposables.Dispose());

            BusyViewModel = new BusyViewModel(scheduler);
            BusyViewModel.AddDisposable(Disposables);

            ActivationStateViewModel = new ActivationStateViewModel(log, scheduler);
            ActivationStateViewModel.AddDisposable(Disposables);

            ActivationStateViewModel.OnInitialise
                                    .SelectMany(_ => OnInitialise().ToObservable()
                                                                   .TakeUntil(BusyViewModel.BusyLatch))
                                    .TakeUntil(ClosingStrategy.Closed)
                                    .Subscribe(_ => { });

            ActivationStateViewModel.ActivationStateChanged
                                    .ObserveOn(scheduler.Dispatcher.RX)
                                    .Where(isActive => isActive)
                                    .TakeUntil(ClosingStrategy.Closed)
                                    .Subscribe(_ => OnActivate());

            ActivationStateViewModel.ActivationStateChanged
                                    .ObserveOn(scheduler.Dispatcher.RX)
                                    .Where(isActive => !isActive)
                                    .TakeUntil(ClosingStrategy.Closed)
                                    .Subscribe(_ => OnDeActivate());

            Show();
        }
Пример #3
0
        protected Workspace(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog)
        {
            _log            = log;
            _scheduler      = scheduler;
            _standardDialog = standardDialog;

            ClosingStrategy = new ClosingStrategy(log);
            ClosingStrategy.AddDisposable(Disposables);

            ClosingStrategy.Closing
            .TakeUntil(ClosingStrategy.Closed)
            .Subscribe(_ =>
            {
                Closing();

                CleanUp();
            });

            this.ExecuteOnClosed(() => Disposables.Dispose());

            BusyViewModel = new BusyViewModel(scheduler);
            BusyViewModel.AddDisposable(Disposables);

            ActivationStateViewModel = new ActivationStateViewModel(log, scheduler);
            ActivationStateViewModel.AddDisposable(Disposables);

            ActivationStateViewModel.OnInitialise
            .SelectMany(_ => OnInitialise().ToObservable()
                        .TakeUntil(BusyViewModel.BusyLatch))
            .TakeUntil(ClosingStrategy.Closed)
            .Subscribe(_ => { });

            ActivationStateViewModel.ActivationStateChanged
            .ObserveOn(scheduler.Dispatcher.RX)
            .Where(isActive => isActive)
            .TakeUntil(ClosingStrategy.Closed)
            .Subscribe(_ => OnActivate());

            ActivationStateViewModel.ActivationStateChanged
            .ObserveOn(scheduler.Dispatcher.RX)
            .Where(isActive => !isActive)
            .TakeUntil(ClosingStrategy.Closed)
            .Subscribe(_ => OnDeActivate());

            Show();
        }
Пример #4
0
        void ISupportActivationState.Activate()
        {
            Log.Debug(string.Format("Activate called on {0} - {1}", GetType().FullName, Header));
            Log.Debug(string.Format("Active value - {0}", IsActive));
            if (IsActive)
            {
                return;
            }

            IsActive = true;
            Log.Debug(string.Format("Active value - {0}", IsActive));

            _activationStateChanged.OnNext(IsActive);

            OnActivate();

            if (_onInitialiseHasBeenCalled)
            {
                return;
            }

            Log.Debug(string.Format("Calling OnInitialise on {0} - {1}", GetType().FullName, Header));

            BusyViewModel.ActiveAsync("... Initialising ...")
            .Then(() =>
            {
                OnInitialise();

                Initialised.SafeInvoke(this);
                _onInitialiseHasBeenCalled = true;
            }, Scheduler.TPL.Task)
            .LogException(Log)
            .CatchAndHandle(ex => ViewService
                            .StandardDialogBuilder()
                            .Error("Error", string.Format("Exception in OnInitialise() call. {0}", ex.Message)), Scheduler.TPL.Task)
            .Finally(BusyViewModel.InActive, Scheduler.TPL.Task);
        }
Пример #5
0
 public SupportBusyViewModel(IDispatcherSchedulerProvider scheduler)
 {
     BusyViewModel = new BusyViewModel(scheduler);
 }