diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/FRESHMusicPlayer-Avalonia.csproj b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/FRESHMusicPlayer-Avalonia.csproj index c36154a..395e187 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/FRESHMusicPlayer-Avalonia.csproj +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/FRESHMusicPlayer-Avalonia.csproj @@ -32,6 +32,19 @@ + + + True + True + Resources.resx + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + PreserveNewest diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Program.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Program.cs index 433fb8b..a2734b8 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Program.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Program.cs @@ -2,20 +2,27 @@ using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.ReactiveUI; using FRESHMusicPlayer; +using FRESHMusicPlayer.Handlers.Configuration; using FRESHMusicPlayer.Utilities; using FRESHMusicPlayer.ViewModels; using System; using System.IO; +using System.Threading.Tasks; -namespace FRESHMusicPlayer_Avalonia +namespace FRESHMusicPlayer { - class Program + public class Program { + public static ConfigurationFile Config; + // Initialization code. Don't use any Avalonia, third-party APIs or any // SynchronizationContext-reliant code before AppMain is called: things aren't initialized // yet and stuff might break. - public static void Main(string[] args) + public static async Task Main(string[] args) { + Config = await ConfigurationHandler.Read(); + if (Config.Language != "automatic") System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Config.Language); + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Properties/Resources.Designer.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Properties/Resources.Designer.cs new file mode 100644 index 0000000..7fa4b9b --- /dev/null +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Properties/Resources.Designer.cs @@ -0,0 +1,189 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FRESHMusicPlayer.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FRESHMusicPlayer.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Import Folders. + /// + public static string ImportFolders { + get { + return ResourceManager.GetString("ImportFolders", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Import Playlist Files. + /// + public static string ImportPlaylistFiles { + get { + return ResourceManager.GetString("ImportPlaylistFiles", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Import Tracks. + /// + public static string ImportTracks { + get { + return ResourceManager.GetString("ImportTracks", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to About. + /// + public static string Menu_About { + get { + return ResourceManager.GetString("Menu_About", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to About FRESHMusicPlayer. + /// + public static string Menu_About_AboutFMP { + get { + return ResourceManager.GetString("Menu_About_AboutFMP", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to File. + /// + public static string Menu_File { + get { + return ResourceManager.GetString("Menu_File", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Playback. + /// + public static string Menu_Playback { + get { + return ResourceManager.GetString("Menu_Playback", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Next. + /// + public static string Menu_Playback_Next { + get { + return ResourceManager.GetString("Menu_Playback_Next", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Pause after current track. + /// + public static string Menu_Playback_PauseAfterCurrentTrack { + get { + return ResourceManager.GetString("Menu_Playback_PauseAfterCurrentTrack", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Play/Pause. + /// + public static string Menu_Playback_PlayPause { + get { + return ResourceManager.GetString("Menu_Playback_PlayPause", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Previous. + /// + public static string Menu_Playback_Previous { + get { + return ResourceManager.GetString("Menu_Playback_Previous", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Repeat. + /// + public static string Menu_Playback_Repeat { + get { + return ResourceManager.GetString("Menu_Playback_Repeat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shuffle. + /// + public static string Menu_Playback_Shuffle { + get { + return ResourceManager.GetString("Menu_Playback_Shuffle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Open.... + /// + public static string OpenDialog { + get { + return ResourceManager.GetString("OpenDialog", resourceCulture); + } + } + } +} diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Properties/Resources.resx b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Properties/Resources.resx new file mode 100644 index 0000000..3c4968a --- /dev/null +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Properties/Resources.resx @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Import Folders + + + Import Playlist Files + + + Import Tracks + + + About + + + About FRESHMusicPlayer + + + File + + + Playback + + + Next + + + Pause after current track + + + Play/Pause + + + Previous + + + Repeat + + + Shuffle + + + Open... + + \ No newline at end of file diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs index 6e57ecb..08e3b3c 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/ViewModels/MainWindowViewModel.cs @@ -337,7 +337,7 @@ namespace FRESHMusicPlayer.ViewModels Player.SongException += Player_SongException; ProgressTimer.Elapsed += ProgressTimer_Elapsed; // TODO: put this in a more logical place LoggingHandler.Log("Handling config..."); - Config = await ConfigurationHandler.Read(); + Config = Program.Config; // HACK: this is a hack Volume = Config?.Volume ?? 1f; LoggingHandler.Log("Handling command line args..."); diff --git a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml index 93b1778..195c7c4 100644 --- a/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml +++ b/FRESHMusicPlayer/FRESHMusicPlayer-Avalonia/Views/MainWindow.axaml @@ -3,6 +3,7 @@ xmlns:vm="using:FRESHMusicPlayer.ViewModels" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:resx ="clr-namespace:FRESHMusicPlayer.Properties" xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" Width="800" Height="540" @@ -53,29 +54,29 @@ - + - + - - - + + + - + - - - + + + - - + + - + - + @@ -363,9 +364,9 @@ - +