From d3b22507d8b23706106d7329c830c1a20a023e49 Mon Sep 17 00:00:00 2001 From: richardadonnell Date: Fri, 5 Dec 2025 17:04:08 -0500 Subject: [PATCH 1/2] Refactor Donate command and enhance RequestConfig with dynamic window height calculation --- TopNotify/GUI/MainCommands.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/TopNotify/GUI/MainCommands.cs b/TopNotify/GUI/MainCommands.cs index 733a1b0..a391e4c 100644 --- a/TopNotify/GUI/MainCommands.cs +++ b/TopNotify/GUI/MainCommands.cs @@ -41,7 +41,7 @@ public static void About() .Show(); } - [Command("Donate")] + [Command("Donate")] public static async void Donate() { try @@ -68,7 +68,7 @@ public static string GetVersion() { // Read version from Appx Manifest var appxManifest = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "AppxManifest.xml"); - if (File.Exists(appxManifest)) { + if (File.Exists(appxManifest)) { var manifestData = File.ReadAllText(appxManifest); var from = manifestData.IndexOf("Version=\"") + "Version=\"".Length; @@ -86,6 +86,17 @@ public static string GetVersion() [Command("RequestConfig")] public static void RequestConfig(WebWindow target) { + // Calculate window height based on preview aspect ratio + var resolution = ResolutionFinder.GetRealResolution(); + float aspect = (float)resolution.Height / resolution.Width; + + // Preview width is 352px, so preview height = 352 * aspect + // Add fixed UI height for header, dropdown, controls, buttons, and padding + float previewHeight = 352f * aspect; + float windowHeight = previewHeight + 420f; + + target.Bounds = new WindowBounds((int)(400f * ResolutionFinder.GetScale()), (int)(windowHeight * ResolutionFinder.GetScale())); + target.SendConfig(); } From 0c74c7f2f94ee23073d4d8760bac71dcf094e9a9 Mon Sep 17 00:00:00 2001 From: hanos5 Date: Sat, 7 Feb 2026 11:49:05 +0900 Subject: [PATCH 2/2] Fix WebView2 data directory failing on non-ASCII user profile paths --- TopNotify/Program.cs | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/TopNotify/Program.cs b/TopNotify/Program.cs index 1bd3a25..633ec6f 100644 --- a/TopNotify/Program.cs +++ b/TopNotify/Program.cs @@ -1,7 +1,8 @@ -#define TRACE // Enable Trace.WriteLine +#define TRACE // Enable Trace.WriteLine using System; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Drawing; using Microsoft.Toolkit.Uwp.Notifications; using TopNotify.Daemon; @@ -11,6 +12,7 @@ using IgniteView.Desktop; using System.Reflection; using System.Runtime.InteropServices; +using System.Text; using Windows.Services.Store; using Serilog; using Serilog.Core; @@ -109,6 +111,18 @@ public static void Main(string[] args) // Open The GUI App In Settings Mode GUI = new ViteAppManager(); + + // WebView2 fails to read/write its data directory when the path contains + // non-ASCII characters (e.g. Japanese usernames). If non-ASCII characters + // are detected, fall back to an ASCII-safe path under ProgramData. + if (GUI.CurrentIdentity.AppDataPath.Any(c => c > 127)) + { + GUI.CurrentIdentity = new AsciiSafeAppIdentity( + GUI.CurrentIdentity.Name, + GUI.CurrentIdentity.Developer + ); + } + App(); } else @@ -153,5 +167,34 @@ public static async Task App() } } + + /// + /// AppIdentity subclass that works around WebView2's inability to handle non-ASCII paths. + /// When the user profile path contains non-ASCII characters (e.g. Japanese usernames), + /// this class redirects the data directory to an ASCII-safe path under ProgramData (C:\ProgramData). + /// + public class AsciiSafeAppIdentity : AppIdentity + { + [SetsRequiredMembers] + public AsciiSafeAppIdentity(string name, string developer) : base(name, developer) { } + + public override string AppDataPath + { + get + { + // ProgramData (C:\ProgramData) always has an ASCII-only path, + // making it safe to use as the WebView2 data directory + var basePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); + var fullPath = Path.Join(basePath, Developer, Name); + + if (!Directory.Exists(fullPath)) + { + Directory.CreateDirectory(fullPath); + } + + return fullPath; + } + } + } }