diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-100.png b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-100.png deleted file mode 100644 index adcd8d708a..0000000000 Binary files a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-100.png and /dev/null differ diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-125.png b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-125.png deleted file mode 100644 index 4ff1604ac8..0000000000 Binary files a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-125.png and /dev/null differ diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-150.png b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-150.png deleted file mode 100644 index e46ae0acdb..0000000000 Binary files a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-150.png and /dev/null differ diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-200.png b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-200.png deleted file mode 100644 index a585ff9ad6..0000000000 Binary files a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-200.png and /dev/null differ diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-400.png b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-400.png deleted file mode 100644 index 612c354231..0000000000 Binary files a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/AppList.scale-400.png and /dev/null differ diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/Hosts.ico b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/Hosts.ico deleted file mode 100644 index d3fcce766e..0000000000 Binary files a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/Hosts/Hosts.ico and /dev/null differ diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/ShortcutGuide/ShortcutGuide.ico b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/ShortcutGuide/ShortcutGuide.ico new file mode 100644 index 0000000000..eb90c1450f Binary files /dev/null and b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Assets/ShortcutGuide/ShortcutGuide.ico differ diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutEntry.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutEntry.cs index 3f46852107..66528c019d 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutEntry.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutEntry.cs @@ -62,13 +62,19 @@ namespace ShortcutGuide.Models async void AnimateTextBlock(TextBlock animatedTextBlock, string text, int delay = 500) { - int index = 0; - - while (true) + try + { + int index = 0; + + while (!ShortcutView.AnimationCancellationTokenSource.Token.IsCancellationRequested) + { + animatedTextBlock.Text = text[index].ToString(); + index = (index + 1) % text.Length; + await Task.Delay(delay); + } + } + catch { - animatedTextBlock.Text = text[index].ToString(); - index = (index + 1) % text.Length; - await Task.Delay(delay); } } @@ -254,7 +260,7 @@ namespace ShortcutGuide.Models async void AnimateStackPanels(StackPanel[] panels, int delay = 2000) { int index = 0; - while (true) + while (!ShortcutView.AnimationCancellationTokenSource.Token.IsCancellationRequested) { foreach (StackPanel panel in panels) { diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Package.appxmanifest b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Package.appxmanifest deleted file mode 100644 index 5d8b7d8069..0000000000 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Package.appxmanifest +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - ShortcutGuide.Ui - aaron - Assets\StoreLogo.png - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Program.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Program.cs index c381cedcdc..7670fc8145 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Program.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Program.cs @@ -8,6 +8,7 @@ using System.IO; using System.Threading; using ManagedCommon; using Microsoft.UI.Dispatching; +using Microsoft.UI.Xaml; using Microsoft.Windows.AppLifecycle; using ShortcutGuide.Helpers; @@ -25,6 +26,12 @@ namespace ShortcutGuide [STAThread] public static void Main() { + if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredShortcutGuideEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled) + { + Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator."); + return; + } + if (!Directory.Exists(ManifestInterpreter.GetPathOfIntepretations())) { Directory.CreateDirectory(ManifestInterpreter.GetPathOfIntepretations()); @@ -43,17 +50,11 @@ namespace ShortcutGuide Logger.InitializeLogger("\\ShortcutGuide\\Logs"); WinRT.ComWrappersSupport.InitializeComWrappers(); - if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredShortcutGuideEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled) - { - Logger.LogWarning("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator."); - return; - } - var instanceKey = AppInstance.FindOrRegisterForKey("PowerToys_ShortcutGuide_Instance"); if (instanceKey.IsCurrent) { - Microsoft.UI.Xaml.Application.Start((p) => + Application.Start((p) => { var context = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread()); SynchronizationContext.SetSynchronizationContext(context); @@ -65,6 +66,9 @@ namespace ShortcutGuide Logger.LogWarning("Another instance of ShortcutGuide is running. Exiting ShortcutGuide"); } + // Something prevents the process from exiting, so we need to kill it manually. + Process.GetCurrentProcess().Kill(); + return; } } diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuide.Ui.csproj b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuide.Ui.csproj index 911ac0502f..0fd7e74638 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuide.Ui.csproj +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuide.Ui.csproj @@ -17,7 +17,7 @@ ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps PowerToys.ShortcutGuide DISABLE_XAML_GENERATED_MAIN,TRACE - Assets/Hosts/Hosts.ico + Assets\ShortcutGuide\ShortcutGuide.ico PowerToys.ShortcutGuide.pri @@ -28,14 +28,10 @@ + - - - - - PreserveNewest @@ -46,7 +42,7 @@ - + @@ -72,10 +68,6 @@ - - - - PowerToys.GPOWrapper diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/App.xaml.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/App.xaml.cs index 8813aa5b35..84a79446eb 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/App.xaml.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/App.xaml.cs @@ -17,6 +17,11 @@ namespace ShortcutGuide { _window = new MainWindow(); _window.Activate(); + _window.Closed += (s, e) => + { + _window = null; + Current.Exit(); + }; } private Window? _window; diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs index 4c23428c73..fe7b930c26 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Text.Json; +using System.Threading.Tasks; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.UI; using Microsoft.UI.Windowing; @@ -79,7 +80,7 @@ namespace ShortcutGuide if (e.WindowActivationState == WindowActivationState.Deactivated) { #if !DEBUG - Environment.Exit(0); + Close(); #endif } @@ -153,7 +154,8 @@ namespace ShortcutGuide public void CloseButton_Clicked(object sender, RoutedEventArgs e) { - Environment.Exit(0); + ShortcutView.AnimationCancellationTokenSource.Cancel(); + Close(); } private void SearchBox_TextChanged(object sender, TextChangedEventArgs e) diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs index 2a6d486aed..ade3bb62b0 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.IO; using System.Runtime.CompilerServices; using System.Text.Json; +using System.Threading; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; @@ -24,11 +25,13 @@ namespace ShortcutGuide { private readonly DispatcherTimer _taskbarUpdateTimer = new() { Interval = TimeSpan.FromMilliseconds(500) }; private readonly bool _showTaskbarShortcuts; + public static readonly CancellationTokenSource AnimationCancellationTokenSource = new(); private ShortcutFile shortcutList = ManifestInterpreter.GetShortcutsOfApplication(ShortcutPageParameters.CurrentPageName); public ShortcutView() { InitializeComponent(); + AnimationCancellationTokenSource.TryReset(); DataContext = this; int i = -1; @@ -91,6 +94,13 @@ namespace ShortcutGuide ErrorMessage.Visibility = Visibility.Visible; ErrorMessage.Text = Resource.ResourceManager.GetString("ErrorInAppParsing", CultureInfo.CurrentUICulture); } + + Unloaded += (s, e) => + { + AnimationCancellationTokenSource.Cancel(); + _taskbarUpdateTimer.Tick -= UpdateTaskbarIndicators; + _taskbarUpdateTimer.Stop(); + }; } private void UpdateTaskbarIndicators(object? sender, object? e) diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/app.manifest b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/app.manifest index a5aa870b41..f3ee9d42c8 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/app.manifest +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/app.manifest @@ -1,7 +1,7 @@ - +