From ed011b818396ae27f5fe5e1f50e64d3bf7af7f08 Mon Sep 17 00:00:00 2001 From: "Yu Leng (from Dev Box)" Date: Tue, 17 Dec 2024 14:08:37 +0800 Subject: [PATCH 1/3] init commit --- src/common/Common.UI/Common.UI.csproj | 3 +-- src/common/Common.UI/SettingsDeepLink.cs | 9 ++++----- src/common/Common.UI/ThemeManager.cs | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/common/Common.UI/Common.UI.csproj b/src/common/Common.UI/Common.UI.csproj index 8d19debc3b43..4abd812fa18d 100644 --- a/src/common/Common.UI/Common.UI.csproj +++ b/src/common/Common.UI/Common.UI.csproj @@ -1,10 +1,9 @@  + - true - true PowerToys.Common.UI diff --git a/src/common/Common.UI/SettingsDeepLink.cs b/src/common/Common.UI/SettingsDeepLink.cs index 41bd2c012e94..d2fb5a8f4cf5 100644 --- a/src/common/Common.UI/SettingsDeepLink.cs +++ b/src/common/Common.UI/SettingsDeepLink.cs @@ -91,20 +91,19 @@ public static void OpenSettings(SettingsWindow window, bool mainExecutableIsOnTh { try { - var assemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - var fullPath = new DirectoryInfo(assemblyPath).FullName; + var directoryPath = System.AppContext.BaseDirectory; if (mainExecutableIsOnTheParentFolder) { // Need to go into parent folder for PowerToys.exe. Likely a WinUI3 App SDK application. - fullPath = fullPath + "\\..\\PowerToys.exe"; + directoryPath = directoryPath + "\\..\\PowerToys.exe"; } else { // PowerToys.exe is in the same path as the application. - fullPath = fullPath + "\\PowerToys.exe"; + directoryPath = directoryPath + "\\PowerToys.exe"; } - Process.Start(new ProcessStartInfo(fullPath) { Arguments = "--open-settings=" + SettingsWindowNameToString(window) }); + Process.Start(new ProcessStartInfo(directoryPath) { Arguments = "--open-settings=" + SettingsWindowNameToString(window) }); } catch { diff --git a/src/common/Common.UI/ThemeManager.cs b/src/common/Common.UI/ThemeManager.cs index d30084ef6ec5..fe6e02ad9446 100644 --- a/src/common/Common.UI/ThemeManager.cs +++ b/src/common/Common.UI/ThemeManager.cs @@ -11,7 +11,7 @@ namespace Common.UI { - public class ThemeManager : IDisposable + public partial class ThemeManager : IDisposable { private readonly Application _app; private const string LightTheme = "Light.Accent1"; From 80cd63fca898e28ced608744e61692ae78dd0348 Mon Sep 17 00:00:00 2001 From: "Yu Leng (from Dev Box)" Date: Thu, 19 Dec 2024 16:00:27 +0800 Subject: [PATCH 2/3] Use path.combine --- src/common/Common.UI/SettingsDeepLink.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/Common.UI/SettingsDeepLink.cs b/src/common/Common.UI/SettingsDeepLink.cs index d2fb5a8f4cf5..904c631d0aa8 100644 --- a/src/common/Common.UI/SettingsDeepLink.cs +++ b/src/common/Common.UI/SettingsDeepLink.cs @@ -95,12 +95,13 @@ public static void OpenSettings(SettingsWindow window, bool mainExecutableIsOnTh if (mainExecutableIsOnTheParentFolder) { // Need to go into parent folder for PowerToys.exe. Likely a WinUI3 App SDK application. - directoryPath = directoryPath + "\\..\\PowerToys.exe"; + directoryPath = Path.Combine(directoryPath, ".."); + directoryPath = Path.Combine(directoryPath, "PowerToys.exe"); } else { // PowerToys.exe is in the same path as the application. - directoryPath = directoryPath + "\\PowerToys.exe"; + directoryPath = Path.Combine(directoryPath, "PowerToys.exe"); } Process.Start(new ProcessStartInfo(directoryPath) { Arguments = "--open-settings=" + SettingsWindowNameToString(window) }); From 19ec643ffd2ceb8d709c32b8eacc71a5add06d7e Mon Sep 17 00:00:00 2001 From: "Yu Leng (from Dev Box)" Date: Fri, 20 Dec 2024 10:29:58 +0800 Subject: [PATCH 3/3] Add useWPF and useWindowsForms back --- src/common/Common.UI/Common.UI.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/Common.UI/Common.UI.csproj b/src/common/Common.UI/Common.UI.csproj index 4abd812fa18d..19fe2f1ee4d2 100644 --- a/src/common/Common.UI/Common.UI.csproj +++ b/src/common/Common.UI/Common.UI.csproj @@ -4,6 +4,8 @@ + true + true PowerToys.Common.UI