From 4951d340834dd6175b0bf86425a3a1fc5dbe8d05 Mon Sep 17 00:00:00 2001 From: LordKBX Date: Mon, 27 Nov 2023 19:19:57 +0100 Subject: [PATCH] TargetFramework changed to net 6.0 Debug Library context menu Remove Debug Button in releases --- AnotherMusicPlayer/AnotherMusicPlayer.csproj | 17 ++- AnotherMusicPlayer/Commons.cs | 2 + .../Library/ContextMenu.xaml.cs | 129 ++++++++++-------- AnotherMusicPlayer/Library/Library.cs | 1 + .../Library/LibraryPathNavigator.cs | 58 ++++---- .../MainWindow/Events/EventsButtons.cs | 4 +- AnotherMusicPlayer/MainWindow/MainWindow.xaml | 2 +- .../MainWindow/MainWindow.xaml.cs | 11 +- .../MainWindow/Preview/Setup.cs | 51 +++++-- AnotherMusicPlayer/PlayLists/PlayLists.cs | 2 +- .../Properties/Settings.Designer.cs | 26 ++++ .../Properties/Settings.settings | 6 + Installer-common.iss => Installer-AnyCPU.iss | 50 +------ Installer-x64.iss | 6 - Installer-x86.iss | 6 - README.md | 8 +- publish.ps1 | 6 +- 17 files changed, 218 insertions(+), 167 deletions(-) create mode 100644 AnotherMusicPlayer/Properties/Settings.Designer.cs create mode 100644 AnotherMusicPlayer/Properties/Settings.settings rename Installer-common.iss => Installer-AnyCPU.iss (53%) delete mode 100644 Installer-x64.iss delete mode 100644 Installer-x86.iss diff --git a/AnotherMusicPlayer/AnotherMusicPlayer.csproj b/AnotherMusicPlayer/AnotherMusicPlayer.csproj index d2034b0..bbc1eb8 100644 --- a/AnotherMusicPlayer/AnotherMusicPlayer.csproj +++ b/AnotherMusicPlayer/AnotherMusicPlayer.csproj @@ -1,7 +1,7 @@ WinExe - netcoreapp3.1 + net6.0-windows7.0 true LordKBX LordKBX Workshop @@ -9,7 +9,7 @@ AnotherMusicPlayer AnotherMusicPlayer AnotherMusicPlayer - 0.1.7.3 + 0.1.7.4 LordKBX Workshop 2022 LICENSE https://github.com/LordKBX/Another-Music-Player @@ -20,10 +20,10 @@ true icons\icon_large.ico Debug;Release - 0.1.7.3 - 0.1.7.3 OnBuildSuccess en + False + False @@ -70,6 +70,11 @@ True Resources.resx + + True + True + Settings.settings + @@ -186,6 +191,10 @@ Never + + SettingsSingleFileGenerator + Settings.Designer.cs + diff --git a/AnotherMusicPlayer/Commons.cs b/AnotherMusicPlayer/Commons.cs index e654a1f..83848c9 100644 --- a/AnotherMusicPlayer/Commons.cs +++ b/AnotherMusicPlayer/Commons.cs @@ -77,10 +77,12 @@ public partial class MainWindow : Window public static string BaseDir = AppDomain.CurrentDomain.BaseDirectory + SeparatorChar; /// Base Diractory of the icon folder public static string BaseDirImg = AppDomain.CurrentDomain.BaseDirectory + SeparatorChar + "icons" + SeparatorChar; + public static bool IsDebug = false; [Conditional("DEBUG")] static public void DebugBaseDir() { + IsDebug = true; Debug.WriteLine(">>> DebugBaseDir() <<<"); MainWindow.BaseDir = "D:\\CODES\\VS\\MediaPlayer\\AnotherMusicPlayer"; } diff --git a/AnotherMusicPlayer/Library/ContextMenu.xaml.cs b/AnotherMusicPlayer/Library/ContextMenu.xaml.cs index 8bc5f6c..eaee00d 100644 --- a/AnotherMusicPlayer/Library/ContextMenu.xaml.cs +++ b/AnotherMusicPlayer/Library/ContextMenu.xaml.cs @@ -13,7 +13,7 @@ namespace AnotherMusicPlayer { public partial class Library { - private ContextMenu MakeContextMenu(object parent, string otype = null, bool back = false, string backPath = "") + public ContextMenu MakeContextMenu(object parent, string otype = null, bool back = false, string backPath = "") { if (otype == null || otype == "") { otype = "track"; } string type = otype = otype.ToLower(); @@ -64,8 +64,11 @@ private ContextMenu MakeContextMenu(object parent, string otype = null, bool bac if (type == "file") { ((MenuItem)cm.Items[i]).Click += CM_EditTrack; } if (type == "track") { ((MenuItem)cm.Items[i]).Click += CM_EditTrack; } if (type == "album") { ((MenuItem)cm.Items[i]).Click += CM_EditAlbum; } - if (type == "folder") { ((MenuItem)cm.Items[i]).Click += CM_EditFolder; } - + if (type == "folder") { + if (MainWindow.Instance.library.CurrentPath == Settings.LibFolder && parent.GetType().Name == "AlignablePanel") + { ((MenuItem)cm.Items[i]).Visibility = Visibility.Collapsed; } + else { ((MenuItem)cm.Items[i]).Click += CM_EditFolder; } + } } else if (((MenuItem)cm.Items[i]).Name.ToLower() == "playlistsadd" + type) { @@ -117,13 +120,21 @@ private void CM_AddPlaylistAlbum(object sender, RoutedEventArgs e) private void CM_AddPlaylistFolder(object sender, RoutedEventArgs e) { - MenuItem item = (MenuItem)sender; - string folder = null; - try { folder = ((Button)item.Tag).Tag as string; } - catch { } - if (folder == null) { return; } - string[] tracks = getDirectoryMediaFIles(folder, true); - Parent.playLists.RecordTracksIntoPlaylist(tracks); + try + { + MenuItem item = (MenuItem)sender; + string folder = null; + + if (item.Tag == null) { return; } + else if (item.Tag.GetType().Name == "Button") { folder = ((Button)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "AlignablePanel") { folder = ((AlignablePanel)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "TextBlock") { folder = ((TextBlock)item.Tag).Tag as string; } + + if (folder == null) { return; } + string[] tracks = getDirectoryMediaFIles(folder, true); + Parent.playLists.RecordTracksIntoPlaylist(tracks); + } + catch(Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } } #region ContextMenu Add Playlist functions @@ -158,8 +169,10 @@ private void CM_AddFolder(object sender, RoutedEventArgs e) { MenuItem item = (MenuItem)sender; string folder = null; - try { folder = ((Button)item.Tag).Tag as string; } - catch { } + if (item.Tag == null) { return; } + else if (item.Tag.GetType().Name == "Button") { folder = ((Button)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "AlignablePanel") { folder = ((AlignablePanel)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "TextBlock") { folder = ((TextBlock)item.Tag).Tag as string; } if (folder == null) { return; } Parent.player.PlaylistEnqueue(getDirectoryMediaFIles(folder, true), false, 0, 0, true); } @@ -189,12 +202,10 @@ private void CM_AddShuffledFolder(object sender, RoutedEventArgs e) else { string folder = null; - try { folder = ((Button)item.Tag).Tag as string; } - catch - { - try { } - catch { } - } + if (item.Tag == null) { return; } + else if (item.Tag.GetType().Name == "Button") { folder = ((Button)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "AlignablePanel") { folder = ((AlignablePanel)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "TextBlock") { folder = ((TextBlock)item.Tag).Tag as string; } if (folder == null) { return; } Parent.player.PlaylistEnqueue(getDirectoryMediaFIles(folder, true), true, 0, 0, true); } @@ -236,12 +247,10 @@ private void CM_PlayFolder(object sender, RoutedEventArgs e) { MenuItem item = (MenuItem)sender; string folder = null; - try { folder = ((Button)item.Tag).Tag as string; } - catch - { - try { } - catch { } - } + if (item.Tag == null) { return; } + else if (item.Tag.GetType().Name == "Button") { folder = ((Button)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "AlignablePanel") { folder = ((AlignablePanel)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "TextBlock") { folder = ((TextBlock)item.Tag).Tag as string; } if (folder == null) { return; } Parent.player.PlaylistClear(); Parent.player.PlaylistEnqueue(getDirectoryMediaFIles(folder, true), false, 0, 0, true); @@ -259,31 +268,36 @@ private void CM_PlayShuffledAlbum(object sender, RoutedEventArgs e) private void CM_PlayShuffledFolder(object sender, RoutedEventArgs e) { - MenuItem item = (MenuItem)sender; - if (item.Tag.GetType().Name == "ListView") + try { - ListView view = (ListView)item.Tag; - if (view.SelectedItems.Count > 0) + MenuItem item = (MenuItem)sender; + Debug.WriteLine(item.Tag.GetType().Name); + if (item.Tag.GetType().Name == "ListView") { - List files = new List(); - foreach (MediaItem itm in view.SelectedItems) { files.Add(itm.Path); } - Parent.player.PlaylistClear(); - Parent.player.PlaylistEnqueue(files.ToArray(), true, 0, 0, true); + ListView view = (ListView)item.Tag; + if (view.SelectedItems.Count > 0) + { + List files = new List(); + foreach (MediaItem itm in view.SelectedItems) { files.Add(itm.Path); } + Parent.player.PlaylistClear(); + Parent.player.PlaylistEnqueue(files.ToArray(), true, 0, 0, true); + } } - } - else - { - string folder = null; - try { folder = ((Button)item.Tag).Tag as string; } - catch + else { - try { } - catch { } + string folder = null; + if (item.Tag == null) { return; } + else if (item.Tag.GetType().Name == "Button") { folder = ((Button)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "AlignablePanel") { folder = ((AlignablePanel)item.Tag).Tag as string; } + else if (item.Tag.GetType().Name == "TextBlock") { folder = ((TextBlock)item.Tag).Tag as string; } + else { Debug.WriteLine(item.Tag.GetType().Name); } + + if (folder == null) { return; } + Parent.player.PlaylistClear(); + Parent.player.PlaylistEnqueue(getDirectoryMediaFIles(folder, true), true, 0, 0, true); } - if (folder == null) { return; } - Parent.player.PlaylistClear(); - Parent.player.PlaylistEnqueue(getDirectoryMediaFIles(folder, true), true, 0, 0, true); } + catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } } #endregion @@ -336,21 +350,26 @@ private void CM_EditAlbum(object sender, RoutedEventArgs e) private void CM_EditFolder(object sender, RoutedEventArgs e) { MenuItem item = (MenuItem)sender; - Button btn = (Button)item.Tag; - string folderPath = ((string)btn.Tag).Trim().TrimEnd(MainWindow.SeparatorChar); - Debug.WriteLine("--> CM_EditFolder, folderPath='" + folderPath + "'"); - string[] pathTab = folderPath.Split(MainWindow.SeparatorChar); - Debug.WriteLine("--> CM_EditFolder, pathTab.Length='" + pathTab.Length + "'"); - - RenameWindow win = new RenameWindow(Parent, folderPath, pathTab); - win.ShowDialog(); - if (win.renamed == true) + if (item.Tag == null) { return; } + else if (item.Tag.GetType().Name == "Button") { - DisplayPath(CurrentPath); + Button btn = (Button)item.Tag; + string folderPath = ((string)btn.Tag).Trim().TrimEnd(MainWindow.SeparatorChar); + Debug.WriteLine("--> CM_EditFolder, folderPath='" + folderPath + "'"); + string[] pathTab = folderPath.Split(MainWindow.SeparatorChar); + Debug.WriteLine("--> CM_EditFolder, pathTab.Length='" + pathTab.Length + "'"); + + RenameWindow win = new RenameWindow(Parent, folderPath, pathTab); + win.ShowDialog(); + if (win.renamed == true) + { + DisplayPath(CurrentPath); + } + //throw new System.NotImplementedException(); } } - //throw new System.NotImplementedException(); + else if (item.Tag.GetType().Name == "AlignablePanel") { return; } } - #endregion + #endregion } /// diff --git a/AnotherMusicPlayer/Library/Library.cs b/AnotherMusicPlayer/Library/Library.cs index 1fcde81..2c42c29 100644 --- a/AnotherMusicPlayer/Library/Library.cs +++ b/AnotherMusicPlayer/Library/Library.cs @@ -225,6 +225,7 @@ public void DisplayPath(string path = null) pathNavigator.Display(path); SearchResultsContener.ItemsSource = null; + NavigationContener.Tag = path; NavigationContener.Children.Clear(); NavigationContenerScoller.ContextMenu = null; NavigationContenerScoller.ContextMenu = MakeContextMenu(NavigationContener, "folder", (path != Settings.LibFolder) ? true : false, (path != Settings.LibFolder) ? path : null); diff --git a/AnotherMusicPlayer/Library/LibraryPathNavigator.cs b/AnotherMusicPlayer/Library/LibraryPathNavigator.cs index f0d8e38..5e7326f 100644 --- a/AnotherMusicPlayer/Library/LibraryPathNavigator.cs +++ b/AnotherMusicPlayer/Library/LibraryPathNavigator.cs @@ -7,6 +7,7 @@ using System.Windows.Media; using System.Diagnostics; using Newtonsoft.Json; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox; namespace AnotherMusicPlayer { @@ -55,7 +56,7 @@ public void Display(string path = null) tb.Text = Parent.Parent.FindResource("LibraryNavigatorItemHome") as string; tb.Tag = RootPath; tb.MouseLeftButtonDown += PathClicked; - tb.ContextMenu = MakeContextMenu(); + tb.ContextMenu = MakeContextMenu(tb, RootPath); Contener.Children.Add(tb); foreach (string name in workTab) @@ -73,7 +74,7 @@ public void Display(string path = null) tb3.Text = name; tb3.Tag = newPath; tb3.MouseLeftButtonDown += PathClicked; - tb3.ContextMenu = MakeContextMenu(); + tb3.ContextMenu = MakeContextMenu(tb3, newPath); Contener.Children.Add(tb3); @@ -101,7 +102,7 @@ public void DisplayAlt(string content = null) tb.Text = Parent.Parent.FindResource("LibraryNavigatorItemHome") as string; tb.Tag = RootPath; tb.MouseLeftButtonDown += PathClicked; - tb.ContextMenu = MakeContextMenu(); + tb.ContextMenu = MakeContextMenu(tb, RootPath); Contener.Children.Add(tb); TextBlock tb2 = new TextBlock(); @@ -131,29 +132,36 @@ private void PathClicked(object sender, System.Windows.Input.MouseButtonEventArg Display(tag); } - private ContextMenu MakeContextMenu() + private ContextMenu MakeContextMenu(TextBlock parent, string path) { - ContextMenu cm = new LibraryContextMenu() { Style = Contener.FindResource("CustomContextMenuStyle") as Style }; - for (int i = 0; i < cm.Items.Count; i++) - { - if (((MenuItem)cm.Items[i]).Name.ToLower() == "addfolder") - { - //((MenuItem)cm.Items[i]).Click += LibraryContextMenuAction_Add; - } - else if (((MenuItem)cm.Items[i]).Name.ToLower() == "addshufflefolder") - { - //((MenuItem)cm.Items[i]).Click += LibraryContextMenuAction_AddShuffle; - } - else if (((MenuItem)cm.Items[i]).Name.ToLower() == "playfolder") - { - //((MenuItem)cm.Items[i]).Click += LibraryContextMenuAction_Play; - } - else if (((MenuItem)cm.Items[i]).Name.ToLower() == "playshufflefolder") - { - //((MenuItem)cm.Items[i]).Click += LibraryContextMenuAction_PlayShuffle; - } - else { ((MenuItem)cm.Items[i]).Visibility = Visibility.Collapsed; } - } + //ContextMenu cm = new LibraryContextMenu() { Style = Contener.FindResource("CustomContextMenuStyle") as Style }; + bool back = (RootPath != path) ? true : false; + string backPath = ""; + if (path != RootPath) { path = Directory.GetParent(path).FullName; } + + ContextMenu cm = MainWindow.Instance.library.MakeContextMenu(parent, "folder", back, backPath); + ((LibraryContextMenu)cm).EditFolder.Visibility = Visibility.Collapsed; + ((LibraryContextMenu)cm).PlayListsAddFolder.Visibility = Visibility.Collapsed; + //for (int i = 0; i < cm.Items.Count; i++) + //{ + // if (((MenuItem)cm.Items[i]).Name.ToLower() == "addfolder") + // { + // //((MenuItem)cm.Items[i]).Click += LibraryContextMenuAction_Add; + // } + // else if (((MenuItem)cm.Items[i]).Name.ToLower() == "addshufflefolder") + // { + // //((MenuItem)cm.Items[i]).Click += LibraryContextMenuAction_AddShuffle; + // } + // else if (((MenuItem)cm.Items[i]).Name.ToLower() == "playfolder") + // { + // //((MenuItem)cm.Items[i]).Click += LibraryContextMenuAction_Play; + // } + // else if (((MenuItem)cm.Items[i]).Name.ToLower() == "playshufflefolder") + // { + // //((MenuItem)cm.Items[i]).Click += LibraryContextMenuAction_PlayShuffle; + // } + // else { ((MenuItem)cm.Items[i]).Visibility = Visibility.Collapsed; } + //} return cm; } diff --git a/AnotherMusicPlayer/MainWindow/Events/EventsButtons.cs b/AnotherMusicPlayer/MainWindow/Events/EventsButtons.cs index 586bd2b..d53d311 100644 --- a/AnotherMusicPlayer/MainWindow/Events/EventsButtons.cs +++ b/AnotherMusicPlayer/MainWindow/Events/EventsButtons.cs @@ -98,7 +98,6 @@ private void BtnRepeat_Click(object sender, RoutedEventArgs e) /// Callback Event Click on Debug Export Vars private void Debug_Button_Click(object sender, RoutedEventArgs e) { - /* setMetadataScanningState(false); JsonSerializerSettings jss = new JsonSerializerSettings(); jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; @@ -116,8 +115,7 @@ private void Debug_Button_Click(object sender, RoutedEventArgs e) } output += "]"; File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + SeparatorChar + AppName + "\\PlayListView.txt", "" + output, System.Text.Encoding.UTF8); - */ - DebugBaseDir(); + StyleUpdate(); } diff --git a/AnotherMusicPlayer/MainWindow/MainWindow.xaml b/AnotherMusicPlayer/MainWindow/MainWindow.xaml index 4812c3c..22e3f6b 100644 --- a/AnotherMusicPlayer/MainWindow/MainWindow.xaml +++ b/AnotherMusicPlayer/MainWindow/MainWindow.xaml @@ -468,7 +468,7 @@ + ScrollViewer.CanContentScroll="False" ContextMenuService.IsEnabled="True" HorizontalAlignment="Stretch"> diff --git a/AnotherMusicPlayer/MainWindow/MainWindow.xaml.cs b/AnotherMusicPlayer/MainWindow/MainWindow.xaml.cs index 0644930..7fc54ab 100644 --- a/AnotherMusicPlayer/MainWindow/MainWindow.xaml.cs +++ b/AnotherMusicPlayer/MainWindow/MainWindow.xaml.cs @@ -69,10 +69,12 @@ public partial class MainWindow : System.Windows.Window private void IsDebugCheck() { isDebug = true; } private App Parent = null; + public static MainWindow? Instance; /// Constructor public MainWindow(Database obdd, App parent) { + Instance = this; Parent = parent; AppName = System.Windows.Application.Current.MainWindow.GetType().Assembly.GetName().Name; bdd = obdd; @@ -99,8 +101,13 @@ public MainWindow(Database obdd, App parent) //TabControl t = new TabControl(); //t.cli SetTitle(""); - TabControler.SelectedIndex = 2; - + DebugBaseDir(); + if (isDebug) { TabControler.SelectedIndex = 1; } + else { + TabControler.SelectedIndex = 0; + this.BtnDebug.Visibility = Visibility.Collapsed; + } + PlayListIndex = Settings.LastPlaylistIndex; Debug.WriteLine("LastPlaylistIndex: " + Settings.LastPlaylistIndex); diff --git a/AnotherMusicPlayer/MainWindow/Preview/Setup.cs b/AnotherMusicPlayer/MainWindow/Preview/Setup.cs index cf3fb01..370c4df 100644 --- a/AnotherMusicPlayer/MainWindow/Preview/Setup.cs +++ b/AnotherMusicPlayer/MainWindow/Preview/Setup.cs @@ -10,6 +10,7 @@ using System.Windows.Media.Imaging; using System.Windows.Media; using System.Diagnostics; +using System.Windows.Controls; namespace AnotherMusicPlayer { @@ -63,28 +64,32 @@ private void PreviewSetUp() DestroyIcon(Hicon4); buttonPrev = new ThumbnailToolBarButton(IconPrev, "test"); - buttonPrev.Click += (object sender, ThumbnailButtonClickedEventArgs e) => { PreviousTrack(); CustomThumbnail_TabbedThumbnailBitmapRequested(null, null); }; + buttonPrev.Click += (object sender, ThumbnailButtonClickedEventArgs e) => { PreviousTrack(); }; buttonPlay = new ThumbnailToolBarButton(IconPlay, "IconPlay"); buttonPlay.Click += (object sender, ThumbnailButtonClickedEventArgs e) => { Pause(); }; buttonNext = new ThumbnailToolBarButton(IconNext, "IconNext"); - buttonNext.Click += (object sender, ThumbnailButtonClickedEventArgs e) => { NextTrack(); CustomThumbnail_TabbedThumbnailBitmapRequested(null, null); }; + buttonNext.Click += (object sender, ThumbnailButtonClickedEventArgs e) => { NextTrack(); }; TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(customThumbnail); TaskbarManager.Instance.ThumbnailToolBars.AddButtons(windowHandle, new ThumbnailToolBarButton[] { buttonPrev, buttonPlay, buttonNext }); customThumbnail.TabbedThumbnailBitmapRequested += CustomThumbnail_TabbedThumbnailBitmapRequested; customThumbnail.TabbedThumbnailActivated += CustomThumbnail_TabbedThumbnailActivated; + customThumbnail.TabbedThumbnailMaximized += CustomThumbnail_TabbedThumbnailMaximized; customThumbnail.TabbedThumbnailClosed += CustomThumbnail_TabbedThumbnailClosed; this.StateChanged += MainWindow_StateChanged; customThumbnail.SetWindowIcon(Properties.Resources.icon_large); } + private void CustomThumbnail_TabbedThumbnailMaximized(object sender, TabbedThumbnailEventArgs e) + { CustomThumbnail_TabbedThumbnailActivated(sender, e); } + private void MainWindow_StateChanged(object sender, EventArgs e) { - if (this.WindowState == WindowState.Minimized) { Opacity = 0; } - if (this.WindowState == WindowState.Normal) { Opacity = 1; } - if (this.WindowState == WindowState.Maximized) { Opacity = 1; } - CustomThumbnailDisplayed = false; + if (this.WindowState == WindowState.Minimized) { Opacity = 0; CustomThumbnailDisplayed = true; } + if (this.WindowState == WindowState.Normal) { Opacity = 1; CustomThumbnailDisplayed = false; } + if (this.WindowState == WindowState.Maximized) { Opacity = 1; CustomThumbnailDisplayed = false; } + } private void CustomThumbnail_TabbedThumbnailClosed(object sender, TabbedThumbnailClosedEventArgs e) { Close(); } @@ -92,7 +97,9 @@ private void MainWindow_StateChanged(object sender, EventArgs e) private void CustomThumbnail_TabbedThumbnailActivated(object sender, TabbedThumbnailEventArgs e) { Opacity = 1; CustomThumbnailDisplayed = false; + this.Topmost = true; Show(); + this.Topmost = false; } private bool CustomThumbnailDisplayed = false; @@ -106,6 +113,7 @@ private void CustomThumbnail_TabbedThumbnailBitmapRequested(object sender, Tabbe if (CustomThumbnailDisplayed == false || CustomThumbnailCouter >= 10) { Bitmap bt = GeneratePreview(); + //Bitmap bt = GeneratePreview(MainWindow.Instance); customThumbnail.SetImage(bt); bt.Dispose(); CustomThumbnailCouter = 0; @@ -117,19 +125,40 @@ private void CustomThumbnail_TabbedThumbnailBitmapRequested(object sender, Tabbe private void InvalidateThumbnail() { customThumbnail.InvalidatePreview(); } - private Bitmap GeneratePreview() + private Bitmap GeneratePreview(Window? ctl = null) { System.Drawing.Bitmap im2 = null; - RenderTargetBitmap bmp = new RenderTargetBitmap(customThumbnailRectangle.Width, customThumbnailRectangle.Height, 96, 96, PixelFormats.Pbgra32); - - bmp.Render(PreviewControl); + int width = 0; + int height = 0; + RenderTargetBitmap bmp; + //if (ctl != null) + //{ + // string sw = "" + ctl.Width; + // string sh = "" + ctl.Height; + // sw = sw.Substring(0, sw.IndexOf(",")); + // sh = sh.Substring(0, sh.IndexOf(",")); + + // width = int.Parse(sw); + // height = int.Parse(sh); + // bmp = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32); + + // bmp.Render(ctl); + //} + //else + //{ + width = customThumbnailRectangle.Width; + height = customThumbnailRectangle.Height; + bmp = new RenderTargetBitmap(customThumbnailRectangle.Width, customThumbnailRectangle.Height, 96, 96, PixelFormats.Pbgra32); + + bmp.Render(PreviewControl); + //} var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); MemoryStream stm = new MemoryStream(); encoder.Save(stm); stm.Seek(0, SeekOrigin.Begin); - im2 = FilesTags.ResizeImage(Image.FromStream(stm), customThumbnailRectangle.Width, customThumbnailRectangle.Height); + im2 = FilesTags.ResizeImage(System.Drawing.Image.FromStream(stm), width, height); stm.Close(); stm.Dispose(); diff --git a/AnotherMusicPlayer/PlayLists/PlayLists.cs b/AnotherMusicPlayer/PlayLists/PlayLists.cs index e9ba96c..d1676d8 100644 --- a/AnotherMusicPlayer/PlayLists/PlayLists.cs +++ b/AnotherMusicPlayer/PlayLists/PlayLists.cs @@ -230,7 +230,7 @@ public void Init() private void RadioCategory_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { - throw new NotImplementedException(); + //throw new NotImplementedException(); } private void radioDoubleClick(object sender, MouseButtonEventArgs e) diff --git a/AnotherMusicPlayer/Properties/Settings.Designer.cs b/AnotherMusicPlayer/Properties/Settings.Designer.cs new file mode 100644 index 0000000..91c7f8f --- /dev/null +++ b/AnotherMusicPlayer/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 +// +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. +// +//------------------------------------------------------------------------------ + +namespace AnotherMusicPlayer.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/AnotherMusicPlayer/Properties/Settings.settings b/AnotherMusicPlayer/Properties/Settings.settings new file mode 100644 index 0000000..049245f --- /dev/null +++ b/AnotherMusicPlayer/Properties/Settings.settings @@ -0,0 +1,6 @@ + + + + + + diff --git a/Installer-common.iss b/Installer-AnyCPU.iss similarity index 53% rename from Installer-common.iss rename to Installer-AnyCPU.iss index e872d5d..8f72f4c 100644 --- a/Installer-common.iss +++ b/Installer-AnyCPU.iss @@ -1,12 +1,13 @@ +#define BuildVersion "AnyCPU" ; Define Compiled version +#define MyAppVersion GetFileVersion('.\Release\AnyCPU\AnotherMusicPlayer.exe'); Warning: build version defined in path #define MyAppName "Another Music Player" #define MyAppPublisher "LordKBX WorkShop" #define MyAppURL "https://github.com/LordKBX/Another-Music-Player" #define MyAppExeName "AnotherMusicPlayer" -#define RunTimeName "Install Runtime .NET CORE 3.1.3" #ifndef MyInstallerVersion -#define MyInstallerVersion "1.0.0" +#define MyInstallerVersion "1.0.0" #endif [Setup] @@ -36,8 +37,6 @@ Compression=lzma SolidCompression=yes ;WizardStyle=modern -#include "C:\Program Files (x86)\Inno Download Plugin\idp.iss" - [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" Name: "french"; MessagesFile: "compiler:Languages\French.isl" @@ -49,7 +48,6 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip [Files] Source: ".\Release\{#BuildVersion}\AnotherMusicPlayer.exe"; DestDir: "{app}"; Flags: ignoreversion Source: ".\Release\{#BuildVersion}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "unzip.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] @@ -57,43 +55,5 @@ Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon -[Run] -Filename: "{tmp}\setup-runtime.exe"; Parameters: "/install /quiet"; Flags: skipifdoesntexist shellexec waituntilterminated -Filename: "{tmp}\unzip.exe"; Parameters: "{tmp}\ffmpeg.zip -d {sd}\ProgramData\{#MyAppExeName}" -Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent - -[Code] -procedure InitializeWizard(); -begin - WizardForm.WelcomeLabel1.Visible := True; - WizardForm.WelcomeLabel2.Visible := True; - - if ('{#BuildVersion}' = 'X86') then - if not DirExists(ExpandConstant('{commonpf32}\dotnet\shared\Microsoft.NETCore.App\3.1.3')) then - idpAddFileSize('http://sd-36502.dedibox.fr/AnotherMusicPlayer/windowsdesktop-runtime-3.1.3-win-x86.exe',expandconstant('{tmp}\setup-runtime.exe'), 48625808) - ; - ; - - if ('{#BuildVersion}' = 'X64') then - if not DirExists(ExpandConstant('{commonpf64}\dotnet\shared\Microsoft.NETCore.App\3.1.3')) then - idpAddFileSize('http://sd-36502.dedibox.fr/AnotherMusicPlayer/windowsdesktop-runtime-3.1.3-win-x64.exe',expandconstant('{tmp}\setup-runtime.exe'), 54449000) - ; - ; - - // find relasese at https://www.videohelp.com/software/ffmpeg/old-versions - if not FileExists(ExpandConstant('{sd}\ProgramData\{#MyAppExeName}\ffmpeg.exe')) then - if ('{#BuildVersion}' = 'X86') then - idpAddFileSize('http://sd-36502.dedibox.fr/AnotherMusicPlayer/ffmpeg-win32-static.zip',expandconstant('{tmp}\ffmpeg.zip'), 20997449) - else - idpAddFileSize('http://sd-36502.dedibox.fr/AnotherMusicPlayer/ffmpeg-win64-static.zip',expandconstant('{tmp}\ffmpeg.zip'), 39247024) - ; - ; - idpDownloadAfter(wpReady); -end; - -procedure CurStepChanged(CurStep: TSetupStep); -begin - if CurStep=ssInstall then begin //Lets install those files that were downloaded for us - CreateDir(expandconstant('{sd}\ProgramData\{#MyAppExeName}')) - end; -end; \ No newline at end of file +;[Run] +;Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent diff --git a/Installer-x64.iss b/Installer-x64.iss deleted file mode 100644 index 2f0af5c..0000000 --- a/Installer-x64.iss +++ /dev/null @@ -1,6 +0,0 @@ - -#define BuildVersion "X64" ; Define Compiled version -#define MyAppVersion GetFileVersion('.\Release\X64\AnotherMusicPlayer.exe'); Warning: build version defined in path -#define MyRegKey "Dotnet_CLI_SharedHost_24.76.28628_x64" - -#include "./Installer-common.iss" diff --git a/Installer-x86.iss b/Installer-x86.iss deleted file mode 100644 index fc3fcc9..0000000 --- a/Installer-x86.iss +++ /dev/null @@ -1,6 +0,0 @@ - -#define BuildVersion "X86" ; Define Compiled version -#define MyAppVersion GetFileVersion('.\Release\X86\AnotherMusicPlayer.exe'); Warning: build version defined in path -#define MyRegKey "dotnet_runtime_24.76.28628_x86" - -#include "./Installer-common.iss" diff --git a/README.md b/README.md index 245686e..f52ea6e 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ ## English Documentation ### Abstract: -This is a personal project to create a Music player written with C# SDK .Net Core 3.1 +This is a personal project to create a Music player written with C# SDK .Net 6.0 **Functions:** * Playing Queue @@ -72,13 +72,13 @@ This is a personal project to create a Music player written with C# SDK .Net Cor |Name|Version| |:---:|:---:| -|![.Net Core](https://github.com/LordKBX/C-.Net-Core-Media-Player/blob/master/Captures/NET-Core-Logo.png?raw=true)|3.1.3 : [[X64]](https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-desktop-3.1.3-windows-x64-installer) - [[X86]](https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-desktop-3.1.3-windows-x86-installer)| +|![.Net 6.0](https://cdn.iconscout.com/icon/free/png-256/free-microsoft-dotnet-1175177.png?f=webp&w=48)|6.0 : [[X64]](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.417-windows-x64-installer) - [[X86]](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.417-windows-x86-installer)| --- ## Documentation Française ### Abstract: -Ceci est un projet personnel de création d'un lecteur de musique écrit en C# SDK .Net Core 3.1 +Ceci est un projet personnel de création d'un lecteur de musique écrit en C# SDK .Net Core 6.0 **Fonctions:** * Liste de lecture courrante @@ -95,4 +95,4 @@ Ceci est un projet personnel de création d'un lecteur de musique écrit en C# S |Nom|Version| |:---:|:---:| -|![.Net Core](https://github.com/LordKBX/C-.Net-Core-Media-Player/blob/master/Captures/NET-Core-Logo.png?raw=true)|3.1.3 : [[X64]](https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-desktop-3.1.3-windows-x64-installer) - [[X86]](https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-desktop-3.1.3-windows-x86-installer)| +|![.Net 6.0](https://cdn.iconscout.com/icon/free/png-256/free-microsoft-dotnet-1175177.png?f=webp&w=48)|6.0 : [[X64]](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.417-windows-x64-installer) - [[X86]](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.417-windows-x86-installer)| diff --git a/publish.ps1 b/publish.ps1 index e21482e..6723f31 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -30,8 +30,6 @@ else { $InstallerVersion = $confirmation.ToString().Trim() } "Compiling" - dotnet publish D:\CODES\VS\MediaPlayer -p:PublishProfile=Win-X64 - dotnet publish D:\CODES\VS\MediaPlayer -p:PublishProfile=Win-X86 - cmd /C "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" D:\CODES\VS\MediaPlayer\Installer-x64.iss /DMyInstallerVersion=$InstallerVersion - cmd /C "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" D:\CODES\VS\MediaPlayer\Installer-x86.iss /DMyInstallerVersion=$InstallerVersion + dotnet publish D:\CODES\VS\MediaPlayer -p:PublishProfile=AnyCPU + cmd /C "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" D:\CODES\VS\MediaPlayer\Installer-AnyCPU.iss /DMyInstallerVersion=$InstallerVersion } \ No newline at end of file