예제 #1
0
        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;
        }
예제 #2
0
        /// <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();
            }
        }
예제 #3
0
        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();
        }
예제 #4
0
        private void OnHyperlinkRequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            NotificationBarViewModel viewModel = (NotificationBarViewModel)this.DataContext;

            if (viewModel.ActionCommand != null)
            {
                viewModel.ActionCommand.Execute(viewModel.ShellViewModel, sender as IInputElement);
            }
        }
예제 #5
0
        /// <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();
            }
        }
예제 #6
0
 private void SetViewRelatedHeaders()
 {
     HeadlineViewModel.ShowRefreshTime = SelectedViewModel is ShellViewModel;
     NotificationBarViewModel.RefreshDefaultNotification();
 }