Remove some hosts references and fix close button

This commit is contained in:
Aaron Junker
2025-06-15 23:20:26 +02:00
parent 46df48684d
commit da77396da5
15 changed files with 47 additions and 79 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1001 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -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)
{

View File

@@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity
Name="5addce20-730c-44a0-8d72-d840a2bd3128"
Publisher="CN=aaron"
Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="5addce20-730c-44a0-8d72-d840a2bd3128" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>ShortcutGuide.Ui</DisplayName>
<PublisherDisplayName>aaron</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="ShortcutGuide.Ui"
Description="ShortcutGuide.Ui"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

View File

@@ -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;
}
}

View File

@@ -17,7 +17,7 @@
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps</OutputPath>
<AssemblyName>PowerToys.ShortcutGuide</AssemblyName>
<DefineConstants>DISABLE_XAML_GENERATED_MAIN,TRACE</DefineConstants>
<ApplicationIcon>Assets/Hosts/Hosts.ico</ApplicationIcon>
<ApplicationIcon>Assets\ShortcutGuide\ShortcutGuide.ico</ApplicationIcon>
<!-- MRT from windows app sdk will search for a pri file with the same name of the module before defaulting to resources.pri -->
<ProjectPriFileName>PowerToys.ShortcutGuide.pri</ProjectPriFileName>
</PropertyGroup>
@@ -28,14 +28,10 @@
<Content Remove="Assets\ShortcutGuide\+WindowsNT.WindowsExplorer.en-US.yml" />
<Content Remove="Assets\ShortcutGuide\Microsoft.PowerToys.en-US.yml" />
<Content Remove="Assets\ShortcutGuide\OfficeKey.png" />
<Content Remove="Assets\ShortcutGuide\ShortcutGuide.ico" />
</ItemGroup>
<ItemGroup>
<None Remove="Assets\ShortcutGuide\AppList.scale-100.png" />
<None Remove="Assets\ShortcutGuide\AppList.scale-125.png" />
<None Remove="Assets\ShortcutGuide\AppList.scale-150.png" />
<None Remove="Assets\ShortcutGuide\AppList.scale-200.png" />
<None Remove="Assets\ShortcutGuide\AppList.scale-400.png" />
<None Remove="ShortcutGuideXAML\ShortcutView.xaml" />
<None Include="Assets\ShortcutGuide\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -46,7 +42,7 @@
<Message Text="Executing CopyPRIFileToOutputDir task" Importance="High" />
<ItemGroup>
<PRIFile Include="$(OutDir)**\PowerToys.Hosts.pri" />
<PRIFile Include="$(OutDir)**\PowerToys.ShortcutGuide.pri" />
</ItemGroup>
<Copy SourceFiles="@(PRIFile)" DestinationFolder="$(OutDir)" />
@@ -72,10 +68,6 @@
</COMReference>
</ItemGroup>
<ItemGroup>
<Content Include="Assets\Hosts\Hosts.ico" />
</ItemGroup>
<!-- See https://learn.microsoft.com/windows/apps/develop/platform/csharp-winrt/net-projection-from-cppwinrt-component for more info -->
<PropertyGroup>
<CsWinRTIncludes>PowerToys.GPOWrapper</CsWinRTIncludes>

View File

@@ -17,6 +17,11 @@ namespace ShortcutGuide
{
_window = new MainWindow();
_window.Activate();
_window.Closed += (s, e) =>
{
_window = null;
Current.Exit();
};
}
private Window? _window;

View File

@@ -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)

View File

@@ -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)

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0"
xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="Hosts.app"/>
<assemblyIdentity version="1.0.0.0" name="ShortcutGuide.app"/>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>