public ShellViewModel() { // TODO: set config directly m_migrationServiceManager = MigrationServiceManager.GetInstance(); // Set up runtime view model hosting environment m_runtimeManager = RuntimeManager.GetInstance(); IRefreshService refresh = (IRefreshService)m_runtimeManager.GetService(typeof(IRefreshService)); refresh.AutoRefresh += this.AutoRefresh; // Avoid race by driving through top level refresh instead of relying upon background thread. Refresh(); ConfigurationModel.Initialize(); m_headlineViewModel = new HeadlineControlViewModel(Properties.Resources.ShellHeaderString, this); m_notificationBarVM = new NotificationBarViewModel(this); PushViewModel(new HomeViewModel(this)); m_backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork); m_backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_backgroundWorker_RunWorkerCompleted); this.Controller.Created += this.OnCreated; this.Controller.Opened += this.OnOpened; this.Controller.Saved += this.OnSaved; }
/// <summary> /// Starts running the SessionGroup defined by the current DataModel. /// </summary> public virtual void Start() { if (DataModel != null && DataModel.Configuration != null && !m_backgroundWorker.IsBusy) { CanStart = false; CanStop = false; CanPause = false; SystemState = SystemState.MigrationProgress; Guid sessionGroupUniqueId = DataModel.Configuration.SessionGroupUniqueId; if (CurrentPipelineState == PipelineState.Paused) // is paused, resume TODO: State=Paused,Running,Stopped { m_currentPipelineState = PipelineState.Starting; NotificationBarViewModel.SetState(NotificationState.Info, DataModel.Configuration.SessionGroup.FriendlyName, Properties.Resources.StartingString); m_backgroundWorker.RunWorkerAsync(new BackgroundWorkerArgs(sessionGroupUniqueId, BackgroundWorkerTask.Resume)); } else { m_currentPipelineState = PipelineState.Starting; NotificationBarViewModel.SetState(NotificationState.Info, DataModel.Configuration.SessionGroup.FriendlyName, Properties.Resources.StartingString); m_backgroundWorker.RunWorkerAsync(new BackgroundWorkerArgs(sessionGroupUniqueId, BackgroundWorkerTask.Start)); } RaisePropertyChangedEvent("CurrentPipelineState"); RuntimeManager.EnableAutoRefresh(); } }
public ExplorerViewModel(Profile <FI, DI, FSI> profile) { _profile = profile; var notificationSources = from m in _profile.GetNotificationSources() select m.ToViewModel(); _notificationViewModel = new NotificationBarViewModel(notificationSources.ToArray()); _navigationViewModel = new NavigationRootViewModel <FI, DI, FSI>(_profile); _currentBrowserViewModel = new DirectoryViewerViewModel <FI, DI, FSI>(_profile, _viewSize); _breadcrumbViewModel = new BreadcrumbViewModel <FI, DI, FSI>(_profile, this); _searchViewModel = new SearchViewModel <FI, DI, FSI>(_profile); _navigationViewModel.DirectoryChanged += dirChangedHandler; if (CurrentEntryBrowserViewModel != null) { CurrentEntryBrowserViewModel.DirectoryChanged += dirChangedHandler; } _breadcrumbViewModel.DirectoryChanged += dirChangedHandler; _searchViewModel.DirectoryChanged += dirChangedHandler; ChangeCurrentBrowserViewModel(_profile.ConstructDirectoryModel(profile.RootDirectories[0])); setupCommands(); }
private void OnHyperlinkRequestNavigate(object sender, RequestNavigateEventArgs e) { NotificationBarViewModel viewModel = (NotificationBarViewModel)this.DataContext; if (viewModel.ActionCommand != null) { viewModel.ActionCommand.Execute(viewModel.ShellViewModel, sender as IInputElement); } }
/// <summary> /// Pauses the SessionGroup defined by the current DataModel. /// </summary> public virtual void Pause() { if (DataModel != null && DataModel.Configuration != null) { CanStart = false; CanStop = false; CanPause = false; m_currentPipelineState = PipelineState.Pausing; RaisePropertyChangedEvent("CurrentPipelineState"); NotificationBarViewModel.SetState(NotificationState.Info, DataModel.Configuration.SessionGroup.FriendlyName, Properties.Resources.PausingString); Guid sessionGroupUniqueId = DataModel.Configuration.SessionGroupUniqueId; m_backgroundWorker.RunWorkerAsync(new BackgroundWorkerArgs(sessionGroupUniqueId, BackgroundWorkerTask.Pause)); RuntimeManager.EnableAutoRefresh(); } }
private void SetViewRelatedHeaders() { HeadlineViewModel.ShowRefreshTime = SelectedViewModel is ShellViewModel; NotificationBarViewModel.RefreshDefaultNotification(); }