示例#1
0
文件: Workspace.cs 项目: smwhit/Naru
        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
文件: Workspace.cs 项目: ganesum/Naru
        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
文件: Workspace.cs 项目: ganesum/Naru
        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
文件: Workspace.cs 项目: smwhit/Naru
        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);
 }