From 92185100a900ea1fbc48a68ef8b07348f6e2f6f1 Mon Sep 17 00:00:00 2001 From: Royce551 Date: Sun, 2 May 2021 07:17:42 -0500 Subject: [PATCH] fixes improvements stuff --- .../ViewModels/MainWindowViewModel.cs | 9 +++++---- .../Forms/MiniPlayer.xaml | 2 +- .../Forms/MiniPlayer.xaml.cs | 20 +++++++++++++++++++ .../Integrations/DiscogsIntegration.cs | 2 +- .../MainWindow.xaml.cs | 11 ++++++---- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs index dd76cc0..4606c05 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs @@ -397,7 +397,7 @@ namespace FRESHMusicPlayer.ViewModels set => this.RaiseAndSetIfChanged(ref filePathOrURL, value); } - private List acceptableFilePaths = "*.wav;*.aiff;*.mp3;*.wma;*.3g2;*.3gp;*.3gp2;*.3gpp;*.asf;*.wmv;*.aac;*.adts;*.avi;*.m4a;*.m4a;*.m4v;*.mov;*.mp4;*.sami;*.smi;*.flac".Split(';').ToList(); + private List acceptableFilePaths = "wav;aiff;mp3;wma;3g2;3gp;3gp2;3gpp;asf;wmv;aac;adts;avi;m4a;m4a;m4v;mov;mp4;sami;smi;flac".Split(';').ToList(); // ripped directly from fmp-wpf 'cause i'm lazy public async void BrowseTracksCommand() { @@ -413,9 +413,10 @@ namespace FRESHMusicPlayer.ViewModels new FileDialogFilter() { Name = "Other", - Extensions = new List(){"*"} + Extensions = new List() { "*" } } - } + }, + AllowMultiple = true }; if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { @@ -433,7 +434,7 @@ namespace FRESHMusicPlayer.ViewModels new FileDialogFilter() { Name = "Playlist Files", - Extensions = new(){ "*.xspf", "*.asx", "*.wvx", "*.b4s", "*.m3u", "*.m3u8", "*.pls", "*.smil", "*.smi", "*.zpl"} + Extensions = new(){ "xspf", "asx", "wvx", "b4s", "m3u", "m3u8", "pls", "smil", "smi", "zpl"} } } }; diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/MiniPlayer.xaml b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/MiniPlayer.xaml index 358b083..199949d 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/MiniPlayer.xaml +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/MiniPlayer.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:FRESHMusicPlayer.Forms" mc:Ignorable="d" WindowStartupLocation="CenterOwner" - WindowStyle="None" Background="Transparent" AllowsTransparency="True" Topmost="True" ResizeMode="CanMinimize" + WindowStyle="None" Background="Transparent" AllowsTransparency="True" Topmost="True" ResizeMode="CanMinimize" LocationChanged="Window_LocationChanged" Title="MiniPlayer" Height="55" Width="500"> diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/MiniPlayer.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/MiniPlayer.xaml.cs index e05274a..fb061fc 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/MiniPlayer.xaml.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/MiniPlayer.xaml.cs @@ -9,6 +9,7 @@ using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; @@ -78,6 +79,8 @@ namespace FRESHMusicPlayer.Forms private void DockPanel_MouseEnter(object sender, MouseEventArgs e) { + + var fadeIn = InterfaceUtils.GetDoubleAnimation(0f, 1f, TimeSpan.FromMilliseconds(500), new PropertyPath("Opacity")); fadeIn.Begin(TitlebarDockPanel); var brightener = InterfaceUtils.GetDoubleAnimation(0.8, 1f, TimeSpan.FromMilliseconds(500), new PropertyPath("Opacity")); @@ -148,5 +151,22 @@ namespace FRESHMusicPlayer.Forms window.Player.Volume = (float)(VolumeSlider.Value / 100); window.VolumeBar.Value = VolumeSlider.Value; } + + private void Window_LocationChanged(object sender, EventArgs e) + { + var currentScreen = WinForms.Screen.FromHandle(new WindowInteropHelper(this).Handle).Bounds; + var window = new System.Drawing.Rectangle((int)Left, (int)Top, (int)Width, (int)Height); + var topHalf = new System.Drawing.Rectangle(currentScreen.X, currentScreen.Y, currentScreen.Width, currentScreen.Height / 2); + if (topHalf.Contains(window)) + { + DockPanel.SetDock(ContentGrid, Dock.Top); + DockPanel.SetDock(TitlebarDockPanel, Dock.Bottom); + } + else + { + DockPanel.SetDock(ContentGrid, Dock.Bottom); + DockPanel.SetDock(TitlebarDockPanel, Dock.Top); + } + } } } diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/TagEditor/Integrations/DiscogsIntegration.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/TagEditor/Integrations/DiscogsIntegration.cs index 8614f87..a4bc93f 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/TagEditor/Integrations/DiscogsIntegration.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Forms/TagEditor/Integrations/DiscogsIntegration.cs @@ -47,7 +47,7 @@ namespace FRESHMusicPlayer.Forms.TagEditor.Integrations { var releases = new List<(string Name, string Id)>(); string jsonString; - try { jsonString = httpClient.GetStringAsync($"https://api.discogs.com/database/search?q={{{query}}}&{{track}}&per_page=1&key={Key}&secret={Secret}").Result; } + try { jsonString = httpClient.GetStringAsync($"https://api.discogs.com/database/search?release_title={query}&type=release&per_page=100&key={Key}&secret={Secret}").Result; } catch (AggregateException) { Worked = false; diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/MainWindow.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/MainWindow.xaml.cs index ec901cf..dd04cbc 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/MainWindow.xaml.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/MainWindow.xaml.cs @@ -107,16 +107,19 @@ namespace FRESHMusicPlayer Dispatcher.Invoke(() => { var files = File.ReadAllLines(args.FullPath); - if (files.Length != 0) + if (files.Length != 0) // user wants to play a file { player.Queue.Clear(); player.Queue.Add(files); player.PlayMusic(); } + else // user might've forgotten fmp is open, let's flash + { + Activate(); + Topmost = true; + Topmost = false; + } File.Delete(args.FullPath); - Activate(); - Topmost = true; - Topmost = false; }); }; LoggingHandler.Log("Ready to go!");