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 @@ /> - + - -