Skip to content

Commit

Permalink
TargetFramework changed to net 6.0
Browse files Browse the repository at this point in the history
Debug Library context menu
Remove Debug Button in releases
  • Loading branch information
LordKBX committed Nov 27, 2023
1 parent 6485429 commit 4951d34
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 167 deletions.
17 changes: 13 additions & 4 deletions AnotherMusicPlayer/AnotherMusicPlayer.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<UseWPF>true</UseWPF>
<Authors>LordKBX</Authors>
<Company>LordKBX Workshop</Company>
<Product>Another Music Player</Product>
<PackageId>AnotherMusicPlayer</PackageId>
<AssemblyName>AnotherMusicPlayer</AssemblyName>
<RootNamespace>AnotherMusicPlayer</RootNamespace>
<Version>0.1.7.3</Version>
<Version>0.1.7.4</Version>
<Copyright>LordKBX Workshop 2022</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>https://github.com/LordKBX/Another-Music-Player</RepositoryUrl>
Expand All @@ -20,10 +20,10 @@
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<ApplicationIcon>icons\icon_large.ico</ApplicationIcon>
<Configurations>Debug;Release</Configurations>
<AssemblyVersion>0.1.7.3</AssemblyVersion>
<FileVersion>0.1.7.3</FileVersion>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<NeutralLanguage>en</NeutralLanguage>
<SignAssembly>False</SignAssembly>
<DelaySign>False</DelaySign>
</PropertyGroup>
<ItemGroup>
<None Remove="icons\icon_large.ico" />
Expand Down Expand Up @@ -70,6 +70,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
Expand Down Expand Up @@ -186,6 +191,10 @@
<None Update="ffmpeg.exe">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Page Update="Styles\Dark.xaml">
Expand Down
2 changes: 2 additions & 0 deletions AnotherMusicPlayer/Commons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ public partial class MainWindow : Window
public static string BaseDir = AppDomain.CurrentDomain.BaseDirectory + SeparatorChar;
/// <summary> Base Diractory of the icon folder </summary>
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";
}
Expand Down
129 changes: 74 additions & 55 deletions AnotherMusicPlayer/Library/ContextMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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<string> files = new List<string>();
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<string> files = new List<string>();
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

Expand Down Expand Up @@ -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
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions AnotherMusicPlayer/Library/Library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
58 changes: 33 additions & 25 deletions AnotherMusicPlayer/Library/LibraryPathNavigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Media;
using System.Diagnostics;
using Newtonsoft.Json;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;

namespace AnotherMusicPlayer
{
Expand Down Expand Up @@ -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)
Expand All @@ -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);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 1 addition & 3 deletions AnotherMusicPlayer/MainWindow/Events/EventsButtons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ private void BtnRepeat_Click(object sender, RoutedEventArgs e)
/// <summary> Callback Event Click on Debug Export Vars </summary>
private void Debug_Button_Click(object sender, RoutedEventArgs e)
{
/*
setMetadataScanningState(false);
JsonSerializerSettings jss = new JsonSerializerSettings();
jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
Expand All @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion AnotherMusicPlayer/MainWindow/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
<TreeView x:Name="PlaylistsTree" Grid.Row="1" Margin="1,0,0,2"
Style="{DynamicResource PlaylistsTreeStyle}"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.CanContentScroll="False" ContextMenuService.IsEnabled="True">
ScrollViewer.CanContentScroll="False" ContextMenuService.IsEnabled="True" HorizontalAlignment="Stretch">
<TreeViewItem x:Name="PlaylistsTreeAuto" Header="{DynamicResource PlayListsAuto}"
IsExpanded="True" BorderBrush="{DynamicResource BorderColor}">
<TreeViewItem Header="BB"></TreeViewItem>
Expand Down
Loading

0 comments on commit 4951d34

Please sign in to comment.