public MiniMainWindowViewModel(IStatusViewModel status, TrayMainWindowMenu menu)
        {
            Menu            = menu;
            _status         = status;
            _taskbarToolTip = this.WhenAnyValue(x => x.DisplayName, x => x.Status.Status,
                                                FormatTaskbarToolTip)
                              .ToProperty(this, x => x.TaskbarToolTip);
            OpenPopup        = ReactiveCommand.Create();
            ShowNotification = ReactiveCommand.CreateAsyncTask(async x => (ITrayNotificationViewModel)x);
            Deactivate       = ReactiveCommand.Create().DefaultSetup("Deactivate");
            Deactivate.Subscribe(x => Close.Execute(null));

            // TODO: Make this a setting?

            /*            Listen<ApiUserActionStarted>()
             *  .ObserveOnMainThread()
             *  .InvokeCommand(OpenPopup);*/
            this.Listen <ClientInfoUpdated>()
            .Where(x => x.Info.UpdateState == AppUpdateState.Updating).ObserveOnMainThread()
            .InvokeCommand(OpenPopup);
            this.Listen <ShowTrayNotification>()
            .Select(x => new TrayNotificationViewModel(x.Subject, x.Text, x.CloseIn, x.Actions))
            .ObserveOnMainThread()
            .InvokeCommand(ShowNotification);
        }
示例#2
0
        public MainWindowViewModel(
            [NotNull] IStatusViewModel statusViewModel,
            [NotNull] IProjectCollectionViewModel projectCollectionViewModel,
            [NotNull] IConfigurationService configurationService,
            [NotNull] IModelEditor showInDialog)
        {
            Guard.NotNull(configurationService, nameof(configurationService));
            Guard.NotNull(showInDialog, nameof(showInDialog));
            Guard.NotNull(projectCollectionViewModel, nameof(projectCollectionViewModel));
            Guard.NotNull(statusViewModel, nameof(statusViewModel));

            ProjectCollection = projectCollectionViewModel;
            StatusViewModel   = statusViewModel;

            WorkingDirectory = string.Empty;
            Logger.Info("ctor");

            OpenSettings = new OpenSettingsCommand(showInDialog, configurationService, WorkingDirectory);
            Initialize   = new CapturingExceptionAsyncCommand(async() =>
            {
                await Task.WhenAll(
                    ProjectCollection.Initialize.ExecuteAsync(null),
                    StatusViewModel.Initialize.ExecuteAsync(null))
                .ConfigureAwait(false);
            });
        }
        public TrayMainWindowViewModel(IViewModel mainArea, TrayMainWindowMenu menu, IStatusViewModel status,
            LoginInfo loginInfo, IWelcomeViewModel welcomeViewModel) {
            _mainArea = Consts.FirstRun /* || Cheat.Consts.IsTestVersion */ ? welcomeViewModel : mainArea;
            _menu = menu;
            _status = status;
            _loginInfo = loginInfo;

            welcomeViewModel.Close.Subscribe(x => MainArea = mainArea);

            _taskbarToolTip = this.WhenAnyValue(x => x.DisplayName, x => x.Status, FormatTaskbarToolTip)
                .ToProperty(this, x => x.TitleToolTip);

            _avatarUrl = this.WhenAnyValue<TrayMainWindowViewModel, Uri, AccountInfo>(x => x.LoginInfo.Account,
                x => new Uri("http:" + AvatarCalc.GetAvatarURL(x)))
                .ToProperty(this, x => x.AvatarUrl);

            _installUpdate =
                ReactiveCommand.CreateAsyncTask(
                    this.WhenAnyValue(x => x.UpdateState, state => state == AppUpdateState.UpdateAvailable),
                    async x => await RequestAsync(new OpenWebLink(ViewType.Update)).ConfigureAwait(false))
                    .DefaultSetup("InstallUpdate");
            _goAccount =
                ReactiveCommand.CreateAsyncTask(
                    async x => await RequestAsync(new OpenWebLink(ViewType.Profile)).ConfigureAwait(false))
                    .DefaultSetup("OpenProfile");
            _goPremium =
                ReactiveCommand.CreateAsyncTask(
                    async x =>
                        await
                            RequestAsync(
                                new OpenWebLink(_loginInfo.IsPremium ? ViewType.PremiumAccount : ViewType.GoPremium))
                                .ConfigureAwait(false))
                    .DefaultSetup("GoPremium");

            IViewModel previousMain = null;

            _switchQueue = ReactiveCommand.CreateAsyncTask(
                async x => {
                    if (previousMain == null) {
                        previousMain = _mainArea;
                        MainArea = await RequestAsync(new GetQueue()).ConfigureAwait(false);
                    } else {
                        MainArea = previousMain;
                        previousMain = null;
                    }
                });
            status.SwitchQueue = _switchQueue; // TODO..

            Listen<LoginChanged>()
                .Select(x => x.LoginInfo)
                .ObserveOnMainThread()
                .BindTo(this, x => x.LoginInfo);
            // We need to receive these right away..
            // toDO: Think about how to make this only on WhenActivated
            Listen<AppStateUpdated>()
                .Select(x => x.UpdateState)
                .ObserveOnMainThread()
                .BindTo(this, x => x.UpdateState);
        }
示例#4
0
 public ShellViewModel(INavigationViewModel navigation, ISearchViewModel search, IArtViewModel art, IStatusViewModel status, IActionTabsViewModel action_tabs)
 {
     Navigation = navigation;
     Search     = search;
     Art        = art;
     Status     = status;
     ActionTabs = action_tabs;
     Navigation.Events.Subscribe(ActionTabs);
 }
        public MiniMainWindowViewModel(IStatusViewModel status, TrayMainWindowMenu menu) {
            Menu = menu;
            _status = status;
            _taskbarToolTip = this.WhenAnyValue(x => x.DisplayName, x => x.Status.Status,
                    FormatTaskbarToolTip)
                .ToProperty(this, x => x.TaskbarToolTip);
            OpenPopup = ReactiveCommand.Create();
            ShowNotification = ReactiveCommand.CreateAsyncTask(async x => (ITrayNotificationViewModel) x);
            Deactivate = ReactiveCommand.Create().DefaultSetup("Deactivate");
            Deactivate.Subscribe(x => Close.Execute(null));

            // TODO: Make this a setting?
            /*            Listen<ApiUserActionStarted>()
                .ObserveOnMainThread()
                .InvokeCommand(OpenPopup);*/
            this.Listen<ClientInfoUpdated>()
                .Where(x => x.Info.UpdateState == AppUpdateState.Updating).ObserveOnMainThread()
                .InvokeCommand(OpenPopup);
            this.Listen<ShowTrayNotification>()
                .Select(x => new TrayNotificationViewModel(x.Subject, x.Text, x.CloseIn, x.Actions))
                .ObserveOnMainThread()
                .InvokeCommand(ShowNotification);
        }
 public string FormatTaskbarToolTip(string s, IStatusViewModel statusViewModel) {
     var baseText = s + " v" + Consts.ProductVersion;
     var statusModel = statusViewModel.Status;
     return statusModel == null
         ? baseText
         : baseText + "\n" +
           (statusModel.Acting ? statusModel.ToText() : statusModel.Text);
 }
        public PlayShellViewModel(IPlayStartupManager startupManager, IDialogManager dialogManager,
                                  IProcessManager processManager,
                                  IEventAggregator eventBus, ISystemInfo systemInfo,
                                  Func <NotificationsCenterViewModel> notificationsCenter, IStatusViewModel statusViewModel,
                                  SettingsViewModel settings, HomeViewModel home,
                                  Lazy <IContentManager> contentManager,
                                  Lazy <ContentViewModel> contentLazy,
                                  IUpdateManager updateManager, IViewModelFactory factory,
                                  ISoftwareUpdate softwareUpdate, ConnectViewModel connect, LocalMachineInfo machineInfo,
                                  UserSettings userSettings, IMediator mediator, IRestarter restarter)
        {
            _contentLazy = contentLazy;
            _restarter   = restarter;
            using (this.Bench()) {
                _startupManager = startupManager;
                _dialogManager  = dialogManager;
                _processManager = processManager;
                _eventBus       = eventBus;
                _systemInfo     = systemInfo;
                _contentManager = contentManager;
                UpdateManager   = updateManager;
                SoftwareUpdate  = softwareUpdate;
                UserSettings    = userSettings;
                _mediator       = mediator;
                _machineInfo    = machineInfo;

                Router = new RoutingState();

                Factory      = factory;
                Connect      = connect;
                Home         = home;
                Settings     = settings;
                StatusFlyout = statusViewModel;

                NotificationsCenter = notificationsCenter();
                // TODO: Normally we would do this only on a user action, like when we would open the menu. It would require the Shell button to be separate from the menu though.
                ProfilesMenu = _mediator.Send(new GetProfilesMenuViewModelQuery());

                DisplayName = GetTitle();

                DidDetectAVRun      = _systemInfo.DidDetectAVRun;
                SecurityStatus      = _startupManager.GetSecurityWarning();
                TrayIconContextMenu = new TrayIconContextMenu(this);
                RecentJumpList      = new RecentJumpList();
                OptionsMenu         = new OptionsMenuViewModel(this);
                ScreenHistory       = new ReactiveList <object>();

                Activator = new ViewModelActivator();

                Application.Current.Exit += (sender, args) => UpdateManager.Terminate();

                Overlay = new OverlayConductor();

                this.SetCommand(x => x.TrayIconDoubleclicked).Subscribe(x => SwitchWindowState());

                this.SetCommand(x => x.Exit).Subscribe(x => {
                    if (!IsBusy())
                    {
                        _mediator.Send(new Shutdown());
                    }
                });

                this.SetCommand(x => x.GoPremiumCommand)
                .Subscribe(x => BrowserHelper.TryOpenUrlIntegrated(new Uri(CommonUrls.MainUrl, "/gopremium")));
                this.SetCommand(x => x.GoPremiumSettingsCommand)
                .Subscribe(
                    x => BrowserHelper.TryOpenUrlIntegrated(new Uri(CommonUrls.ConnectUrl, "settings/premium")));
                this.SetCommand(x => x.SwitchHome).Subscribe(x => SwitchHomeButton());
                this.SetCommand(x => x.GoLatestNewsCommand).Subscribe(x => GoLatestNews());
                this.SetCommand(x => x.SecuritySuiteCommand).Subscribe(x => BrowserHelper.TryOpenUrlIntegrated(
                                                                           "https://community.withsix.com"));

                this.SetCommand(x => x.GoBackCommand, this.WhenAnyValue(x => x.CanGoBack))
                .Subscribe(GoBack);
                this.SetCommand(x => x.GoForwardCommand, this.WhenAnyValue(x => x.CanGoForward))
                .Subscribe(GoForward);
            }
        }