diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/App.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/App.xaml.cs
index bf58881..d77520a 100644
--- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/App.xaml.cs
+++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/App.xaml.cs
@@ -6,6 +6,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
+using FRESHMusicPlayer.Handlers;
namespace FRESHMusicPlayer
{
@@ -23,11 +24,15 @@ namespace FRESHMusicPlayer
private Player player;
void App_Startup(object sender, StartupEventArgs e )
{
+ LoggingHandler.Log("Handling configuration...");
+
Config = ConfigurationHandler.Read();
player = new Player { Volume = Config.Volume };
if (Config.Language != "automatic") System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Config.Language);
ChangeSkin(Config.Theme);
+ LoggingHandler.Log("Handling command line args...");
+
if (e.Args.Length > 0)
{
var args = e.Args.Where(x => x.Contains('.'));
diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/FRESHMusicPlayer.csproj b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/FRESHMusicPlayer.csproj
index 01db482..691e40f 100644
--- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/FRESHMusicPlayer.csproj
+++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/FRESHMusicPlayer.csproj
@@ -125,6 +125,7 @@
+
diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Handlers/LoggingHandler.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Handlers/LoggingHandler.cs
new file mode 100644
index 0000000..eaefb36
--- /dev/null
+++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Handlers/LoggingHandler.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace FRESHMusicPlayer.Handlers
+{
+ public class LoggingHandler
+ {
+ [Conditional("DEBUG")]
+ public static void Log(string message)
+ {
+#if DEBUG
+ var line = $"[{DateTime.Now:T}] {message}";
+ Console.WriteLine(line);
+ Console.ResetColor();
+ var logFilePath = "log.txt";
+ using (var sw = File.AppendText(logFilePath))
+ {
+ sw.WriteLine(line);
+ }
+#endif
+ }
+ }
+}
diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/MainWindow.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/MainWindow.xaml.cs
index 5b80c46..210b794 100644
--- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/MainWindow.xaml.cs
+++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/MainWindow.xaml.cs
@@ -66,6 +66,7 @@ namespace FRESHMusicPlayer
private IPlaybackIntegration discordIntegration;
public MainWindow(Player player, string[] initialFile = null)
{
+ LoggingHandler.Log("Starting main window...");
Player = player;
InitializeComponent();
Player.SongChanged += Player_SongChanged;
@@ -77,6 +78,7 @@ namespace FRESHMusicPlayer
Interval = 1000
};
progressTimer.Tick += ProgressTimer_Tick;
+ LoggingHandler.Log("Reading library...");
LiteDatabase library;
try
{
@@ -111,7 +113,8 @@ namespace FRESHMusicPlayer
TracksTab.Visibility = ArtistsTab.Visibility = AlbumsTab.Visibility = PlaylistsTab.Visibility = Visibility.Collapsed;
SearchButton.Visibility = QueueManagementButton.Visibility = Visibility.Collapsed;
}
-
+ LoggingHandler.Log("Ready to go!");
+
if (initialFile != null)
{
Player.Queue.Add(initialFile);
@@ -203,6 +206,7 @@ namespace FRESHMusicPlayer
}
public void ShowAuxilliaryPane(AuxiliaryPane pane, int width = 235, bool openleft = false)
{
+ LoggingHandler.Log($"Showing pane --> {pane}");
if (SelectedAuxiliaryPane == pane)
{
HideAuxilliaryPane();
@@ -350,9 +354,10 @@ namespace FRESHMusicPlayer
discordIntegration?.Update(CurrentTrack, status);
}
}
- #region Tabs
private void ChangeTabs(Menu tab, string search = null)
{
+ LoggingHandler.Log($"Changing tabs -> {tab}");
+
SelectedMenu = tab;
TextBlock tabLabel;
switch (SelectedMenu)
@@ -388,9 +393,6 @@ namespace FRESHMusicPlayer
}
#endregion
-
- #endregion
-
#region Events
#region Player
private void Player_SongStopped(object sender, EventArgs e)
@@ -401,6 +403,8 @@ namespace FRESHMusicPlayer
CoverArtBox.Source = null;
SetIntegrations(PlaybackStatus.Stopped);
SetCoverArtVisibility(false);
+
+ LoggingHandler.Log("Stopping!");
}
private void Player_SongChanged(object sender, EventArgs e)
@@ -439,6 +443,8 @@ namespace FRESHMusicPlayer
PlayPauseMethod();
PauseAfterCurrentTrack = false;
}
+
+ LoggingHandler.Log("Changing tracks");
}
private void Player_SongException(object sender, PlaybackExceptionEventArgs e)
{
diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/LibraryPage.xaml b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/LibraryPage.xaml
index f94a6dc..a218ebc 100644
--- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/LibraryPage.xaml
+++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/LibraryPage.xaml
@@ -7,11 +7,11 @@
xmlns:local="clr-namespace:FRESHMusicPlayer.Pages.Library"
mc:Ignorable="d"
d:DesignHeight="372" d:DesignWidth="694"
- Title="LibraryPage" Unloaded="Page_Unloaded" DragEnter="Page_DragEnter" Drop="Page_Drop" AllowDrop="True">
+ Title="LibraryPage" Unloaded="Page_Unloaded" DragEnter="Page_DragEnter" Drop="Page_Drop" AllowDrop="True" Loaded="Page_Loaded">
-
+
@@ -35,15 +35,35 @@
/>
-
+
-
-
-
+
+
+
+
+
+
+
diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/LibraryPage.xaml.cs b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/LibraryPage.xaml.cs
index 5e3f03f..5649ac4 100644
--- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/LibraryPage.xaml.cs
+++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/LibraryPage.xaml.cs
@@ -16,8 +16,6 @@ namespace FRESHMusicPlayer.Pages.Library
///
public partial class LibraryPage : Page
{
- private Menu previousPage;
-
private readonly MainWindow window;
public LibraryPage(MainWindow window, string search = null)
{
@@ -32,7 +30,7 @@ namespace FRESHMusicPlayer.Pages.Library
}
}
- public void LoadLibrary()
+ public async void LoadLibrary() // TODO: figure out how to make this not async void
{
TracksPanel.Items.Clear();
CategoryPanel.Items.Clear();
@@ -40,20 +38,20 @@ namespace FRESHMusicPlayer.Pages.Library
switch (window.SelectedMenu) // all of this stuff is here so that i can avoid copying and pasting the same page thrice, maybe there's a better way?
{
case Menu.Tracks:
- ShowTracks();
+ await ShowTracks();
break;
case Menu.Artists:
- ShowArtists();
+ await ShowArtists();
break;
case Menu.Albums:
- ShowAlbums();
+ await ShowAlbums();
break;
case Menu.Playlists:
- ShowPlaylists();
+ await ShowPlaylists();
break;
}
}
- public async void ShowTracks()
+ public async Task ShowTracks()
{
LeftSide.Width = new GridLength(0);
int length = 0;
@@ -72,7 +70,7 @@ namespace FRESHMusicPlayer.Pages.Library
InfoLabel.Visibility = Visibility.Visible;
InfoLabel.Text = $@"{Properties.Resources.MAINWINDOW_TRACKS}: {TracksPanel.Items.Count} ・ {Math.Floor(lengthTimeSpan.TotalHours)}:{lengthTimeSpan:mm}:{lengthTimeSpan:ss}";
}
- public async void ShowArtists()
+ public async Task ShowArtists()
{
await Task.Run(() =>
{
@@ -83,7 +81,7 @@ namespace FRESHMusicPlayer.Pages.Library
}
});
}
- public async void ShowAlbums()
+ public async Task ShowAlbums()
{
await Task.Run(() =>
{
@@ -94,7 +92,7 @@ namespace FRESHMusicPlayer.Pages.Library
}
});
}
- public async void ShowPlaylists()
+ public async Task ShowPlaylists()
{
var x = window.Library.Database.GetCollection("playlists").Query().OrderBy("Name").ToList();
await Task.Run(() =>
@@ -107,7 +105,7 @@ namespace FRESHMusicPlayer.Pages.Library
}
});
}
- public async void ShowTracksforArtist(string selectedItem)
+ public async Task ShowTracksforArtist(string selectedItem)
{
TracksPanel.Items.Clear();
int length = 0;
@@ -122,7 +120,7 @@ namespace FRESHMusicPlayer.Pages.Library
InfoLabel.Visibility = Visibility.Visible;
InfoLabel.Text = $"{Properties.Resources.MAINWINDOW_TRACKS}: {TracksPanel.Items.Count} ・ {new TimeSpan(0, 0, 0, length):hh\\:mm\\:ss}";
}
- public async void ShowTracksforAlbum(string selectedItem)
+ public async Task ShowTracksforAlbum(string selectedItem)
{
TracksPanel.Items.Clear();
int length = 0;
@@ -137,7 +135,7 @@ namespace FRESHMusicPlayer.Pages.Library
InfoLabel.Visibility = Visibility.Visible;
InfoLabel.Text = $"{Properties.Resources.MAINWINDOW_TRACKS}: {TracksPanel.Items.Count} ・ {new TimeSpan(0, 0, 0, length):hh\\:mm\\:ss}";
}
- public async void ShowTracksforPlaylist(string selectedItem)
+ public async Task ShowTracksforPlaylist(string selectedItem)
{
TracksPanel.Items.Clear();
int length = 0;
@@ -152,24 +150,29 @@ namespace FRESHMusicPlayer.Pages.Library
InfoLabel.Visibility = Visibility.Visible;
InfoLabel.Text = $"{Properties.Resources.MAINWINDOW_TRACKS}: {TracksPanel.Items.Count} ・ {new TimeSpan(0, 0, 0, length):hh\\:mm\\:ss}";
}
- private void CategoryPanel_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ private async void CategoryPanel_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selectedItem = (string)CategoryPanel.SelectedItem;
if (selectedItem == null) return;
- if (window.SelectedMenu == Menu.Artists) ShowTracksforArtist(selectedItem);
- else if (window.SelectedMenu == Menu.Playlists) ShowTracksforPlaylist(selectedItem);
- else ShowTracksforAlbum(selectedItem);
+ if (window.SelectedMenu == Menu.Artists) await ShowTracksforArtist(selectedItem);
+ else if (window.SelectedMenu == Menu.Playlists) await ShowTracksforPlaylist(selectedItem);
+ else await ShowTracksforAlbum(selectedItem);
}
- private void MainWindow_TabChanged(object sender, string e)
+ //private void MainWindow_TabChanged(object sender, string e)
+ //{
+ // if (previousPage == Menu.Tracks) LeftSide.Width = new GridLength(222);
+ // LoadLibrary();
+ // if (e != null)
+ // {
+ // Thread.Sleep(10);
+ // CategoryPanel.SelectedItem = e;
+ // }
+ // previousPage = window.SelectedMenu;
+ //}
+
+ private void Page_Loaded(object sender, RoutedEventArgs e)
{
- if (previousPage == Menu.Tracks) LeftSide.Width = new GridLength(222);
- LoadLibrary();
- if (e != null)
- {
- Thread.Sleep(10);
- CategoryPanel.SelectedItem = e;
- }
- previousPage = window.SelectedMenu;
+
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
@@ -207,5 +210,7 @@ namespace FRESHMusicPlayer.Pages.Library
window.Player.Queue.Add(tracks);
window.Player.PlayMusic();
}
+
+
}
}
diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/SearchPage.xaml b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/SearchPage.xaml
index d911914..8df2554 100644
--- a/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/SearchPage.xaml
+++ b/FRESHMusicPlayer/FRESHMusicPlayer-WPF-UI-Test/Pages/Library/SearchPage.xaml
@@ -25,7 +25,7 @@
-