From fdfadea7feacdf7ef2f2c2b088775b7dca0a8a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Climent?= Date: Sun, 19 May 2024 14:44:50 +0200 Subject: [PATCH] Minor improvements --- src/UniGetUI/Interface/MainWindow.xaml.cs | 16 +++++++++++----- .../SoftwarePages/AbstractPackagesPage.xaml | 4 ++-- .../Interface/SoftwarePages/PackageBundle.xaml | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/UniGetUI/Interface/MainWindow.xaml.cs b/src/UniGetUI/Interface/MainWindow.xaml.cs index 6c26c492a..7a491ca9b 100644 --- a/src/UniGetUI/Interface/MainWindow.xaml.cs +++ b/src/UniGetUI/Interface/MainWindow.xaml.cs @@ -39,7 +39,7 @@ IntPtr GetForWindow([System.Runtime.InteropServices.In] IntPtr appWindow, void ShowShareUIForWindow(IntPtr appWindow); } - TaskbarIcon TrayIcon; + TaskbarIcon? TrayIcon; private bool RecentlyActivated = false; static readonly Guid _dtm_iid = @@ -55,6 +55,7 @@ IntPtr GetForWindow([System.Runtime.InteropServices.In] IntPtr appWindow, public List DialogQueue = new(); public List NavButtonList = new(); +#pragma warning disable CS8618 public MainWindow() { InitializeComponent(); @@ -76,7 +77,7 @@ public MainWindow() LoadingSthDalog.Title = CoreTools.Translate("Please wait"); LoadingSthDalog.Content = new ProgressBar() { IsIndeterminate = true, Width = 300 }; } - +#pragma warning restore CS8618 public void HandleNotificationActivation(ToastArguments args, ValueSet input) { if (args.Contains("action") && args["action"] == "updateAll") @@ -275,14 +276,19 @@ public void UpdateSystemTrayStatus() else tooltip = CoreTools.Translate("{0} updates are available").Replace("{0}", MainApp.Instance.TooltipStatus.AvailableUpdates.ToString()) + " - " + Title; } + if(TrayIcon == null) + { + Logger.Warn("Attempting to update a null taskbar icon tray, aborting!"); + return; + } TrayIcon.ToolTipText = tooltip; ApplicationTheme theme = ApplicationTheme.Light; string RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; string RegistryValueName = "SystemUsesLightTheme"; - RegistryKey key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath); - object registryValueObject = key?.GetValue(RegistryValueName); + RegistryKey? key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath); + object? registryValueObject = key?.GetValue(RegistryValueName) ?? null; if (registryValueObject != null) { int registryValue = (int)registryValueObject; @@ -294,7 +300,7 @@ public void UpdateSystemTrayStatus() modifier += "_white"; - string FullIconPath = Path.Join(Directory.GetParent(Assembly.GetEntryAssembly().Location).ToString(), "\\Assets\\Images\\tray" + modifier + ".ico"); + string FullIconPath = Path.Join(CoreData.UniGetUIExecutableDirectory, "\\Assets\\Images\\tray" + modifier + ".ico"); TrayIcon.SetValue(TaskbarIcon.IconSourceProperty, new BitmapImage() { UriSource = new Uri(FullIconPath) }); } diff --git a/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml b/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml index 6aa942d13..4a0aff0eb 100644 --- a/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml +++ b/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml @@ -635,7 +635,7 @@ VerticalContentAlignment="Center" />