From 0471ba88c182802030897029f39ad1cb12ad8a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Sat, 5 Nov 2022 01:05:46 +0100 Subject: [PATCH 1/8] Cover images working in all cases --- Handlers/MPDHandler.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Handlers/MPDHandler.cs b/Handlers/MPDHandler.cs index 744e055..589ddf8 100644 --- a/Handlers/MPDHandler.cs +++ b/Handlers/MPDHandler.cs @@ -46,7 +46,7 @@ namespace unison private MpdStatus _currentStatus; private IMpdFile _currentSong; - private BitmapFrame _cover; + private BitmapImage _cover; public Statistics _stats; private readonly System.Timers.Timer _elapsedTimer; private DispatcherTimer _retryTimer; @@ -474,14 +474,12 @@ namespace unison else { using MemoryStream stream = new MemoryStream(data.ToArray()); - try - { - _cover = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); - } - catch - { - _cover = null; - } + _cover = new BitmapImage(); + _cover.BeginInit(); + _cover.CacheOption = BitmapCacheOption.OnLoad; + _cover.StreamSource = stream; + _cover.EndInit(); + _cover.Freeze(); } UpdateCover(); } @@ -523,7 +521,7 @@ namespace unison public IMpdFile GetCurrentSong() => _currentSong; public MpdStatus GetStatus() => _currentStatus; - public BitmapFrame GetCover() => _cover; + public BitmapImage GetCover() => _cover; public string GetVersion() => _version; public Statistics GetStats() => _stats; public double GetCurrentTime() => _currentTime; From 529754934d9335d4df8fba1f9afa05390786d512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Sun, 6 Nov 2022 00:41:13 +0100 Subject: [PATCH 2/8] Installer file --- Installer/unison.iss | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Installer/unison.iss diff --git a/Installer/unison.iss b/Installer/unison.iss new file mode 100644 index 0000000..88b793f --- /dev/null +++ b/Installer/unison.iss @@ -0,0 +1,43 @@ +#define Name "unison" +#define Version "1.3.1" +#define Snapcast "snapclient_0.26.0-1_win64" +#define Publisher "Tho Marchal" +#define URL "https://github.com/ZetaKebab/unison" +#define ExeName "unison.exe" + +[Setup] +AppName={#Name} +AppVersion={#Version} +AppVerName={#Name} v{#Version} +AppPublisher={#Publisher} +AppPublisherURL={#URL} +AppSupportURL={#URL} +AppUpdatesURL={#URL} +DefaultDirName={autopf}\{#Name} +DisableProgramGroupPage=yes +ArchitecturesInstallIn64BitMode=x64 +OutputBaseFilename="{#Name}-v{#Version}-setup" +OutputDir=..\publish\installer +SetupIconFile=..\Resources\icon-full.ico +UninstallDisplayIcon = "{app}\{#Name}.exe" +Compression=lzma +SolidCompression=yes +WizardStyle=modern + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" +Name: "french"; MessagesFile: "compiler:Languages\French.isl" +Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" + +[Files] +Source: "..\publish\{#ExeName}"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\publish\LICENSE"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\publish\unison.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\publish\{#Snapcast}\*"; DestDir: "{app}\{#Snapcast}"; Flags: ignoreversion recursesubdirs createallsubdirs + +[Icons] +Name: "{group}\{#Name}"; Filename: "{app}\{#ExeName}" + +[Run] +Filename: "{app}\{#Name}.exe"; Parameters: "-frominstaller"; Flags: nowait postinstall skipifsilent + From ccbb4525f3528c5d9cecb28b10d55c2722fee306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Sun, 6 Nov 2022 15:44:53 +0100 Subject: [PATCH 3/8] Update system implemented --- App.xaml.cs | 12 ++++--- Handlers/UpdateHandler.cs | 49 +++++++++++++++++++++++++++++ Installer/unison.xml | 7 +++++ Resources/Resources.Designer.cs | 56 ++++++++++++++++++++++++++++++++- Resources/Resources.es-ES.resx | 22 +++++++++++-- Resources/Resources.fr-FR.resx | 22 +++++++++++-- Resources/Resources.resx | 22 +++++++++++-- Views/MainWindow.xaml.cs | 5 +++ Views/Settings.xaml | 11 +++++-- Views/Settings.xaml.cs | 23 ++++++++++++-- unison.csproj | 1 + 11 files changed, 214 insertions(+), 16 deletions(-) create mode 100644 Handlers/UpdateHandler.cs create mode 100644 Installer/unison.xml diff --git a/App.xaml.cs b/App.xaml.cs index 49a5de9..e4c5760 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,6 +1,6 @@ -using System.Globalization; -using System.Windows; +using System.Windows; using Hardcodet.Wpf.TaskbarNotification; +using unison.Handlers; namespace unison { @@ -10,12 +10,13 @@ namespace unison private HotkeyHandler _hotkeys; private SnapcastHandler _snapcast; private MPDHandler _mpd; + private UpdateHandler _updater; protected override void OnStartup(StartupEventArgs e) { //debug language - //unison.Resources.Resources.Culture = CultureInfo.GetCultureInfo("fr-FR"); - //unison.Resources.Resources.Culture = CultureInfo.GetCultureInfo("es-ES"); + //unison.Resources.Resources.Culture = System.Globalization.CultureInfo.GetCultureInfo("fr-FR"); + //unison.Resources.Resources.Culture = System.Globalization.CultureInfo.GetCultureInfo("es-ES"); base.OnStartup(e); @@ -29,6 +30,9 @@ namespace unison _snapcast = new SnapcastHandler(); Current.Properties["snapcast"] = _snapcast; + _updater = new UpdateHandler(); + Current.Properties["updater"] = _updater; + Current.MainWindow = new MainWindow(); _systray = (TaskbarIcon)FindResource("SystrayTaskbar"); diff --git a/Handlers/UpdateHandler.cs b/Handlers/UpdateHandler.cs new file mode 100644 index 0000000..2afc0d3 --- /dev/null +++ b/Handlers/UpdateHandler.cs @@ -0,0 +1,49 @@ +using System.Windows; +using AutoUpdaterDotNET; + +namespace unison.Handlers +{ + internal class UpdateHandler + { + readonly string xmlFile = "https://raw.githubusercontent.com/ZetaKebab/unison/main/Installer/unison.xml"; + + private bool _UpdateAvailable = false; + public bool UpdateAvailable() => _UpdateAvailable; + + public UpdateHandler() + { + AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent; + Start(); + } + + public void Start() + { + AutoUpdater.Start(xmlFile); + } + + private string CutVersionNumber(string number) + { + return number.Substring(0, number.LastIndexOf(".")); + } + + private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) + { + if (args.Error == null) + { + if (args.IsUpdateAvailable) + { + _UpdateAvailable = true; + string number = CutVersionNumber(args.CurrentVersion); + + MainWindow MainWin = (MainWindow)Application.Current.MainWindow; + MainWin.UpdateUpdateStatus(number); + + MessageBoxResult Result = MessageBox.Show($"{unison.Resources.Resources.Update_Message1} {number}.\n{unison.Resources.Resources.Update_Message2}", + "unison", MessageBoxButton.YesNo, MessageBoxImage.Information); + if (Result == MessageBoxResult.Yes) + AutoUpdater.DownloadUpdate(args); + } + } + } + } +} diff --git a/Installer/unison.xml b/Installer/unison.xml new file mode 100644 index 0000000..6d68f3d --- /dev/null +++ b/Installer/unison.xml @@ -0,0 +1,7 @@ + + + 1.3.1.0 + https://github.com/ZetaKebab/unison/releases/download/v1.3.1/unison-v1.3.1.zip + https://raw.githubusercontent.com/ZetaKebab/unison/main/CHANGELOG.md + false + \ No newline at end of file diff --git a/Resources/Resources.Designer.cs b/Resources/Resources.Designer.cs index 16667a1..a6d5258 100644 --- a/Resources/Resources.Designer.cs +++ b/Resources/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace unison.Resources { // 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.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -617,5 +617,59 @@ namespace unison.Resources { return ResourceManager.GetString("StopSnapcast", resourceCulture); } } + + /// + /// Looks up a localized string similar to Check for updates. + /// + public static string Update_ButtonCheck { + get { + return ResourceManager.GetString("Update_ButtonCheck", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Start update. + /// + public static string Update_ButtonStart { + get { + return ResourceManager.GetString("Update_ButtonStart", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Update available! New version is. + /// + public static string Update_Message1 { + get { + return ResourceManager.GetString("Update_Message1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Install now?. + /// + public static string Update_Message2 { + get { + return ResourceManager.GetString("Update_Message2", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New version. + /// + public static string Update_String1 { + get { + return ResourceManager.GetString("Update_String1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to available!. + /// + public static string Update_String2 { + get { + return ResourceManager.GetString("Update_String2", resourceCulture); + } + } } } diff --git a/Resources/Resources.es-ES.resx b/Resources/Resources.es-ES.resx index 8318afa..e5d17e0 100644 --- a/Resources/Resources.es-ES.resx +++ b/Resources/Resources.es-ES.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Salir @@ -303,4 +303,22 @@ Parar Snapcast + + Buscar actualización + + + Actualizar + + + ¡Actualización disponible! La nueva versión es la + + + ¿Instalar ahora? + + + ¡Nueva versión + + + disponible! + \ No newline at end of file diff --git a/Resources/Resources.fr-FR.resx b/Resources/Resources.fr-FR.resx index 8991b56..fe71680 100644 --- a/Resources/Resources.fr-FR.resx +++ b/Resources/Resources.fr-FR.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Quitter @@ -303,4 +303,22 @@ Stopper Snapcast + + Chercher une mise à jour + + + Mettre à jour + + + Mise à jour disponible ! La nouvelle version est la + + + Installer maintenant ? + + + Nouvelle version + + + disponible ! + \ No newline at end of file diff --git a/Resources/Resources.resx b/Resources/Resources.resx index 50e7710..affe785 100644 --- a/Resources/Resources.resx +++ b/Resources/Resources.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Exit @@ -303,4 +303,22 @@ Stop Snapcast + + Check for updates + + + Start update + + + Update available! New version is + + + Install now? + + + New version + + + available! + \ No newline at end of file diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index 2bbd176..5309caf 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -271,6 +271,11 @@ namespace unison slider.ToolTip = (int)slider.Value; } + public void UpdateUpdateStatus(string version) + { + _settingsWin.UpdateUpdateStatus(version); + } + protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); diff --git a/Views/Settings.xaml b/Views/Settings.xaml index 5c5b46c..5c7be83 100644 --- a/Views/Settings.xaml +++ b/Views/Settings.xaml @@ -229,16 +229,23 @@ - + + + + + +