protected ModuleViewModelBase() { this.SetCommand(x => x.SwitchEnabled).Subscribe(() => { if (IsActive) { TryClose(true); } else { Open(); } }); this.SetCommand(x => x.Show).Subscribe(Open); ProgressState = new ProgressState { IsIndeterminate = true, Active = true }; Overlay = new OverlayConductor(); Overlay.ConductWith(this); }
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); } }