private void SetArtistInformation()
        {
            this.SlideDirection = SlideDirection.RightToLeft;
            this.regionManager.RequestNavigate(RegionNames.NowPlayingContentRegion, typeof(NowPlayingScreenArtistInformation).FullName);
            SettingsClient.Set <int>("FullPlayer", "SelectedNowPlayingPage", (int)SelectedNowPlayingPage.ArtistInformation);

            isShowCaseVisible          = false;
            isPlaylistVisible          = false;
            isLyricsVisible            = false;
            isArtistInformationVisible = true;
        }
        public void GetPlayBackServiceShuffle()
        {
            // Important: set Shuffle directly, not the Shuffle Property,
            // because there is no Shuffle Property Setter!
            this.shuffle = this.playbackService.Shuffle;

            RaisePropertyChanged(nameof(this.Shuffle));

            // Save the Shuffle status in the Settings
            SettingsClient.Set <bool>("Playback", "Shuffle", this.shuffle);
        }
Exemple #3
0
        private void Window_Closing(object sender, CancelEventArgs e)
        {
            // Prevent the OOBE window from appearing the next time the application is started
            SettingsClient.Set <bool>("General", "ShowOobe", false);

            // Closing the OOBE window, must show the main window.
            Application.Current.MainWindow.Show();

            // We're closing the OOBE window, tell the IndexingService to start checking the collection.
            this.indexingService.RefreshCollectionImmediatelyAsync();
        }
Exemple #4
0
        private void MetroWindow_Closing(object sender, CancelEventArgs e)
        {
            // Prevent the Oobe window from appearing the next time the application is started
            SettingsClient.Set <bool>("General", "ShowOobe", false);

            // Closing the Oobe windows, must show the main window
            Application.Current.MainWindow.Show();

            // We're closing the OOBE screen, tell the IndexingService to start.
            this.indexingService.IndexCollectionAsync(SettingsClient.Get <bool>("Indexing", "IgnoreRemovedFiles"), false);
        }
Exemple #5
0
 private void SaveWindowSize()
 {
     if (this.allowSaveWindowGeometry)
     {
         if (!this.isMiniPlayer & !(this.WindowState == WindowState.Maximized))
         {
             SettingsClient.Set <int>("FullPlayer", "Width", Convert.ToInt32(this.ActualWidth));
             SettingsClient.Set <int>("FullPlayer", "Height", Convert.ToInt32(this.ActualHeight));
         }
     }
 }
Exemple #6
0
 public void SaveWindowSize(WindowState state, Size size)
 {
     if (this.canSaveWindowGeometry)
     {
         if (!this.isMiniPlayerActive & state != WindowState.Maximized)
         {
             SettingsClient.Set <int>("FullPlayer", "Width", Convert.ToInt32(size.Width));
             SettingsClient.Set <int>("FullPlayer", "Height", Convert.ToInt32(size.Height));
         }
     }
 }
        public void SetMute(bool mute)
        {
            this.mute = mute;

            if (this.player != null)
            {
                this.player.SetVolume(mute ? 0.0f : this.Volume);
            }

            SettingsClient.Set <bool>("Playback", "Mute", this.mute);
            this.PlaybackMuteChanged(this, new EventArgs());
        }
Exemple #8
0
        public void SaveWindowState(WindowState state)
        {
            this.WindowState = state;

            // Only save window state when not in tablet mode. Tablet mode maximizes the screen.
            // We don't want to save that, as we want to be able to restore to the original state when leaving tablet mode.
            if (this.canSaveWindowGeometry & !this.windowsIntegrationService.IsTabletModeEnabled)
            {
                SettingsClient.Set <bool>("FullPlayer", "IsMaximized", state == WindowState.Maximized ? true : false);
            }

            this.WindowStateChanged(this, new WindowStateChangedEventArgs(state));
        }
        public void GetPlayBackServiceLoop()
        {
            // Important: set Loop directly, not the Loop Property,
            // because there is no Loop Property Setter!
            this.loopMode = this.playbackService.LoopMode;

            RaisePropertyChanged(nameof(this.ShowLoopNone));
            RaisePropertyChanged(nameof(this.ShowLoopOne));
            RaisePropertyChanged(nameof(this.ShowLoopAll));

            // Save the Loop status in the Settings
            SettingsClient.Set <int>("Playback", "LoopMode", (int)this.loopMode);
        }
Exemple #10
0
        public static void SetVisibleSongsColumns(bool ratingVisible, bool loveVisible, bool lyricsVisible, bool artistVisible, bool albumVisible, bool genreVisible, bool lengthVisible, bool albumArtistVisible, bool trackNumberVisible, bool yearVisible, bool bitrateVisible)
        {
            List <string> visibleColumns = new List <string>();

            if (ratingVisible)
            {
                visibleColumns.Add("rating");
            }
            if (loveVisible)
            {
                visibleColumns.Add("love");
            }
            if (lyricsVisible)
            {
                visibleColumns.Add("lyrics");
            }
            if (artistVisible)
            {
                visibleColumns.Add("artist");
            }
            if (albumVisible)
            {
                visibleColumns.Add("album");
            }
            if (genreVisible)
            {
                visibleColumns.Add("genre");
            }
            if (lengthVisible)
            {
                visibleColumns.Add("length");
            }
            if (albumArtistVisible)
            {
                visibleColumns.Add("albumartist");
            }
            if (trackNumberVisible)
            {
                visibleColumns.Add("tracknumber");
            }
            if (yearVisible)
            {
                visibleColumns.Add("year");
            }
            if (bitrateVisible)
            {
                visibleColumns.Add("bitrate");
            }

            SettingsClient.Set <string>("TracksGrid", "VisibleColumns", string.Join(";", visibleColumns.ToArray()));
        }
Exemple #11
0
 private void SaveWindowState()
 {
     if (this.allowSaveWindowGeometry)
     {
         if (this.WindowState == WindowState.Maximized)
         {
             SettingsClient.Set <bool>("FullPlayer", "IsMaximized", true);
         }
         else
         {
             SettingsClient.Set <bool>("FullPlayer", "IsMaximized", false);
         }
     }
 }
        public TracksViewModelBase(IContainerProvider container) : base(container)
        {
            // Dependency injection
            this.container         = container;
            this.trackRepository   = container.Resolve <ITrackRepository>();
            this.dialogService     = container.Resolve <IDialogService>();
            this.searchService     = container.Resolve <ISearchService>();
            this.playbackService   = container.Resolve <IPlaybackService>();
            this.collectionService = container.Resolve <ICollectionService>();
            this.i18nService       = container.Resolve <II18nService>();
            this.eventAggregator   = container.Resolve <IEventAggregator>();
            this.providerService   = container.Resolve <IProviderService>();
            this.playlistService   = container.Resolve <IPlaylistService>();
            this.metadataService   = container.Resolve <IMetadataService>();

            // Events
            this.metadataService.MetadataChanged += MetadataChangedHandlerAsync;

            // Commands
            this.ToggleTrackOrderCommand             = new DelegateCommand(() => this.ToggleTrackOrder());
            this.AddTracksToPlaylistCommand          = new DelegateCommand <string>(async(playlistName) => await this.AddTracksToPlaylistAsync(playlistName, this.SelectedTracks));
            this.PlaySelectedCommand                 = new DelegateCommand(async() => await this.PlaySelectedAsync());
            this.PlayNextCommand                     = new DelegateCommand(async() => await this.PlayNextAsync());
            this.AddTracksToNowPlayingCommand        = new DelegateCommand(async() => await this.AddTracksToNowPlayingAsync());
            this.RemoveSelectedTracksFromDiskCommand = new DelegateCommand(async() => await this.RemoveTracksFromDiskAsync(this.SelectedTracks), () => !this.IsIndexing);

            this.UpdateShowTrackArtCommand = new DelegateCommand <bool?>((showTrackArt) =>
            {
                SettingsClient.Set <bool>("Appearance", "ShowTrackArtOnPlaylists", showTrackArt.Value, true);
            });

            // Settings changed
            SettingsClient.SettingChanged += (_, e) =>
            {
                if (SettingsClient.IsSettingChanged(e, "Behaviour", "ShowRemoveFromDisk"))
                {
                    RaisePropertyChanged(nameof(this.ShowRemoveFromDisk));
                }
            };

            // Events
            this.i18nService.LanguageChanged += (_, __) =>
            {
                RaisePropertyChanged(nameof(this.TotalDurationInformation));
                RaisePropertyChanged(nameof(this.TotalSizeInformation));
                this.RefreshLanguage();
            };

            this.playbackService.PlaybackCountersChanged += PlaybackService_PlaybackCountersChanged;
        }
Exemple #13
0
        public PlaylistViewModelBase(IContainerProvider container) : base(container)
        {
            // Dependency injection
            this.container       = container;
            this.playbackService = container.Resolve <IPlaybackService>();
            this.eventAggregator = container.Resolve <IEventAggregator>();
            this.searchService   = container.Resolve <ISearchService>();
            this.dialogService   = container.Resolve <IDialogService>();
            this.providerService = container.Resolve <IProviderService>();
            this.i18nService     = container.Resolve <II18nService>();

            // Commands
            this.PlaySelectedCommand          = new DelegateCommand(async() => await this.PlaySelectedAsync());
            this.PlayNextCommand              = new DelegateCommand(async() => await this.PlayNextAsync());
            this.AddTracksToNowPlayingCommand = new DelegateCommand(async() => await this.AddTracksToNowPlayingAsync());
            this.UpdateShowTrackArtCommand    = new DelegateCommand <bool?>((showTrackArt) =>
            {
                SettingsClient.Set <bool>("Appearance", "ShowTrackArtOnPlaylists", showTrackArt.Value, true);
            });

            // Settings
            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;
                }
            };

            // Events
            this.i18nService.LanguageChanged += (_, __) => this.RefreshLanguage();

            SettingsClient.SettingChanged += (_, e) =>
            {
                if (SettingsClient.IsSettingChanged(e, "Appearance", "ShowTrackArtOnPlaylists"))
                {
                    this.ShowTrackArt = (bool)e.SettingValue;
                    this.UpdateShowTrackArtAsync();
                }
            };

            // Settings
            this.ShowTrackArt = SettingsClient.Get <bool>("Appearance", "ShowTrackArtOnPlaylists");
        }
Exemple #14
0
 private void SaveWindowLocation()
 {
     if (this.canSaveWindowGeometry)
     {
         if (SettingsClient.Get <bool>("General", "IsMiniPlayer"))
         {
             SettingsClient.Set <int>("MiniPlayer", "Top", Convert.ToInt32(this.Top));
             SettingsClient.Set <int>("MiniPlayer", "Left", Convert.ToInt32(this.Left));
         }
         else if (!SettingsClient.Get <bool>("General", "IsMiniPlayer") & !(this.WindowState == WindowState.Maximized))
         {
             SettingsClient.Set <int>("FullPlayer", "Top", Convert.ToInt32(this.Top));
             SettingsClient.Set <int>("FullPlayer", "Left", Convert.ToInt32(this.Left));
         }
     }
 }
Exemple #15
0
 private void SaveWindowLocation()
 {
     if (this.allowSaveWindowGeometry)
     {
         if (this.isMiniPlayer)
         {
             SettingsClient.Set <int>("MiniPlayer", "Top", Convert.ToInt32(this.Top));
             SettingsClient.Set <int>("MiniPlayer", "Left", Convert.ToInt32(this.Left));
         }
         else if (!this.isMiniPlayer & !(this.WindowState == WindowState.Maximized))
         {
             SettingsClient.Set <int>("FullPlayer", "Top", Convert.ToInt32(this.Top));
             SettingsClient.Set <int>("FullPlayer", "Left", Convert.ToInt32(this.Left));
         }
     }
 }
Exemple #16
0
 public void SaveWindowLocation(double top, double left, WindowState state)
 {
     if (this.canSaveWindowGeometry)
     {
         if (this.isMiniPlayerActive)
         {
             SettingsClient.Set <int>("MiniPlayer", "Top", Convert.ToInt32(top));
             SettingsClient.Set <int>("MiniPlayer", "Left", Convert.ToInt32(left));
         }
         else if (state != WindowState.Maximized)
         {
             SettingsClient.Set <int>("FullPlayer", "Top", Convert.ToInt32(top));
             SettingsClient.Set <int>("FullPlayer", "Left", Convert.ToInt32(left));
         }
     }
 }
Exemple #17
0
        private async Task BackupAsync()
        {
            bool isBackupSuccess = false;

            // Choose a backup file
            string backupFile         = string.Empty;
            bool   isBackupFileChosen = this.SaveBackupFile(ref backupFile);

            if (!isBackupFileChosen)
            {
                return;
            }

            // Close all note windows
            await this.noteService.CloseAllNoteWindowsAsync(500);

            // 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 NagivateToSelectedPage(FullPlayerPage page)
        {
            this.SlideInFrom          = page <= this.previousSelectedPage ? -Constants.SlideDistance : Constants.SlideDistance;
            this.previousSelectedPage = page;

            switch (page)
            {
            case FullPlayerPage.Collection:
                this.regionManager.RequestNavigate(RegionNames.FullPlayerRegion, typeof(Views.FullPlayer.Collection.Collection).FullName);
                this.regionManager.RequestNavigate(RegionNames.FullPlayerMenuRegion, typeof(Views.FullPlayer.Collection.CollectionMenu).FullName);
                this.ShowBackButton = false;
                this.goBackPage     = FullPlayerPage.Collection;
                SettingsClient.Set <int>("FullPlayer", "SelectedPage", (int)FullPlayerPage.Collection);
                break;

            case FullPlayerPage.Playlists:
                this.regionManager.RequestNavigate(RegionNames.FullPlayerRegion, typeof(Views.FullPlayer.Playlists.Playlists).FullName);
                this.regionManager.RequestNavigate(RegionNames.FullPlayerMenuRegion, typeof(Views.FullPlayer.Playlists.PlaylistsMenu).FullName);
                this.ShowBackButton = false;
                this.goBackPage     = FullPlayerPage.Playlists;
                SettingsClient.Set <int>("FullPlayer", "SelectedPage", (int)FullPlayerPage.Playlists);
                break;

            case FullPlayerPage.Settings:
                this.regionManager.RequestNavigate(RegionNames.FullPlayerRegion, typeof(Views.FullPlayer.Settings.Settings).FullName);
                this.regionManager.RequestNavigate(RegionNames.FullPlayerMenuRegion, typeof(Views.FullPlayer.Settings.SettingsMenu).FullName);
                this.ShowBackButton = true;
                break;

            case FullPlayerPage.Information:
                this.regionManager.RequestNavigate(RegionNames.FullPlayerRegion, typeof(Views.FullPlayer.Information.Information).FullName);
                this.regionManager.RequestNavigate(RegionNames.FullPlayerMenuRegion, typeof(Views.FullPlayer.Information.InformationMenu).FullName);
                this.ShowBackButton = true;
                break;

            default:
                break;
            }

            if (page != FullPlayerPage.Settings)
            {
                this.indexingService.RefreshCollectionIfFoldersChangedAsync();
            }
        }
Exemple #19
0
        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);
        }
Exemple #20
0
        private async void Shell_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            LogClient.Info("### STOPPING {0}, version {1} ###", ProductInformation.ApplicationName, ProcessExecutable.AssemblyVersion().ToString());

            // Prevent saving the size when the window is minimized.
            // When minimized, the actual size is not detected correctly,
            // which causes a too small size to be saved.

            if (!(this.WindowState == WindowState.Minimized))
            {
                if (this.WindowState == WindowState.Maximized)
                {
                    SettingsClient.Set <bool>("General", "IsMaximized", true);
                }
                else
                {
                    SettingsClient.Set <bool>("General", "IsMaximized", false);

                    // TODO: make tis better. Workaround for bug "MainWindow opens with size 0 px"
                    if (this.ActualWidth > 50 & this.ActualHeight > 50)
                    {
                        SettingsClient.Set <int>("General", "Width", (int)this.ActualWidth);
                        SettingsClient.Set <int>("General", "Height", (int)this.ActualHeight);
                    }
                    else
                    {
                        SettingsClient.Set <int>("General", "Width", Defaults.DefaultMainWindowWidth);
                        SettingsClient.Set <int>("General", "Height", Defaults.DefaultMainWindowHeight);
                    }

                    SettingsClient.Set <int>("General", "Top", (int)this.Top);
                    SettingsClient.Set <int>("General", "Left", (int)this.Left);
                }

                // Save the settings immediately
                SettingsClient.Write();
            }

            await this.noteService.CloseAllNoteWindowsAsync();
        }
        private void ApplyManualPreset()
        {
            if (!this.canApplyManualPreset)
            {
                return;
            }

            EqualizerPreset manualPreset = this.Presets.Select((p) => p).Where((p) => p.Name == Defaults.ManualPresetName).FirstOrDefault();

            manualPreset.Load(this.Band0, this.Band1, this.Band2, this.Band3, this.Band4, this.Band5, this.Band6, this.Band7, this.Band8, this.Band9);

            SettingsClient.Set <string>("Equalizer", "ManualPreset", manualPreset.ToValueString());

            // Once a slider has moved, revert to the manual preset (also in the settings).
            if (this.SelectedPreset.Name != Defaults.ManualPresetName)
            {
                this.SelectedPreset = manualPreset;
                SettingsClient.Set <string>("Equalizer", "SelectedPreset", Defaults.ManualPresetName);
            }

            this.playbackService.ApplyPreset(manualPreset);
        }
        public MiniPlayerViewModelBase(IContainerProvider container) : base(container)
        {
            // Commands
            this.ChangePlayerTypeCommand = new DelegateCommand <string>(miniPlayerType => this.SetPlayerContextMenuCheckBoxes((MiniPlayerType)(int.Parse(miniPlayerType))));
            ApplicationCommands.ChangePlayerTypeCommand.RegisterCommand(this.ChangePlayerTypeCommand);

            this.ToggleMiniPlayerPositionLockedCommand = new DelegateCommand(() =>
            {
                IsMiniPlayerPositionLocked = !IsMiniPlayerPositionLocked;
                SettingsClient.Set <bool>("Behaviour", "MiniPlayerPositionLocked", IsMiniPlayerPositionLocked);
            });
            ApplicationCommands.ToggleMiniPlayerPositionLockedCommand.RegisterCommand(this.ToggleMiniPlayerPositionLockedCommand);

            this.ToggleMiniPlayerAlwaysOnTopCommand = new DelegateCommand(() =>
            {
                this.IsMiniPlayerAlwaysOnTop = !this.IsMiniPlayerAlwaysOnTop;
                SettingsClient.Set <bool>("Behaviour", "MiniPlayerOnTop", this.IsMiniPlayerAlwaysOnTop);
            });
            ApplicationCommands.ToggleMiniPlayerAlwaysOnTopCommand.RegisterCommand(this.ToggleMiniPlayerAlwaysOnTopCommand);

            //Initialize
            this.Initialize();
        }
        private void SetSpectrumStyle(SpectrumStyle style)
        {
            switch (style)
            {
            case SpectrumStyle.Flames:
                this.SpectrumStyleFlames();
                break;

            case SpectrumStyle.Lines:
                this.SpectrumStyleLines();
                break;

            case SpectrumStyle.Bars:
                this.SpectrumStyleBars();
                break;

            default:
                this.SpectrumStyleFlames();
                break;
            }

            SettingsClient.Set <int>("Playback", "SpectrumStyle", (int)style);
        }
Exemple #24
0
        protected async override Task SetCoversizeAsync(CoverSizeType iCoverSize)
        {
            await base.SetCoversizeAsync(iCoverSize);

            SettingsClient.Set <int>("CoverSizes", "AlbumsCoverSize", (int)iCoverSize);
        }
        private void SetSpectrumStyle(SpectrumStyle style)
        {
            switch (style)
            {
            case SpectrumStyle.Flames:
                this.SpectrumStyle       = SpectrumStyle.Flames;
                this.BlurRadius          = 20;
                this.SpectrumBarCount    = 65;
                this.SpectrumWidth       = 270;
                this.SpectrumBarWidth    = 4;
                this.SpectrumBarSpacing  = 0;
                this.SpectrumPanelHeight = 60;
                this.SpectrumOpacity     = 0.65;
                this.AnimationStyle      = SpectrumAnimationStyle.Gentle;
                //var accentColor = (Color)Application.Current.TryFindResource("RG_AccentColor");
                //var gradientColor = HSLColor.GetFromRgb(accentColor).MoveNext(40).ToRgb();
                //this.SpectrumBarBackground = new LinearGradientBrush(new GradientStopCollection()
                //{
                //    new GradientStop(accentColor, 0),
                //    new GradientStop(accentColor, 0.45),
                //    new GradientStop(gradientColor, 1),
                //}, new Point(0.5, 1), new Point(0.5, 0));
                this.SpectrumBarBackground = (Brush)Application.Current.TryFindResource("RG_AccentBrush");
                break;

            case SpectrumStyle.Lines:
                this.SpectrumStyle         = SpectrumStyle.Lines;
                this.BlurRadius            = 0;
                this.SpectrumBarCount      = 50;
                this.SpectrumWidth         = 162;
                this.SpectrumBarWidth      = 1;
                this.SpectrumBarSpacing    = 2;
                this.SpectrumPanelHeight   = 30;
                this.SpectrumOpacity       = 1.0;
                this.AnimationStyle        = SpectrumAnimationStyle.Nervous;
                this.SpectrumBarBackground = (Brush)Application.Current.TryFindResource("RG_AccentBrush");
                break;

            case SpectrumStyle.Bars:
                this.SpectrumStyle         = SpectrumStyle.Bars;
                this.BlurRadius            = 0;
                this.SpectrumBarCount      = 20;
                this.SpectrumWidth         = 162;
                this.SpectrumBarWidth      = 6;
                this.SpectrumBarSpacing    = 2;
                this.SpectrumPanelHeight   = 30;
                this.SpectrumOpacity       = 1.0;
                this.AnimationStyle        = SpectrumAnimationStyle.Nervous;
                this.SpectrumBarBackground = (Brush)Application.Current.TryFindResource("RG_AccentBrush");
                break;

            case SpectrumStyle.Stripes:
                this.SpectrumStyle         = SpectrumStyle.Stripes;
                this.BlurRadius            = 0;
                this.SpectrumBarCount      = 13;
                this.SpectrumWidth         = 162;
                this.SpectrumBarWidth      = 10;
                this.SpectrumBarSpacing    = 2;
                this.SpectrumPanelHeight   = 30;
                this.SpectrumOpacity       = 1.0;
                this.AnimationStyle        = SpectrumAnimationStyle.Nervous;
                this.SpectrumBarBackground = (Brush)Application.Current.TryFindResource("RG_AccentStripedBrush");
                break;

            default:
                // Shouldn't happen
                break;
            }

            SettingsClient.Set <int>("Playback", "SpectrumStyle", (int)style);
        }
Exemple #26
0
        private void InitializeCommands()
        {
            // TaskbarItemInfo
            // ---------------
            TaskbarItemInfoPlayCommand = new DelegateCommand(async() => await this.playbackService.PlayOrPauseAsync());
            Common.Prism.ApplicationCommands.TaskbarItemInfoPlayCommand.RegisterCommand(this.TaskbarItemInfoPlayCommand);

            // Window State
            // ------------
            this.MinimizeWindowCommand = new DelegateCommand(() => this.WindowState = WindowState.Minimized);
            Common.Prism.ApplicationCommands.MinimizeWindowCommand.RegisterCommand(this.MinimizeWindowCommand);

            this.RestoreWindowCommand = new DelegateCommand(() => this.SetPlayer(false, MiniPlayerType.CoverPlayer));
            Common.Prism.ApplicationCommands.RestoreWindowCommand.RegisterCommand(this.RestoreWindowCommand);

            this.MaximizeRestoreWindowCommand = new DelegateCommand(() =>
            {
                if (this.WindowState == WindowState.Maximized)
                {
                    this.WindowState = WindowState.Normal;
                }
                else
                {
                    this.WindowState = WindowState.Maximized;
                }
            });

            Common.Prism.ApplicationCommands.MaximizeRestoreWindowCommand.RegisterCommand(this.MaximizeRestoreWindowCommand);

            this.CloseWindowCommand = new DelegateCommand(() => this.Close());
            Common.Prism.ApplicationCommands.CloseWindowCommand.RegisterCommand(this.CloseWindowCommand);

            // Player type
            // -----------
            this.ChangePlayerTypeCommand = new DelegateCommand <string>((miniPlayerType) => this.SetPlayer(true, (MiniPlayerType)Convert.ToInt32(miniPlayerType)));
            Common.Prism.ApplicationCommands.ChangePlayerTypeCommand.RegisterCommand(this.ChangePlayerTypeCommand);

            this.TogglePlayerCommand = new DelegateCommand(() =>
            {
                // If tablet mode is enabled, we should not be able to toggle the player.
                if (!this.IsTabletModeEnabled())
                {
                    this.TogglePlayer();
                }
            });
            Common.Prism.ApplicationCommands.TogglePlayerCommand.RegisterCommand(this.TogglePlayerCommand);

            // Mini Player
            // -----------
            this.isMiniPlayerPositionLocked = SettingsClient.Get <bool>("Behaviour", "MiniPlayerPositionLocked");
            this.isMiniPlayerAlwaysOnTop    = SettingsClient.Get <bool>("Behaviour", "MiniPlayerOnTop");

            this.ToggleMiniPlayerPositionLockedCommand = new DelegateCommand(() =>
            {
                this.isMiniPlayerPositionLocked = !isMiniPlayerPositionLocked;
                this.SetWindowPositionLocked(isMiniPlayer);
            });

            Common.Prism.ApplicationCommands.ToggleMiniPlayerPositionLockedCommand.RegisterCommand(this.ToggleMiniPlayerPositionLockedCommand);

            this.ToggleMiniPlayerAlwaysOnTopCommand = new DelegateCommand(() =>
            {
                this.isMiniPlayerAlwaysOnTop = !this.isMiniPlayerAlwaysOnTop;
                this.SetWindowAlwaysOnTop(this.isMiniPlayer);
            });

            Common.Prism.ApplicationCommands.ToggleMiniPlayerAlwaysOnTopCommand.RegisterCommand(this.ToggleMiniPlayerAlwaysOnTopCommand);

            // Screens
            // -------
            this.NavigateToMainScreenCommand = new DelegateCommand(() =>
            {
                this.regionManager.RequestNavigate(RegionNames.ScreenTypeRegion, typeof(MainScreen).FullName);
                SettingsClient.Set <bool>("FullPlayer", "IsNowPlayingSelected", false);
                this.eventAggregator.GetEvent <NowPlayingIsSelectedChanged>().Publish(false);
            });

            Common.Prism.ApplicationCommands.NavigateToMainScreenCommand.RegisterCommand(this.NavigateToMainScreenCommand);

            this.NavigateToNowPlayingScreenCommand = new DelegateCommand(() =>
            {
                this.regionManager.RequestNavigate(RegionNames.ScreenTypeRegion, typeof(NowPlayingScreen).FullName);
                SettingsClient.Set <bool>("FullPlayer", "IsNowPlayingSelected", true);
                this.eventAggregator.GetEvent <NowPlayingIsSelectedChanged>().Publish(true);
            });

            Common.Prism.ApplicationCommands.NavigateToNowPlayingScreenCommand.RegisterCommand(this.NavigateToNowPlayingScreenCommand);

            // Application
            // -----------
            this.ShowMainWindowCommand = new DelegateCommand(() => TrayIconContextMenuAppName_Click(null, null));
            Common.Prism.ApplicationCommands.ShowMainWindowCommand.RegisterCommand(this.ShowMainWindowCommand);
        }
 public void OnNavigatedTo(NavigationContext navigationContext)
 {
     this.Subscribe();
     SettingsClient.Set <int>("FullPlayer", "SelectedPage", (int)SelectedPage.Artists);
 }
Exemple #28
0
        public ShellService(IRegionManager regionManager, IWindowsIntegrationService windowsIntegrationService, IEventAggregator eventAggregator,
                            string nowPlayingPage, string fullPlayerPage, string coverPlayerPage, string microplayerPage, string nanoPlayerPage)
        {
            this.regionManager             = regionManager;
            this.windowsIntegrationService = windowsIntegrationService;
            this.eventAggregator           = eventAggregator;
            this.nowPlayingPage            = nowPlayingPage;
            this.fullPlayerPage            = fullPlayerPage;
            this.coverPlayerPage           = coverPlayerPage;
            this.microplayerPage           = microplayerPage;
            this.nanoPlayerPage            = nanoPlayerPage;

            this.ShowNowPlayingCommand = new DelegateCommand(() =>
            {
                this.regionManager.RequestNavigate(RegionNames.PlayerTypeRegion, this.nowPlayingPage);
                SettingsClient.Set <bool>("FullPlayer", "IsNowPlayingSelected", true);
                this.eventAggregator.GetEvent <IsNowPlayingPageActiveChanged>().Publish(true);
            });

            ApplicationCommands.ShowNowPlayingCommand.RegisterCommand(this.ShowNowPlayingCommand);

            this.ShowFullPlayerCommmand = new DelegateCommand(() =>
            {
                this.regionManager.RequestNavigate(RegionNames.PlayerTypeRegion, this.fullPlayerPage);
                SettingsClient.Set <bool>("FullPlayer", "IsNowPlayingSelected", false);
                this.eventAggregator.GetEvent <IsNowPlayingPageActiveChanged>().Publish(false);
            });

            ApplicationCommands.ShowFullPlayerCommand.RegisterCommand(this.ShowFullPlayerCommmand);

            // Window state
            this.WindowState = SettingsClient.Get <bool>("FullPlayer", "IsMaximized") ? WindowState.Maximized : WindowState.Normal;

            // Player type
            this.ChangePlayerTypeCommand = new DelegateCommand <string>((miniPlayerType) =>
                                                                        this.SetPlayer(true, (MiniPlayerType)Convert.ToInt32(miniPlayerType)));
            ApplicationCommands.ChangePlayerTypeCommand.RegisterCommand(this.ChangePlayerTypeCommand);

            this.TogglePlayerCommand = new DelegateCommand(() =>
            {
                // If tablet mode is enabled, we should not be able to toggle the player.
                if (!this.windowsIntegrationService.IsTabletModeEnabled)
                {
                    this.TogglePlayer();
                }
            });

            ApplicationCommands.TogglePlayerCommand.RegisterCommand(this.TogglePlayerCommand);

            // Mini Player Playlist
            this.CoverPlayerPlaylistButtonCommand = new DelegateCommand <bool?>(isPlaylistButtonChecked =>
            {
                this.ToggleMiniPlayerPlaylist(MiniPlayerType.CoverPlayer, isPlaylistButtonChecked.Value);
            });

            ApplicationCommands.CoverPlayerPlaylistButtonCommand.RegisterCommand(this.CoverPlayerPlaylistButtonCommand);

            this.MicroPlayerPlaylistButtonCommand = new DelegateCommand <bool?>(isPlaylistButtonChecked =>
            {
                this.ToggleMiniPlayerPlaylist(MiniPlayerType.MicroPlayer, isPlaylistButtonChecked.Value);
            });

            ApplicationCommands.MicroPlayerPlaylistButtonCommand.RegisterCommand(this.MicroPlayerPlaylistButtonCommand);

            this.NanoPlayerPlaylistButtonCommand = new DelegateCommand <bool?>(isPlaylistButtonChecked =>
            {
                this.ToggleMiniPlayerPlaylist(MiniPlayerType.NanoPlayer, isPlaylistButtonChecked.Value);
            });

            ApplicationCommands.NanoPlayerPlaylistButtonCommand.RegisterCommand(this.NanoPlayerPlaylistButtonCommand);

            // Mini Player
            this.ToggleMiniPlayerPositionLockedCommand = new DelegateCommand(() =>
            {
                bool isMiniPlayerPositionLocked = SettingsClient.Get <bool>("Behaviour", "MiniPlayerPositionLocked");
                SettingsClient.Set <bool>("Behaviour", "MiniPlayerPositionLocked", !isMiniPlayerPositionLocked);
                this.SetWindowPositionLockedFromSettings();
            });

            ApplicationCommands.ToggleMiniPlayerPositionLockedCommand.RegisterCommand(this.ToggleMiniPlayerPositionLockedCommand);

            this.ToggleMiniPlayerAlwaysOnTopCommand = new DelegateCommand(() =>
            {
                bool topmost = SettingsClient.Get <bool>("Behaviour", "MiniPlayerOnTop");
                SettingsClient.Set <bool>("Behaviour", "MiniPlayerOnTop", !topmost);
                this.SetWindowTopmostFromSettings();
            });

            ApplicationCommands.ToggleMiniPlayerAlwaysOnTopCommand.RegisterCommand(this.ToggleMiniPlayerAlwaysOnTopCommand);
        }
Exemple #29
0
        protected async override Task SetCoversizeAsync(CoverSizeType coverSize)
        {
            await base.SetCoversizeAsync(coverSize);

            SettingsClient.Set <int>("CoverSizes", "GenresCoverSize", (int)coverSize);
        }
 public void OnNavigatedTo(NavigationContext navigationContext)
 {
     SettingsClient.Set <int>("FullPlayer", "SelectedPage", (int)SelectedPage.Recent);
 }