public Shell(IUnityContainer container, IRegionManager regionManager, IAppearanceService appearanceService, II18nService i18nService, IJumpListService jumpListService, IEventAggregator eventAggregator, INoteService noteService) { InitializeComponent(); // Dependency injection this.container = container; this.regionManager = regionManager; this.appearanceService = appearanceService; this.i18nService = i18nService; this.jumplistService = jumpListService; this.eventAggregator = eventAggregator; this.noteService = noteService; // Theming this.appearanceService.ApplyTheme(SettingsClient.Get <string>("Appearance", "Theme")); this.appearanceService.ApplyColorScheme(SettingsClient.Get <bool>("Appearance", "FollowWindowsColor"), SettingsClient.Get <string>("Appearance", "ColorScheme")); // I18n this.i18nService.ApplyLanguageAsync(SettingsClient.Get <string>("Appearance", "Language")); // Events this.eventAggregator.GetEvent <ShowMainWindowEvent>().Subscribe((x) => this.ActivateNow()); // Geometry this.SetGeometry(SettingsClient.Get <int>("General", "Top"), SettingsClient.Get <int>("General", "Left"), SettingsClient.Get <int>("General", "Width") > 50 ? SettingsClient.Get <int>("General", "Width") : Defaults.DefaultMainWindowWidth, SettingsClient.Get <int>("General", "Height") > 50 ? SettingsClient.Get <int>("General", "Height") : Defaults.DefaultMainWindowHeight, Defaults.DefaultMainWindowLeft, Defaults.DefaultMainWindowTop); // Main window state this.WindowState = SettingsClient.Get <bool>("General", "IsMaximized") ? WindowState.Maximized : WindowState.Normal; }
public RecentReposService( IJumpListService jumpListService, IGitInfoService gitInfoService) { this.jumpListService = jumpListService; this.gitInfoService = gitInfoService; }
public RecentModelsService( ISettingsService settingsService, IJumpListService jumpListService) { this.settingsService = settingsService; this.jumpListService = jumpListService; }
public ItemPageViewModel(IDataService dataService, Lazy <IGestureService> gestureService, INavigationService navigationService, IJumpListService jumpListService) { _navigationService = navigationService ?? throw new ArgumentNullException(nameof(navigationService)); _jumpListService = jumpListService ?? throw new ArgumentNullException(nameof(jumpListService)); _dataService = dataService ?? throw new ArgumentNullException(nameof(dataService)); _gestureService = gestureService.Value ?? throw new ArgumentNullException(nameof(gestureService)); }
private void InitializeServices() { this.i18nService = SimpleIoc.Default.GetInstance <II18nService>(); this.i18nService.ApplyLanguageAsync(SettingsClient.Get <string>("Configuration", "Language")); // Set default language this.convertService = SimpleIoc.Default.GetInstance <IConvertService>(); this.jumpListService = SimpleIoc.Default.GetInstance <IJumpListService>(); this.jumpListService.PopulateJumpListAsync(); }
public ShellViewModel(IPlaybackService playbackService, ITaskbarService taskbarService, IDialogService dialogService, IJumpListService jumpListService, IFileService fileService, IUpdateService updateService) { this.TaskbarService = taskbarService; dialogService.DialogVisibleChanged += isDialogVisible => { this.IsOverlayVisible = isDialogVisible; }; this.PlayPreviousCommand = new DelegateCommand(async() => await playbackService.PlayPreviousAsync()); this.PlayNextCommand = new DelegateCommand(async() => await playbackService.PlayNextAsync()); this.PlayOrPauseCommand = new DelegateCommand(async() => await playbackService.PlayOrPauseAsync()); this.LoadedCommand = new DelegateCommand(() => fileService.ProcessArguments(Environment.GetCommandLineArgs())); // Populate the JumpList jumpListService.PopulateJumpListAsync(); }
public NotesListsViewModel(IEventAggregator eventAggregator, INoteService noteService, IAppearanceService appearanceService, IJumpListService jumpListService, ISearchService searchService, IDialogService dialogService, I18nService i18nService, IBackupService backupService) { // Injection this.eventAggregator = eventAggregator; this.noteService = noteService; this.appearanceService = appearanceService; this.jumpListService = jumpListService; this.searchService = searchService; this.dialogService = dialogService; this.i18nService = i18nService; this.backupService = backupService; // PubSub events this.eventAggregator.GetEvent <TriggerLoadNoteAnimationEvent>().Subscribe((_) => { this.TriggerRefreshNotesAnimation = false; this.TriggerRefreshNotesAnimation = true; }); this.eventAggregator.GetEvent <SettingChangeStorageLocationFromMainChangedEvent>().Subscribe((_) => OnPropertyChanged(() => this.ShowChangeStorageLocationButton)); this.eventAggregator.GetEvent <RefreshJumpListEvent>().Subscribe((_) => this.jumpListService.RefreshJumpListAsync(this.noteService.GetRecentlyOpenedNotes(SettingsClient.Get <int>("Advanced", "NumberOfNotesInJumpList")), this.noteService.GetFlaggedNotes())); this.eventAggregator.GetEvent <OpenNoteEvent>().Subscribe(noteTitle => { if (!string.IsNullOrEmpty(noteTitle)) { this.SelectedNote = new NoteViewModel { Title = noteTitle } } ; this.OpenSelectedNote(); }); // Event handlers this.i18nService.LanguageChanged += LanguageChangedHandler; this.noteService.FlagUpdated += async(noteId, isFlagged) => { await this.UpdateNoteFlagAsync(noteId, isFlagged); }; this.noteService.StorageLocationChanged += (_, __) => this.RefreshNotebooksAndNotes(); this.backupService.BackupRestored += (_, __) => this.RefreshNotebooksAndNotes(); this.noteService.NotesChanged += (_, __) => Application.Current.Dispatcher.Invoke(() => { this.RefreshNotes(); }); this.searchService.Searching += (_, __) => TryRefreshNotesOnSearch(); this.NoteFilter = ""; // Must be set before RefreshNotes() // Initialize notebooks this.RefreshNotebooksAndNotes(); // Commands this.DeleteNoteCommand = new DelegateCommand <object>(async(obj) => await this.DeleteNoteAsync(obj)); this.ToggleNoteFlagCommand = new DelegateCommand <object>((obj) => this.ToggleNoteFlag(obj)); this.DeleteNotebookCommand = new DelegateCommand <object>((obj) => this.DeleteNotebook(obj)); this.EditNotebookCommand = new DelegateCommand <object>((obj) => this.EditNotebook(obj)); this.DeleteSelectedNotebookCommand = new DelegateCommand(() => this.DeleteSelectedNotebook()); this.EditSelectedNotebookCommand = new DelegateCommand(() => this.EditSelectedNotebook()); this.DeleteSelectedNoteCommand = new DelegateCommand(async() => await this.DeleteSelectedNoteAync()); this.ChangeStorageLocationCommand = new DelegateCommand(async() => await this.ChangeStorageLocationAsync(false)); this.ResetStorageLocationCommand = new DelegateCommand(async() => await this.ChangeStorageLocationAsync(true)); this.NewNotebookCommand = new DelegateCommand <string>((_) => this.NewNotebook()); Common.Prism.ApplicationCommands.NewNotebookCommand.RegisterCommand(this.NewNotebookCommand); this.NewNoteCommand = new DelegateCommand <object>(param => this.NewNote(param)); Common.Prism.ApplicationCommands.NewNoteCommand.RegisterCommand(this.NewNoteCommand); this.ImportNoteCommand = new DelegateCommand <string>((_) => this.ImportNote()); Common.Prism.ApplicationCommands.ImportNoteCommand.RegisterCommand(this.ImportNoteCommand); this.NavigateBetweenNotesCommand = new DelegateCommand <object>(NavigateBetweenNotes); Common.Prism.ApplicationCommands.NavigateBetweenNotesCommand.RegisterCommand(this.NavigateBetweenNotesCommand); // Process jumplist commands this.ProcessJumplistCommands(); }
public ShellViewModel(IUnityContainer container, IRegionManager regionManager, IDialogService dialogService, IPlaybackService playbackService, II18nService i18nService, ITaskbarService taskbarService, IJumpListService jumpListService, IFileService fileService, IScrobblingService scrobblingService) { this.container = container; this.regionManager = regionManager; this.dialogService = dialogService; this.playbackService = playbackService; this.i18nService = i18nService; this.taskbarService = taskbarService; this.jumpListService = jumpListService; this.fileService = fileService; this.scrobblingService = scrobblingService; // Not used here, but needs to be instantiated in the main window to ensure scrobbling is enabled. // Event handlers this.dialogService.DialogVisibleChanged += isDialogVisible => { this.IsOverlayVisible = isDialogVisible; }; this.ShowLogfileCommand = new DelegateCommand(() => { try { Actions.TryViewInExplorer(LogClient.Logfile()); } catch (Exception ex) { LogClient.Error("Could not view the log file {0} in explorer. Exception: {1}", LogClient.Logfile(), ex.Message); } }); this.OpenPathCommand = new DelegateCommand <string>((string path) => { try { Actions.TryOpenPath(path); } catch (Exception ex) { LogClient.Error("Could not open the path {0} in Explorer. Exception: {1}", path, ex.Message); } }); ApplicationCommands.OpenPathCommand.RegisterCommand(this.OpenPathCommand); this.OpenLinkCommand = new DelegateCommand <string>((string link) => { try { Actions.TryOpenLink(link); } catch (Exception ex) { LogClient.Error("Could not open the link {0} in Internet Explorer. Exception: {1}", link, ex.Message); } }); ApplicationCommands.OpenLinkCommand.RegisterCommand(this.OpenLinkCommand); this.PreviousCommand = new DelegateCommand(async() => await this.playbackService.PlayPreviousAsync()); this.NextCommand = new DelegateCommand(async() => await this.playbackService.PlayNextAsync()); this.LoadedCommand = new DelegateCommand(() => this.fileService.ProcessArguments(Environment.GetCommandLineArgs())); this.playbackService.PlaybackFailed += (sender, playbackFailedEventArgs) => { switch (playbackFailedEventArgs.FailureReason) { case PlaybackFailureReason.FileNotFound: this.dialogService.ShowNotification(0xe711, 16, ResourceUtils.GetStringResource("Language_Error"), ResourceUtils.GetStringResource("Language_Error_Cannot_Play_This_Song_File_Not_Found"), ResourceUtils.GetStringResource("Language_Ok"), false, string.Empty); break; default: this.dialogService.ShowNotification(0xe711, 16, ResourceUtils.GetStringResource("Language_Error"), ResourceUtils.GetStringResource("Language_Error_Cannot_Play_This_Song"), ResourceUtils.GetStringResource("Language_Ok"), true, ResourceUtils.GetStringResource("Language_Log_File")); break; } }; // Equalizer this.ShowEqualizerCommand = new DelegateCommand(() => { EqualizerControl view = this.container.Resolve <EqualizerControl>(); view.DataContext = this.container.Resolve <EqualizerControlViewModel>(); this.dialogService.ShowCustomDialog( new EqualizerIcon() { IsDialogIcon = true }, ResourceUtils.GetStringResource("Language_Equalizer"), view, 570, 0, false, true, true, false, ResourceUtils.GetStringResource("Language_Close"), string.Empty, null); }); ApplicationCommands.ShowEqualizerCommand.RegisterCommand(this.ShowEqualizerCommand); // Populate the JumpList this.jumpListService.PopulateJumpListAsync(); }