public CollectionPlaylistsViewModel(IUnityContainer container) : base(container) { // Dependency injection this.fileService = container.Resolve <IFileService>(); this.playlistService = container.Resolve <IPlaylistService>(); this.playbackService = container.Resolve <IPlaybackService>(); this.eventAggregator = container.Resolve <IEventAggregator>(); this.dialogService = container.Resolve <IDialogService>(); // Commands this.LoadedCommand = new DelegateCommand(async() => await this.LoadedCommandAsync()); this.NewPlaylistCommand = new DelegateCommand(async() => await this.ConfirmAddPlaylistAsync()); this.OpenPlaylistCommand = new DelegateCommand(async() => await this.OpenPlaylistAsync()); this.RenameSelectedPlaylistCommand = new DelegateCommand(async() => await this.RenameSelectedPlaylistAsync()); this.RemoveSelectedTracksCommand = new DelegateCommand(async() => await this.DeleteTracksFromPlaylistsAsync()); this.AddPlaylistToNowPlayingCommand = new DelegateCommand(async() => await this.AddPlaylistToNowPlayingAsync()); this.DeletePlaylistByNameCommand = new DelegateCommand <string>(async(playlistName) => await this.ConfirmDeletePlaylistAsync(playlistName)); this.ShuffleSelectedPlaylistCommand = new DelegateCommand(async() => await this.ShuffleSelectedPlaylistAsync()); this.DeleteSelectedPlaylistCommand = new DelegateCommand(async() => { if (this.IsPlaylistSelected) { await this.ConfirmDeletePlaylistAsync(this.SelectedPlaylistName); } }); // Events this.eventAggregator.GetEvent <SettingEnableRatingChanged>().Subscribe(enableRating => this.EnableRating = enableRating); this.eventAggregator.GetEvent <SettingEnableLoveChanged>().Subscribe(enableLove => this.EnableLove = enableLove); this.playlistService.TracksAdded += async(numberTracksAdded, playlistName) => await this.UpdateAddedTracksAsync(playlistName); this.playlistService.TracksDeleted += async(playlistName) => await this.UpdateDeletedTracksAsync(playlistName); this.playlistService.PlaylistAdded += (addedPlaylistName) => this.UpdateAddedPlaylist(addedPlaylistName); this.playlistService.PlaylistDeleted += (deletedPlaylistName) => this.UpdateDeletedPlaylist(deletedPlaylistName); this.playlistService.PlaylistRenamed += (oldPlaylistName, newPlaylistName) => this.UpdateRenamedPlaylist(oldPlaylistName, newPlaylistName); this.playlistService.PlaylistFolderChanged += async(_, __) => await this.FillListsAsync(); // Set width of the panels this.LeftPaneWidthPercent = SettingsClient.Get <int>("ColumnWidths", "PlaylistsLeftPaneWidthPercent"); }
public CollectionAlbumsViewModel(IUnityContainer container) : base(container) { // IndexingService this.IndexingService.RefreshArtwork += async(_, __) => await this.CollectionService.RefreshArtworkAsync(this.Albums); // Commands this.ToggleAlbumOrderCommand = new DelegateCommand(async() => await this.ToggleAlbumOrderAsync()); this.RemoveSelectedTracksCommand = new DelegateCommand(async() => await this.RemoveTracksFromCollectionAsync(this.SelectedTracks), () => !this.IsIndexing); this.RemoveSelectedTracksFromDiskCommand = new DelegateCommand(async() => await this.RemoveTracksFromDiskAsync(this.SelectedTracks), () => !this.IsIndexing); // Events this.EventAggregator.GetEvent <SettingEnableRatingChanged>().Subscribe(async(enableRating) => { this.EnableRating = enableRating; this.SetTrackOrder("AlbumsTrackOrder"); await this.GetTracksAsync(null, null, this.SelectedAlbums, this.TrackOrder); }); this.EventAggregator.GetEvent <SettingEnableLoveChanged>().Subscribe(async(enableLove) => { this.EnableLove = enableLove; this.SetTrackOrder("AlbumsTrackOrder"); await this.GetTracksAsync(null, null, this.SelectedAlbums, this.TrackOrder); }); // MetadataService this.MetadataService.MetadataChanged += MetadataChangedHandlerAsync; // Set the initial AlbumOrder this.AlbumOrder = (AlbumOrder)SettingsClient.Get <int>("Ordering", "AlbumsAlbumOrder"); // Set the initial TrackOrder this.SetTrackOrder("AlbumsTrackOrder"); // Subscribe to Events and Commands on creation this.Subscribe(); // Set width of the panels this.LeftPaneWidthPercent = SettingsClient.Get <int>("ColumnWidths", "AlbumsLeftPaneWidthPercent"); // Cover size this.SetCoversizeAsync((CoverSizeType)SettingsClient.Get <int>("CoverSizes", "AlbumsCoverSize")); }
private void Backup() { bool isBackupSuccess = false; // Choose a backup file string backupFile = string.Empty; bool isBackupFileChosen = this.SaveBackupFile(ref backupFile); if (!isBackupFileChosen) { return; } // Perform the backup to file isBackupSuccess = this.backupService.Backup(backupFile); // Update LastBackupDirectory setting if (isBackupSuccess) { SettingsClient.Set <string>("General", "LastBackupDirectory", Path.GetDirectoryName(backupFile)); } if (isBackupSuccess) { // Show notification if backup succeeded this.dialogService.ShowNotificationDialog( null, title: ResourceUtils.GetStringResource("Language_Success"), content: ResourceUtils.GetStringResource("Language_Backup_Was_Successful"), okText: ResourceUtils.GetStringResource("Language_Ok"), showViewLogs: false); } else { // Show error if backup failed this.dialogService.ShowNotificationDialog( null, title: ResourceUtils.GetStringResource("Language_Error"), content: ResourceUtils.GetStringResource("Language_Error_Backup_Error"), okText: ResourceUtils.GetStringResource("Language_Ok"), showViewLogs: true); } }
private void LoadSavedSelectedPage() { int savedSelectedPage = SettingsClient.Get <int>("FullPlayer", "SelectedPage"); switch (savedSelectedPage) { case (int)FullPlayerPage.Collection: this.NagivateToSelectedPage(FullPlayerPage.Collection); break; case (int)FullPlayerPage.Playlists: this.NagivateToSelectedPage(FullPlayerPage.Playlists); break; default: this.NagivateToSelectedPage(FullPlayerPage.Collection); break; } }
public async Task <FolderViewModel> GetSelectedFolderAsync() { IList <FolderViewModel> allFolders = await this.GetFoldersAsync(); string savedSelectedBrowseFolderPath = SettingsClient.Get <string>("Selections", "SelectedFolder"); if (allFolders.Count == 0) { return(null); } if (string.IsNullOrEmpty(savedSelectedBrowseFolderPath) || !allFolders.Select(x => x.SafePath).Contains(savedSelectedBrowseFolderPath.ToSafePath())) { return(allFolders.First()); } return(allFolders.Where(x => x.SafePath.Equals(savedSelectedBrowseFolderPath.ToSafePath())).FirstOrDefault()); }
private void LoadSavedSelectedPage() { int savedSelectedPage = SettingsClient.Get <int>("FullPlayer", "SelectedPage"); switch (savedSelectedPage) { case (int)FullPlayerPage.Collection: this.CollectionButton.IsChecked = true; break; case (int)FullPlayerPage.Playlists: this.PlaylistsButton.IsChecked = true; break; default: this.CollectionButton.IsChecked = true; break; } }
public SettingsStartupViewModel(IUpdateService updateService) { this.updateService = updateService; this.IsPortable = SettingsClient.Get <bool>("Configuration", "IsPortable"); // CheckBoxes this.GetCheckBoxesAsync(); // No automatic updates in the portable version if (!this.IsPortable) { this.checkBoxInstallUpdatesAutomaticallyChecked = SettingsClient.Get <bool>("Updates", "AutomaticDownload"); } else { this.checkBoxInstallUpdatesAutomaticallyChecked = false; } }
public void CheckIfTabletMode(bool isInitializing) { if (this.windowsIntegrationService.IsTabletModeEnabled) { // Always revert to full player when tablet mode is enabled. Maximizing will be done by Windows. this.SetPlayer(false, (MiniPlayerType)SettingsClient.Get <int>("General", "MiniPlayerType"), isInitializing); } else { bool isMiniPlayer = SettingsClient.Get <bool>("General", "IsMiniPlayer"); bool isMaximized = SettingsClient.Get <bool>("FullPlayer", "IsMaximized"); this.WindowStateChanged(this, new WindowStateChangedEventArgs() { WindowState = isMaximized & !isMiniPlayer ? WindowState.Maximized : WindowState.Normal }); this.SetPlayer(isMiniPlayer, (MiniPlayerType)SettingsClient.Get <int>("General", "MiniPlayerType"), isInitializing); } }
private void Application_Startup(object sender, StartupEventArgs e) { ApplicationContext.Initialize(); this.RootVisual = new UserControlContainer(); if (Application.Current.IsRunningOutOfBrowser) { Application.Current.CheckAndDownloadUpdateCompleted += (obj, args) => { if (args.UpdateAvailable) { UpdateAvailableWindow.Show(() => Application.Current.MainWindow.Close()); } else { var settingsUriString = "Settings.xml"; Uri source = Application.Current.Host.Source; string location; if (Debugger.IsAttached) { location = "http://www.indoorworx.com/IndoorWorx/";// "http://localhost:3415/"; } else { location = source.AbsoluteUri.Substring(0, source.AbsoluteUri.IndexOf("ClientBin", StringComparison.OrdinalIgnoreCase)); } settingsUriString = String.Concat(location, settingsUriString); Uri settingsUri = new Uri(settingsUriString, UriKind.Absolute); SettingsClient settingsService = new SettingsClient(settingsUri); settingsService.GetSettingsCompleted += this.SettingsService_GetSettingsCompleted; settingsService.GetSettingsAsync(); } }; Application.Current.CheckAndDownloadUpdateAsync(); } else { RootContainer.SwitchControl(new ApplicationInstallerView()); } }
private async Task IndexCollectionAsync() { if (this.IsIndexing) { return; } this.isIndexing = true; this.IndexingStarted(this, new EventArgs()); // Tracks // ------ bool isTracksChanged = await this.IndexTracksAsync(SettingsClient.Get <bool>("Indexing", "IgnoreRemovedFiles")) > 0 ? true : false; // Track statistics (for upgrade from 1.x to 2.x) // ---------------------------------------------- await this.MigrateTrackStatisticsIfExistsAsync(); // Artwork cleanup // --------------- bool isArtworkCleanedUp = await this.CleanupArtworkAsync(); // Refresh lists // ------------- if (isTracksChanged || isArtworkCleanedUp) { LogClient.Info("Sending event to refresh the lists because: isTracksChanged = {0}, isArtworkCleanedUp = {1}", isTracksChanged, isArtworkCleanedUp); this.RefreshLists(this, new EventArgs()); } // Finalize // -------- this.isIndexing = false; this.IndexingStopped(this, new EventArgs()); this.AddArtworkInBackgroundAsync(); if (SettingsClient.Get <bool>("Indexing", "RefreshCollectionAutomatically")) { await this.watcherManager.StartWatchingAsync(); } }
public CacheService() { string cacheFolderPath = Path.Combine(SettingsClient.ApplicationFolder(), ApplicationPaths.CacheFolder); this.coverArtCacheFolderPath = Path.Combine(SettingsClient.ApplicationFolder(), ApplicationPaths.CacheFolder, ApplicationPaths.CoverArtCacheFolder); this.temporaryCacheFolderPath = Path.Combine(SettingsClient.ApplicationFolder(), ApplicationPaths.CacheFolder, ApplicationPaths.TemporaryCacheFolder); // If it doesn't exist, create the cache folder. if (!Directory.Exists(cacheFolderPath)) { Directory.CreateDirectory(cacheFolderPath); } // If it doesn't exist, create the coverArt cache folder. if (!Directory.Exists(this.coverArtCacheFolderPath)) { Directory.CreateDirectory(this.coverArtCacheFolderPath); } // If it exists, delete the temporary cache folder and create it again (this makes sure it is cleaned from time to time) if (Directory.Exists(this.temporaryCacheFolderPath)) { try { Directory.Delete(this.temporaryCacheFolderPath, true); } catch (Exception ex) { LogClient.Error("Could not delete the temporary cache folder. Exception: {0}", ex.Message); } } // If the temporary cache folder doesn't exist, create it. if (!Directory.Exists(this.temporaryCacheFolderPath)) { Directory.CreateDirectory(this.temporaryCacheFolderPath); } temporaryCacheCleanupTimer = new Timer(); temporaryCacheCleanupTimer.Interval = temporaryCacheCleanupTimeout; temporaryCacheCleanupTimer.Elapsed += TemporaryCacheCleanupTimer_Elapsed; temporaryCacheCleanupTimer.Start(); }
public NowPlayingPlaybackControlsViewModel(IContainerProvider container, IEventAggregator eventAggregator) : base(container) { this.eventAggregator = eventAggregator; this.PlaybackService.PlaybackSuccess += (_, __) => RaisePropertyChanged(nameof(this.HasPlaybackQueue)); this.PlaybackService.PlaybackStopped += (_, __) => this.Reset(); this.LoadedCommand = new DelegateCommand(() => { if (SettingsClient.Get <bool>("Startup", "ShowLastSelectedPage")) { this.SelectedNowPlayingSubPage = (NowPlayingSubPage)SettingsClient.Get <int>("FullPlayer", "SelectedNowPlayingSubPage"); } else { this.SelectedNowPlayingSubPage = NowPlayingSubPage.ShowCase; } }); }
public CollectionAlbumsViewModel(IContainerProvider container) : base(container) { // Dependency injection this.indexingService = container.Resolve <IIndexingService>(); this.collectionService = container.Resolve <ICollectionService>(); this.eventAggregator = container.Resolve <IEventAggregator>(); // Settings SettingsClient.SettingChanged += async(_, e) => { if (SettingsClient.IsSettingChanged(e, "Behaviour", "EnableRating")) { this.EnableRating = (bool)e.SettingValue; this.SetTrackOrder("AlbumsTrackOrder"); await this.GetTracksAsync(null, null, this.SelectedAlbums, this.TrackOrder); } if (SettingsClient.IsSettingChanged(e, "Behaviour", "EnableLove")) { this.EnableLove = (bool)e.SettingValue; this.SetTrackOrder("AlbumsTrackOrder"); await this.GetTracksAsync(null, null, this.SelectedAlbums, this.TrackOrder); } }; // Commands this.ToggleAlbumOrderCommand = new DelegateCommand(async() => await this.ToggleAlbumOrderAsync()); this.ToggleTrackOrderCommand = new DelegateCommand(async() => await this.ToggleTrackOrderAsync()); this.RemoveSelectedTracksCommand = new DelegateCommand(async() => await this.RemoveTracksFromCollectionAsync(this.SelectedTracks), () => !this.IsIndexing); this.RemoveSelectedTracksFromDiskCommand = new DelegateCommand(async() => await this.RemoveTracksFromDiskAsync(this.SelectedTracks), () => !this.IsIndexing); // Set the initial AlbumOrder this.AlbumOrder = (AlbumOrder)SettingsClient.Get <int>("Ordering", "AlbumsAlbumOrder"); // Set the initial TrackOrder this.SetTrackOrder("AlbumsTrackOrder"); // Set width of the panels this.LeftPaneWidthPercent = SettingsClient.Get <int>("ColumnWidths", "AlbumsLeftPaneWidthPercent"); // Cover size this.SetCoversizeAsync((CoverSizeType)SettingsClient.Get <int>("CoverSizes", "AlbumsCoverSize")); }
public ConvertService() { this.musicFolder = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), ProductInformation.ApplicationDisplayName); this.workingFolder = Path.Combine(SettingsClient.ApplicationFolder(), "Working"); // Create the music folder. If this fails, we cannot continue (let it crash). this.CreateMusicFolder(); // Try to delete the working folder. If it fails: no problem. try { if (Directory.Exists(this.workingFolder)) { Directory.Delete(this.workingFolder, true); } } catch (Exception ex) { LogClient.Error("An error occurred while deleting the working folder {0}. Exception: {1}", this.workingFolder, ex.Message); } // Try to create the working folder. If this fails, we cannot continue (let it crash). try { if (!Directory.Exists(this.workingFolder)) { Directory.CreateDirectory(this.workingFolder); } } catch (Exception ex) { LogClient.Error("An error occurred while creating the music folder {0}. Exception: {1}", this.workingFolder, ex.Message); throw; } this.convertState = ConvertState.Idle; convertStateResetTimer.Elapsed += ConvertStateResetTimer_Elapsed; }
public SpectrumAnalyzerControlViewModel(IPlaybackService playbackService, IAppearanceService appearanceService, IEventAggregator eventAggregator) { this.playbackService = playbackService; this.eventAggregator = eventAggregator; this.appearanceService = appearanceService; this.playbackService.SpectrumVisibilityChanged += isSpectrumVisible => this.ShowSpectrumAnalyzer = isSpectrumVisible; this.appearanceService.ColorSchemeChanged += (_, __) => Application.Current.Dispatcher.Invoke(() => this.SetSpectrumStyle((SpectrumStyle)SettingsClient.Get <int>("Playback", "SpectrumStyle"))); this.playbackService.PlaybackFailed += (_, __) => this.IsPlaying = false; this.playbackService.PlaybackStopped += (_, __) => this.IsPlaying = false; this.playbackService.PlaybackPaused += (_, __) => this.IsPlaying = false; this.playbackService.PlaybackResumed += (_, __) => this.IsPlaying = true; this.playbackService.PlaybackSuccess += (_, __) => this.IsPlaying = true; SettingsClient.SettingChanged += (_, e) => { if (SettingsClient.IsSettingChanged(e, "Playback", "SpectrumStyle")) { this.SetSpectrumStyle((SpectrumStyle)e.SettingValue); } }; // Spectrum analyzer performance is only acceptable with Windows Media Foundation this.ShowSpectrumAnalyzer = this.playbackService.SupportsWindowsMediaFoundation && SettingsClient.Get <bool>("Playback", "ShowSpectrumAnalyzer"); // Initial value if (!this.playbackService.IsStopped & this.playbackService.IsPlaying) { this.IsPlaying = true; } else { this.IsPlaying = false; } // Default spectrum this.SetSpectrumStyle((SpectrumStyle)SettingsClient.Get <int>("Playback", "SpectrumStyle")); }
public CollectionFoldersSettingsViewModel(IIndexingService indexingService, IDialogService dialogService, ICollectionService collectionservice, IFoldersService foldersService) { this.indexingService = indexingService; this.dialogService = dialogService; this.collectionservice = collectionservice; this.foldersService = foldersService; this.AddFolderCommand = new DelegateCommand <string>((_) => { this.AddFolder(); }); this.RemoveFolderCommand = new DelegateCommand <long?>(folderId => { if (this.dialogService.ShowConfirmation(0xe11b, 16, ResourceUtils.GetString("Language_Remove"), ResourceUtils.GetString("Language_Confirm_Remove_Folder"), ResourceUtils.GetString("Language_Yes"), ResourceUtils.GetString("Language_No"))) { this.RemoveFolder(folderId.Value); } }); this.ShowInCollectionChangedCommand = new DelegateCommand <long?>(folderId => { this.ShowAllFoldersInCollection = false; lock (this.Folders) { this.foldersService.MarkFolderAsync(this.Folders.Where((f) => f.Folder.FolderID == folderId).FirstOrDefault()); } }); this.ShowAllFoldersInCollection = SettingsClient.Get <bool>("Indexing", "ShowAllFoldersInCollection"); // Makes sure IsIndexng is set if this ViewModel is created after the indexer has started indexing if (this.indexingService.IsIndexing) { this.IsIndexing = true; } // These events handle changes of indexer status after the ViewModel is created this.indexingService.IndexingStarted += (_, __) => this.IsIndexing = true; this.indexingService.IndexingStopped += (_, __) => this.IsIndexing = false; this.GetFoldersAsync(); }
private void SelectMenuItem() { if (SettingsClient.Get <bool>("Startup", "ShowLastSelectedPage")) { SelectedPage page = (SelectedPage)SettingsClient.Get <int>("FullPlayer", "SelectedPage"); switch (page) { case SelectedPage.Artists: this.IsArtistsSelected = true; break; case SelectedPage.Genres: this.IsGenresSelected = true; break; case SelectedPage.Albums: this.IsAlbumsSelected = true; break; case SelectedPage.Tracks: this.IsTracksSelected = true; break; case SelectedPage.Playlists: this.IsPlaylistsSelected = true; break; case SelectedPage.Recent: this.IsCloudSelected = true; break; default: this.IsArtistsSelected = true; break; } } else { this.IsArtistsSelected = true; } }
public PlaylistsViewModelBase(IContainerProvider container, IDialogService dialogService, IPlaybackService playbackService, IPlaylistServiceBase playlistServiceBase) : base(container) { this.dialogService = dialogService; this.playlistServiceBase = playlistServiceBase; this.playbackService = playbackService; // Events this.playlistServiceBase.PlaylistFolderChanged += PlaylistServiceBase_PlaylistFolderChanged;; this.playlistServiceBase.PlaylistAdded += PlaylistServiceBase_PlaylistAdded; this.playlistServiceBase.PlaylistDeleted += PlaylistServiceBase_PlaylistDeleted; this.playlistServiceBase.PlaylistRenamed += PlaylistServiceBase_PlaylistRenamed; // Commands this.RenameSelectedPlaylistCommand = new DelegateCommand(async() => await this.RenameSelectedPlaylistAsync()); this.DeletePlaylistCommand = new DelegateCommand <PlaylistViewModel>(async(playlist) => await this.ConfirmDeletePlaylistAsync(playlist)); this.ImportPlaylistsCommand = new DelegateCommand(async() => await this.ImportPlaylistsAsync()); this.AddPlaylistToNowPlayingCommand = new DelegateCommand(async() => await this.AddPlaylistToNowPlayingAsync()); this.ShuffleSelectedPlaylistCommand = new DelegateCommand(async() => await this.ShuffleSelectedPlaylistAsync()); this.DeleteSelectedPlaylistCommand = new DelegateCommand(async() => { if (this.IsPlaylistSelected) { await this.ConfirmDeletePlaylistAsync(this.SelectedPlaylist); } }); // Settings changed SettingsClient.SettingChanged += (_, e) => { if (SettingsClient.IsSettingChanged(e, "Behaviour", "EnableRating")) { this.EnableRating = (bool)e.SettingValue; } if (SettingsClient.IsSettingChanged(e, "Behaviour", "EnableLove")) { this.EnableLove = (bool)e.SettingValue; } }; }
public LastFmScrobblingService(IPlaybackService playbackService) { this.playbackService = playbackService; this.playbackService.PlaybackSuccess += PlaybackService_PlaybackSuccess; this.playbackService.PlaybackProgressChanged += PlaybackService_PlaybackProgressChanged; this.username = SettingsClient.Get <string>("Lastfm", "Username"); this.password = SettingsClient.Get <string>("Lastfm", "Password"); this.sessionKey = SettingsClient.Get <string>("Lastfm", "Key"); if (!string.IsNullOrEmpty(this.username) && !string.IsNullOrEmpty(this.password) && !string.IsNullOrEmpty(this.sessionKey)) { this.signInState = SignInState.SignedIn; } else { this.signInState = SignInState.SignedOut; } }
private void GetColorSchemes() { this.ColorSchemes.Clear(); foreach (ColorScheme cs in this.appearanceService.GetColorSchemes()) { this.ColorSchemes.Add(cs); } string savedColorSchemeName = SettingsClient.Get <string>("Appearance", "ColorScheme"); if (!string.IsNullOrEmpty(savedColorSchemeName)) { this.SelectedColorScheme = this.appearanceService.GetColorScheme(savedColorSchemeName); } else { this.SelectedColorScheme = this.appearanceService.GetColorSchemes()[0]; } }
public SpectrumAnalyzerControl() { InitializeComponent(); this.playbackService = ServiceLocator.Current.GetInstance <IPlaybackService>(); this.shellService = ServiceLocator.Current.GetInstance <IShellService>(); this.playbackService.PlaybackSuccess += (_, __) => this.TryRegisterSpectrumPlayers(); this.shellService.WindowStateChanged += (_, __) => this.TryRegisterSpectrumPlayers(); SettingsClient.SettingChanged += (_, e) => { if (SettingsClient.IsSettingChanged(e, "Playback", "ShowSpectrumAnalyzer")) { this.TryRegisterSpectrumPlayers(); } }; this.TryRegisterSpectrumPlayers(); }
public void Initialize() { // Register Views and ViewModels with UnityContainer this.container.RegisterType <object, FullPlayer>(typeof(FullPlayer).FullName); this.container.RegisterType <object, FullPlayerViewModel>(typeof(FullPlayerViewModel).FullName); this.container.RegisterType <object, MainMenu>(typeof(MainMenu).FullName); this.container.RegisterType <object, MainMenuViewModel>(typeof(MainMenuViewModel).FullName); this.container.RegisterType <object, Status>(typeof(Status).FullName); this.container.RegisterType <object, StatusViewModel>(typeof(StatusViewModel).FullName); this.container.RegisterType <object, MainScreen>(typeof(MainScreen).FullName); this.container.RegisterType <object, MainScreenViewModel>(typeof(MainScreenViewModel).FullName); this.container.RegisterType <object, NowPlayingScreen>(typeof(NowPlayingScreen).FullName); this.container.RegisterType <object, NowPlayingScreenViewModel>(typeof(NowPlayingScreenViewModel).FullName); this.container.RegisterType <object, NowPlayingScreenShowcase>(typeof(NowPlayingScreenShowcase).FullName); this.container.RegisterType <object, NowPlayingScreenShowcaseViewModel>(typeof(NowPlayingScreenShowcaseViewModel).FullName); this.container.RegisterType <object, NowPlayingScreenPlaylist>(typeof(NowPlayingScreenPlaylist).FullName); this.container.RegisterType <object, NowPlayingScreenPlaylistViewModel>(typeof(NowPlayingScreenPlaylistViewModel).FullName); this.container.RegisterType <object, NowPlayingScreenArtistInformation>(typeof(NowPlayingScreenArtistInformation).FullName); this.container.RegisterType <object, NowPlayingScreenArtistInformationViewModel>(typeof(NowPlayingScreenArtistInformationViewModel).FullName); this.container.RegisterType <object, NowPlayingScreenLyrics>(typeof(NowPlayingScreenLyrics).FullName); this.container.RegisterType <object, NowPlayingScreenLyricsViewModel>(typeof(NowPlayingScreenLyricsViewModel).FullName); // Default View for dynamic Regions this.regionManager.RegisterViewWithRegion(RegionNames.FullPlayerSearchRegion, typeof(SearchControl)); if (SettingsClient.Get <bool>("Startup", "ShowLastSelectedPage")) { if (SettingsClient.Get <bool>("FullPlayer", "IsNowPlayingSelected")) { this.regionManager.RegisterViewWithRegion(RegionNames.ScreenTypeRegion, typeof(Views.NowPlayingScreen)); } else { this.regionManager.RegisterViewWithRegion(RegionNames.ScreenTypeRegion, typeof(Views.MainScreen)); } } else { this.regionManager.RegisterViewWithRegion(RegionNames.ScreenTypeRegion, typeof(Views.MainScreen)); } }
protected virtual void ToggleTrackOrder() { switch (this.TrackOrder) { case TrackOrder.Alphabetical: this.TrackOrder = TrackOrder.ReverseAlphabetical; break; case TrackOrder.ReverseAlphabetical: if (this.CanOrderByAlbum) { this.TrackOrder = TrackOrder.ByAlbum; } else { this.TrackOrder = TrackOrder.ByRating; } break; case TrackOrder.ByAlbum: if (SettingsClient.Get <bool>("Behaviour", "EnableRating")) { this.TrackOrder = TrackOrder.ByRating; } else { this.TrackOrder = TrackOrder.Alphabetical; } break; case TrackOrder.ByRating: this.TrackOrder = TrackOrder.Alphabetical; break; default: // Cannot happen, but just in case. this.TrackOrder = TrackOrder.ByAlbum; break; } }
private void ImportNote() { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = ProductInformation.ApplicationName + " file (*." + Defaults.ExportFileExtension + ")|*." + Defaults.ExportFileExtension + "|All files (*.*)|*.*"; string lastExportDirectory = SettingsClient.Get <string>("General", "LastExportDirectory"); if (!string.IsNullOrEmpty(lastExportDirectory)) { dlg.InitialDirectory = lastExportDirectory; } else { // If no LastRtfDirectory is set, default to the My Documents folder dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } if ((bool)dlg.ShowDialog()) { string importFile = dlg.FileName; try { if (!MiscUtils.IsValidExportFile(importFile)) { this.dialogService.ShowNotificationDialog(null, title: ResourceUtils.GetString("Language_Error"), content: ResourceUtils.GetString("Language_Invalid_File"), okText: ResourceUtils.GetString("Language_Ok"), showViewLogs: false); } else { // Try to import this.noteService.ImportFile(importFile); this.RefreshNotes(); } } catch (UnauthorizedAccessException) { this.dialogService.ShowNotificationDialog(null, title: ResourceUtils.GetString("Language_Error"), content: ResourceUtils.GetString("Language_Error_Unexpected_Error"), okText: ResourceUtils.GetString("Language_Ok"), showViewLogs: false); } } }
public SettingsCollectionFoldersViewModel(IIndexingService indexingService, IDialogService dialogService, ICollectionService collectionservice, IFolderRepository folderRepository) { this.indexingService = indexingService; this.dialogService = dialogService; this.collectionservice = collectionservice; this.folderRepository = folderRepository; this.AddFolderCommand = new DelegateCommand <string>((_) => { this.AddFolder(); }); this.RemoveFolderCommand = new DelegateCommand <string>(iPath => { if (this.dialogService.ShowConfirmation(0xe11b, 16, ResourceUtils.GetStringResource("Language_Remove"), ResourceUtils.GetStringResource("Language_Confirm_Remove_Folder"), ResourceUtils.GetStringResource("Language_Yes"), ResourceUtils.GetStringResource("Language_No"))) { this.RemoveFolder(iPath); } }); this.ShowInCollectionChangedCommand = new DelegateCommand <string>(path => { this.ShowAllFoldersInCollection = false; lock (this.Folders) { this.collectionservice.MarkFolderAsync(this.Folders.Select((f) => f.Folder).Where((f) => f.SafePath.Equals(path.ToSafePath())).FirstOrDefault()); } }); this.ShowAllFoldersInCollection = SettingsClient.Get <bool>("Indexing", "ShowAllFoldersInCollection"); // Makes sure Me.IsIndexng is set if this ViewModel is created after the Indexer has started indexing if (this.indexingService.IsIndexing) { this.IsIndexing = true; } // These events handle changes of Indexer status after the ViewModel is created this.indexingService.IndexingStarted += (_, __) => this.IsIndexing = true; this.indexingService.IndexingStopped += (_, __) => this.IsIndexing = false; this.GetFoldersAsync(); }
private async void Initialize() { // PlayerFactory this.playerFactory = new PlayerFactory(); // Settings this.SetPlaybackSettings(); // Audio device await this.SetAudioDeviceAsync(); // Detect audio device changes this.watcher.StartWatching(); this.watcher.AudioDevicesChanged += Watcher_AudioDevicesChanged; // Equalizer await this.SetIsEqualizerEnabledAsync(SettingsClient.Get <bool>("Equalizer", "IsEnabled")); // Queued tracks this.GetSavedQueuedTracks(); }
public void EnableUpdateCheck() { // Log that we start checking for updates CoreLogger.Current.Info("Update check: checking for updates. AlsoCheckForPreReleases = {0}", this.checkForPreReleases.ToString()); // We can check for updates this.canCheckForUpdates = true; // Set the timer interval based on update settings this.checkNewVersionTimer.Interval = TimeSpan.FromSeconds(Base.Constants.UpdateCheckIntervalSeconds).TotalMilliseconds; // Set flags based on update settings this.automaticDownload = SettingsClient.Get <bool>("Updates", "AutomaticDownload") & !SettingsClient.Get <bool>("Configuration", "IsPortable"); this.checkForPreReleases = SettingsClient.Get <bool>("Updates", "AlsoCheckForPreReleases"); // Actual update check. Don't await, just run async. (Stops the timer when starting and starts the timer again when ready) if (!this.checkingForUpdates) { this.CheckForUpdatesAsync(); } }
public SettingsAppearanceViewModel(IPlaybackService playbackService, IEventAggregator eventAggregator) { this.playbackService = playbackService; this.eventAggregator = eventAggregator; this.ColorSchemesDirectory = System.IO.Path.Combine(SettingsClient.ApplicationFolder(), ApplicationPaths.ColorSchemesFolder); this.OpenColorSchemesDirectoryCommand = new DelegateCommand <string>((colorSchemesDirectory) => { try { Actions.TryOpenPath(colorSchemesDirectory); } catch (Exception ex) { LogClient.Error("Could not open the ColorSchemes directory. Exception: {0}", ex.Message); } }); this.GetCheckBoxesAsync(); }
public void Reset() { LogClient.Info("Resetting update check"); this.DisablePeriodicCheck(); this.isDismissed = false; if (SettingsClient.Get <bool>("Updates", "CheckAtStartup")) { this.CheckNow(); } else if (SettingsClient.Get <bool>("Updates", "CheckPeriodically")) { this.EnablePeriodicCheck(); } else { this.NoNewVersionAvailable(this, new EventArgs()); } }
private async Task ToggleGenreOrderAsync() { switch (this.GenreOrder) { case GenreOrder.Alphabetical: this.GenreOrder = GenreOrder.ReverseAlphabetical; break; case GenreOrder.ReverseAlphabetical: this.GenreOrder = GenreOrder.Alphabetical; break; default: // Cannot happen, but just in case. this.GenreOrder = GenreOrder.Alphabetical; break; } SettingsClient.Set <int>("Ordering", "GenresGenreOrder", (int)this.GenreOrder); await this.GetGenresCommonAsync(this.Genres.Select((g) => ((GenreViewModel)g).Genre).ToList(), this.GenreOrder); }
public void SetSettings() { SettingsClient sc=new SettingsClient(); Setting settings = sc.GetSetting(); txtCompanyName.Text = settings.CompanyName; txtCSN.Text = settings.RC; txtCNIS.Text = settings.NIS; txtCNF.Text = settings.NF; txtCPhone.Text = settings.Phone; txtCFax.Text = settings.Fax; txtTown.Text = settings.City; txtCompany.Text = settings.CompanyName; txtCAddress.Text = settings.Adresse; txtAI.Text = settings.AI; txtEmail.Text = settings.Email; }