From b66de328cad846fdf5298920feb63bcb4c237c05 Mon Sep 17 00:00:00 2001 From: Royce551 Date: Sun, 5 Jun 2022 20:40:43 -0500 Subject: [PATCH 1/3] Various changes --- .../ViewModels/MainWindowViewModel.cs | 96 ++++++++++++------- .../Views/MainWindow.axaml | 18 +++- .../Views/MainWindow.axaml.cs | 8 +- .../FRESHMusicPlayer-WPF.csproj | 4 +- .../Forms/TagEditor/TagEditor.xaml.cs | 62 ++++++------ .../FRESHMusicPlayer-WPF/MainWindow.xaml.cs | 17 +--- .../MainWindow_Logic.xaml.cs | 2 +- 7 files changed, 118 insertions(+), 89 deletions(-) diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs index 3021cea..e11ed31 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs @@ -58,12 +58,12 @@ namespace FRESHMusicPlayer.ViewModels public IntegrationHandler Integrations { get; private set; } = new(); public NotificationHandler Notifications { get; private set; } = new(); - private Window Window + private MainWindow Window { get { if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - return desktop.MainWindow; + return desktop.MainWindow as MainWindow; else return null; } } @@ -407,43 +407,35 @@ namespace FRESHMusicPlayer.ViewModels { get { - switch (SelectedPane) + return SelectedPane switch // TODO: convert to switch expression { - case Pane.Settings: - return new Views.Settings().SetThings(Program.Config, Library); - case Pane.QueueManagement: - return new Views.QueueManagement().SetStuff(Player, Library, ProgressTimer); - case Pane.Search: - return new UserControl + Pane.Settings => new Views.Settings().SetThings(Program.Config, Library), + Pane.QueueManagement => new Views.QueueManagement().SetStuff(Player, Library, ProgressTimer), + Pane.Search => new UserControl + { + Content = new TextBlock { - Content = new TextBlock - { - Text = "Search" - } - }; - case Pane.TrackInfo: - return new TrackInfo().SetStuff(Player); - case Pane.Notifications: - return new UserControl + Text = "Search" + } + }, + Pane.TrackInfo => new TrackInfo().SetStuff(Player), + Pane.Notifications => new UserControl + { + Content = new TextBlock { - Content = new TextBlock - { - Text = "Notifications" - } - }; - case Pane.Lyrics: - return new UserControl + Text = "Notifications" + } + }, + Pane.Lyrics => new UserControl + { + Content = new TextBlock { - Content = new TextBlock - { - Text = "Lyrics" - } - }; - case Pane.None: - return null; - default: - throw new Exception("????"); - } + Text = "Lyrics" + } + }, + Pane.None => null, + _ => throw new Exception("????"), + }; } } @@ -454,6 +446,36 @@ namespace FRESHMusicPlayer.ViewModels set => this.RaiseAndSetIfChanged(ref auxPaneWidth, value); } + private Dock auxPaneDock = Dock.Right; + public Dock AuxPaneDock + { + get => auxPaneDock; + set => this.RaiseAndSetIfChanged(ref auxPaneDock, value); + } + + public void ShowAuxiliaryPane(Pane pane, int width = 235, bool openleft = false) + { + if (SelectedPane == pane) + { + HideAuxiliaryPane(); + return; + } + + if (SelectedPane != Pane.None) + { + // TODO: put something here + } + + if (!openleft) AuxPaneDock = Dock.Right; else AuxPaneDock = Dock.Left; + SelectedPane = pane; + Window.SetAuxPaneOpened(true); + } + public void HideAuxiliaryPane() + { + SelectedPane = Pane.None; + Window.SetAuxPaneOpened(false); + } + #region Library public async void StartThings() { @@ -592,12 +614,12 @@ namespace FRESHMusicPlayer.ViewModels #region NavBar public void OpenSettingsCommand() { - SelectedPane = Pane.Settings; + ShowAuxiliaryPane(Pane.Settings, 335); } public void OpenQueueManagementCommand() { - SelectedPane = Pane.QueueManagement; + ShowAuxiliaryPane(Pane.QueueManagement, 335); } public void OpenPlaylistManagementCommand() diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml index 7f9a9a6..8e86890 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml @@ -206,8 +206,22 @@ - - + + + + + diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml.cs index e279798..df9cf1a 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml.cs @@ -23,7 +23,7 @@ namespace FRESHMusicPlayer.Views #if DEBUG this.AttachDevTools(); #endif - DoStuff(); + //DoStuff(); RootPanel = this.FindControl("RootPanel"); SetValue(DragDrop.AllowDropProperty, true); AddHandler(DragDrop.DragEnterEvent, (s, e) => OnDragEnter(s, e)); @@ -36,10 +36,14 @@ namespace FRESHMusicPlayer.Views } - private void DoStuff() + public void SetAuxPaneOpened(bool state) { + var auxPane = this.FindControl("AuxPane"); + if (state) auxPane.Classes.Add("opened"); + else auxPane.Classes.Remove("opened"); } + private void OnClosing(object sender, CancelEventArgs e) { ViewModel?.CloseThings(); diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj index 3c95824..526bc2c 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj @@ -12,7 +12,7 @@ 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 - true + false true @@ -429,5 +429,5 @@ - + \ No newline at end of file diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/Forms/TagEditor/TagEditor.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/Forms/TagEditor/TagEditor.xaml.cs index 8168ddc..24625e2 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/Forms/TagEditor/TagEditor.xaml.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/Forms/TagEditor/TagEditor.xaml.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media.Imaging; @@ -89,33 +90,36 @@ namespace FRESHMusicPlayer.Forms.TagEditor unsavedChanges = false; } - public void SaveChanges(List filePaths) + public async Task SaveChanges(List filePaths) { - foreach (string path in filePaths) + await Task.Run(() => { - var track = new Track(path) + foreach (string path in filePaths) { - Artist = ArtistBox.Text, - Title = TitleBox.Text, - Album = AlbumBox.Text, - Genre = GenreBox.Text, - Year = Convert.ToInt32(YearBox.Text), - AlbumArtist = AlbumArtistBox.Text, - Composer = ComposerBox.Text, - TrackNumber = Convert.ToInt32(TrackNumBox.Text), - DiscNumber = Convert.ToInt32(DiscNumBox.Text), - Lyrics = new LyricsInfo() - }; - track.Lyrics.UnsynchronizedLyrics = UntimedLyricsBox.Text; - track.EmbeddedPictures.Clear(); - foreach (var cover in CoverArts) track.EmbeddedPictures.Add(cover); - track.Save(); - library?.Remove(path); // update library entry, if available - library?.Import(path); - } + var track = new Track(path) + { + Artist = ArtistBox.Text, + Title = TitleBox.Text, + Album = AlbumBox.Text, + Genre = GenreBox.Text, + Year = Convert.ToInt32(YearBox.Text), + AlbumArtist = AlbumArtistBox.Text, + Composer = ComposerBox.Text, + TrackNumber = Convert.ToInt32(TrackNumBox.Text), + DiscNumber = Convert.ToInt32(DiscNumBox.Text), + Lyrics = new LyricsInfo() + }; + track.Lyrics.UnsynchronizedLyrics = UntimedLyricsBox.Text; + track.EmbeddedPictures.Clear(); + foreach (var cover in CoverArts) track.EmbeddedPictures.Add(cover); + track.Save(); + library?.Remove(path); // update library entry, if available + library?.Import(path); + } + }); } - public void SaveButton() + public async Task SaveButton() { unsavedChanges = false; Title = $"{string.Join(", ", Displayfilepaths)} | FRESHMusicPlayer Tag Editor"; @@ -129,7 +133,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor return; } } - SaveChanges(FilePaths); + await SaveChanges(FilePaths); } public void ChangeFiles() @@ -219,7 +223,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor if (selectedIndex <= CoverArtSelector.Items.Count) CoverArtSelector.SelectedIndex = selectedIndex; } - private void Player_SongChanged(object sender, EventArgs e) + private async void Player_SongChanged(object sender, EventArgs e) { if (filePathsToSaveInBackground.Count != 0) { @@ -227,13 +231,13 @@ namespace FRESHMusicPlayer.Forms.TagEditor { if (path == player.FilePath) break; // still listening to files that can't be properly saved } - SaveChanges(filePathsToSaveInBackground); + await SaveChanges(filePathsToSaveInBackground); filePathsToSaveInBackground.Clear(); Close(); } } - private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) + private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (unsavedChanges == true) { @@ -241,7 +245,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor "FRESHMusicPlayer Tag Editor", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); - if (result == MessageBoxResult.Yes) SaveButton(); + if (result == MessageBoxResult.Yes) await SaveButton(); else if (result == MessageBoxResult.Cancel) { e.Cancel = true; @@ -260,7 +264,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor } } - private void Button_Click(object sender, RoutedEventArgs e) => SaveButton(); + private async void Button_Click(object sender, RoutedEventArgs e) => await SaveButton(); private void Button_Click_1(object sender, RoutedEventArgs e) => ChangeFiles(); @@ -284,7 +288,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor private void OpenMenu_MouseDown(object sender, RoutedEventArgs e) => ChangeFiles(); - private void SaveMenuItem(object sender, RoutedEventArgs e) => SaveButton(); + private async void SaveMenuItem(object sender, RoutedEventArgs e) => await SaveButton(); private void ExitMenuItem(object sender, RoutedEventArgs e) => Close(); diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml.cs index c6aa49b..9845cdb 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml.cs @@ -1,33 +1,18 @@ using FRESHMusicPlayer.Backends; -using FRESHMusicPlayer.Forms; -using FRESHMusicPlayer.Forms.Playlists; -using FRESHMusicPlayer.Forms.TagEditor; using FRESHMusicPlayer.Handlers; using FRESHMusicPlayer.Handlers.Configuration; using FRESHMusicPlayer.Handlers.Integrations; using FRESHMusicPlayer.Handlers.Notifications; -using FRESHMusicPlayer.Pages; -using FRESHMusicPlayer.Pages.Library; -using FRESHMusicPlayer.Pages.Lyrics; -using FRESHMusicPlayer.Utilities; using LiteDB; using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Linq; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; using System.Windows.Media.Animation; -using System.Windows.Media.Imaging; using WinForms = System.Windows.Forms; namespace FRESHMusicPlayer { - + /// /// Interaction logic for MainWindow.xaml /// diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow_Logic.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow_Logic.xaml.cs index 11952e2..879f4cf 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow_Logic.xaml.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow_Logic.xaml.cs @@ -170,7 +170,7 @@ namespace FRESHMusicPlayer PauseAfterCurrentTrack = false; } - LoggingHandler.Log("Changing tracks"); + LoggingHandler.Log("Changing tracks!"); } private async void Player_SongException(object sender, PlaybackExceptionEventArgs e) { From cf5fe6f09b74b7098da242fe6aeb87aadda7e263 Mon Sep 17 00:00:00 2001 From: Royce551 Date: Mon, 6 Jun 2022 20:17:19 -0500 Subject: [PATCH 2/3] Fix overflow menu not scaling up when window is dragged to higher dpi monitor --- FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml | 4 ++-- .../FRESHMusicPlayer-WPF/MainWindow_Controls.xaml.cs | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml index 4819688..7e4bf02 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow.xaml @@ -70,14 +70,14 @@ - + - + diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow_Controls.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow_Controls.xaml.cs index f4ee3f6..38ab92f 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow_Controls.xaml.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/MainWindow_Controls.xaml.cs @@ -74,12 +74,6 @@ namespace FRESHMusicPlayer ProgressTimer.Start(); // resync the progress timer } private void TrackTitle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) => ShowAuxilliaryPane(Pane.TrackInfo, 235, true); - private void TrackTitle_MouseRightButtonDown(object sender, MouseButtonEventArgs e) - { - var cm = FindResource("MiscContext") as ContextMenu; - cm.PlacementTarget = sender as Button; - cm.IsOpen = true; - } private void TrackContextTagEditor_Click(object sender, RoutedEventArgs e) { var tracks = new List(); From 73217995407dc1a60ac3586b9a25c46f4c67f87f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jun 2022 23:59:53 +0000 Subject: [PATCH 3/3] Bump NuGet.CommandLine in /FRESHMusicPlayer/FRESHMusicPlayer-WPF Bumps [NuGet.CommandLine](https://github.com/NuGet/NuGet.Client) from 5.7.0 to 5.7.2. - [Release notes](https://github.com/NuGet/NuGet.Client/releases) - [Commits](https://github.com/NuGet/NuGet.Client/commits) --- updated-dependencies: - dependency-name: NuGet.CommandLine dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .../FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj index 526bc2c..8b8d9ef 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF/FRESHMusicPlayer-WPF.csproj @@ -397,7 +397,7 @@ 1.9.0 - 5.7.0 + 5.7.2 runtime; build; native; contentfiles; analyzers; buildtransitive all