Esempio n. 1
0
        public MainBottomViewModel(IEventAggregator eventAggregator, BusyObserver busyObserver)
        {
            var aggregator = eventAggregator;

            _busyObserver = busyObserver;
            _busyObserver.PropertyChanged += (sender, args) => {
                ContentIsBusy  = _busyObserver.ContentIsBusy;
                UploaderIsBusy = _busyObserver.UploaderIsBusy;
            };

            aggregator.GetEvent <ShellEvents.WallSelectedEvent>().Subscribe(onShellWallSelectedChanged);

            BackCommand = new DelegateCommand(() => {
                aggregator.GetEvent <MainBottomEvents.Back>().Publish();
            }, () => !IsBusy && !ContentIsBusy && !UploaderIsBusy && IsWallSelected)
                          .ObservesProperty(() => IsBusy)
                          .ObservesProperty(() => ContentIsBusy)
                          .ObservesProperty(() => UploaderIsBusy)
                          .ObservesProperty(() => IsWallSelected);

            RefreshCommand = new DelegateCommand(() => {
                aggregator.GetEvent <MainBottomEvents.Refresh>().Publish();
            }, () => !IsBusy && !ContentIsBusy && !UploaderIsBusy)
                             .ObservesProperty(() => IsBusy)
                             .ObservesProperty(() => ContentIsBusy)
                             .ObservesProperty(() => UploaderIsBusy);

            SettingsCommand = new DelegateCommand(() => {
                aggregator.GetEvent <MainBottomEvents.Settings>().Publish();
            });

            Version = App.Version.ToString();
        }
        public WallContentLeftBlockViewModel(IEventAggregator eventAggregator, IRegionManager regionManager,
                                             PullersController pullersController, BusyObserver busyObserver, Settings settings)
        {
            SetProfilePhoto(AuthBarViewModel.DEFAULT_AVATAR);
            _eventAggregator               = eventAggregator;
            _regionManager                 = regionManager;
            _pullersController             = pullersController;
            _busyObserver                  = busyObserver;
            _settings                      = settings;
            _busyObserver.PropertyChanged += (sender, args) => {
                ContentIsBusy = _busyObserver.ContentIsBusy;
            };

            _pullersController.Postponed.WallHolderChanged += onPostponedWallHolderChanged;
            _pullersController.Postponed.PullCompleted     += onPostponedPullCompleted;
            _pullersController.History.PullCompleted       += onHistoryPullCompleted;

            ShowActualWallCommand =
                new DelegateCommand(
                    () => {
                var parameters = new NavigationParameters {
                    { "filter", "howdy" }
                };
                _regionManager.RequestNavigate(RegionNames.ContentMainRegion, ViewNames.WallActualContent,
                                               parameters);
            }, () => !ContentIsBusy)
                .ObservesProperty(() => ContentIsBusy);

            ShowPostponeWallCommand =
                new DelegateCommand(
                    () => {
                _regionManager.RequestNavigate(RegionNames.ContentMainRegion,
                                               $"{ViewNames.WallPostponeContent}?filter=sayhello");
            }, () => !ContentIsBusy)
                .ObservesProperty(() => ContentIsBusy);

            ShowHistoryCommand =
                new DelegateCommand(
                    () => {
                _regionManager.RequestNavigate(RegionNames.ContentMainRegion,
                                               $"{ViewNames.HistoryContent}?filter=sayhello", result => {
                    recountLastSeen();
                });
            }, () => !ContentIsBusy)
                .ObservesProperty(() => ContentIsBusy);


            ExpandAllCommand = new DelegateCommand(() => {
                _eventAggregator.GetEvent <ContentEvents.LeftBlockExpandAllRequest>().Publish();
            });
            CollapseAllCommand = new DelegateCommand(() => {
                _eventAggregator.GetEvent <ContentEvents.LeftBlockCollapseAllRequest>().Publish();
            });
        }