protected SmartViewViewModelBase(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, ITrackingManager trackingManager) : base(workbook, navigationService) { if (workbook == null) { throw new ArgumentNullException(nameof(workbook)); } if (navigationService == null) { throw new ArgumentNullException(nameof(navigationService)); } if (messageBoxService == null) { throw new ArgumentNullException(nameof(messageBoxService)); } if (trackingManager == null) { throw new ArgumentNullException(nameof(trackingManager)); } this.workbook = workbook; this.navigationService = navigationService; this.messageBoxService = messageBoxService; this.trackingManager = trackingManager; this.blocks = new ObservableCollection <SmartViewBlockViewModel>(); this.addBlockCommand = new RelayCommand(this.AddBlockExecute); var smartview = new SmartView(this.workbook, new Core.Shared.Model.Impl.SmartView() { Rules = "(Title Contains azerty)" }); this.liveCountFolderViewModel = new FolderItemViewModel(this.workbook, smartview); this.tracker = new SmartViewViewModelTracker(this); this.tracker.Changed += this.OnContentChanged; }
protected MainPageViewModelBase(IWorkbook workbook, ISynchronizationManager synchronizationManager, IStartupManager startupManager, IMessageBoxService messageBoxService, INotificationService notificationService, INavigationService navigationService, IPlatformService platformService, ITileManager tileManager, ITrackingManager trackingManager, ISpeechService speechService) : base(workbook, navigationService) { if (startupManager == null) { throw new ArgumentNullException(nameof(startupManager)); } if (synchronizationManager == null) { throw new ArgumentNullException(nameof(synchronizationManager)); } if (messageBoxService == null) { throw new ArgumentNullException(nameof(messageBoxService)); } if (platformService == null) { throw new ArgumentNullException(nameof(platformService)); } if (notificationService == null) { throw new ArgumentNullException(nameof(notificationService)); } if (tileManager == null) { throw new ArgumentNullException(nameof(tileManager)); } if (trackingManager == null) { throw new ArgumentNullException(nameof(trackingManager)); } if (speechService == null) { throw new ArgumentNullException(nameof(speechService)); } this.synchronizationManager = synchronizationManager; this.messageBoxService = messageBoxService; this.notificationService = notificationService; this.platformService = platformService; this.tileManager = tileManager; this.trackingManager = trackingManager; this.speechService = speechService; this.synchronizationManager.OperationStarted += this.OnSyncStarted; this.synchronizationManager.OperationProgressChanged += this.OnSyncProgressChanged; this.synchronizationManager.OperationCompleted += this.OnSyncOperationCompleted; this.synchronizationManager.OperationFailed += this.OnSyncOperationFailed; this.synchronizationManager.PropertyChanged += (s, e) => { if (e.PropertyName == "ActiveService") { this.RaisePropertyChanged("SyncPrioritySupport"); } }; this.Workbook.Settings.KeyChanged += this.OnSettingsChanged; this.Workbook.TaskAdded += this.OnTaskAddded; this.Workbook.FoldersReordered += this.OnFolderReordered; this.Workbook.ContextsReordered += this.OnContextReordered; this.addViewCommand = new RelayCommand(this.AddViewExecute); this.addSmartViewCommand = new RelayCommand(this.AddSmartViewExecute); this.addFolderCommand = new RelayCommand(this.AddFolderExecute); this.addContextCommand = new RelayCommand(this.AddContextExecute); this.addTaskCommand = new RelayCommand(this.AddTaskExecute); this.syncCommand = new RelayCommand(this.SyncExecute); this.openSettingsCommand = new RelayCommand(this.OpenSettingsExecute); this.openDebugCommand = new RelayCommand(this.OpenDebugExecute); this.clearSearchCommand = new RelayCommand(this.ClearSearchExecute); this.speechCommand = new RelayCommand(this.SpeechExecute); this.quickSpeechCommand = new RelayCommand(this.QuickSpeechExecute); this.printCommand = new RelayCommand(this.PrintExecute); this.shareCommand = new RelayCommand(this.ShareExecute); this.editCommand = new RelayCommand(this.EditExecute); this.deleteSelectionCommand = new RelayCommand(this.DeleteSelectionExecute); this.completeSelectionCommand = new RelayCommand(this.CompleteSelectionExecute); this.toggleTaskCompletionCommand = new RelayCommand <ITask>(this.ToggleTaskCompletionExecute); this.setPrioritySelectionCommand = new RelayCommand <string>(this.SetPrioritySelectionExecute); this.menuItems = new SortableObservableCollection <MenuItemViewModel>(); bool hasViews = this.Workbook.Views.Any(v => v.IsEnabled); bool hasSmartViews = this.Workbook.SmartViews.Any(); bool hasFolders = this.Workbook.Folders.Any(); bool hasContexts = this.Workbook.Contexts.Any(); // create search view this.viewSearch = new ViewSearch(this.Workbook); this.searchFolderItem = new FolderItemViewModel(this.Workbook, this.viewSearch); // load views foreach (var view in this.Workbook.Views.Where(f => f.IsEnabled)) { this.menuItems.Add(new FolderItemViewModel(workbook, view)); } // load smart views if (this.Workbook.SmartViews.Any()) { if (hasViews) { this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorSmartViewId)); } foreach (var smartview in this.Workbook.SmartViews) { this.menuItems.Add(new FolderItemViewModel(workbook, smartview)); } } // load folders if (this.Workbook.Folders.Count > 0) { if (hasViews || hasSmartViews) { this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorFolderId)); } foreach (var folder in this.Workbook.Folders) { this.menuItems.Add(new FolderItemViewModel(workbook, folder)); } } // load contexts if (this.Workbook.Contexts.Count > 0) { if (hasViews || hasSmartViews || hasFolders) { this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorContextId)); } foreach (var context in this.Workbook.Contexts) { this.menuItems.Add(new FolderItemViewModel(workbook, context)); } } // load tags if (this.Workbook.Tags.Any()) { if (hasViews || hasSmartViews || hasFolders || hasContexts) { this.menuItems.Add(new SeparatorItemViewModel(Constants.SeparatorTagId)); } foreach (var tag in this.Workbook.Tags) { this.menuItems.Add(new FolderItemViewModel(workbook, tag)); } } }