From a8a27bddde55c967b814aa54eca822b2f78e0e0d Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sat, 30 Oct 2021 17:11:24 +1300 Subject: [PATCH] Found CTD error with long game library names Incorrect logic when checking long file names which restuled in text loneer than the 64 character limit for the notification icon. Partially fixes #49 --- DisplayMagician/Properties/AssemblyInfo.cs | 4 ++-- DisplayMagician/ShortcutRepository.cs | 28 ++++++++++------------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/DisplayMagician/Properties/AssemblyInfo.cs b/DisplayMagician/Properties/AssemblyInfo.cs index e51c555..7bdb162 100644 --- a/DisplayMagician/Properties/AssemblyInfo.cs +++ b/DisplayMagician/Properties/AssemblyInfo.cs @@ -26,8 +26,8 @@ using System.Resources; [assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")] // Version information -[assembly: AssemblyVersion("2.1.0.36")] -[assembly: AssemblyFileVersion("2.1.0.36")] +[assembly: AssemblyVersion("2.1.0.37")] +[assembly: AssemblyFileVersion("2.1.0.37")] [assembly: NeutralResourcesLanguageAttribute( "en" )] [assembly: CLSCompliant(true)] diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index baf7e3d..0c18f3c 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -1119,7 +1119,7 @@ namespace DisplayMagician string notificationText = $"DisplayMagician: Running {shortcutToUse.ExecutableNameAndPath}..."; if (notificationText.Length >= 64) { - string thingToRun = shortcutToUse.ExecutableNameAndPath.Substring(0, 35); + string thingToRun = shortcutToUse.ExecutableNameAndPath.Substring(0, 34); notifyIcon.Text = $"DisplayMagician: Running {thingToRun}..."; } Application.DoEvents(); @@ -1372,6 +1372,14 @@ namespace DisplayMagician } + string notificationText = $"DisplayMagician: Running {gameToRun.Name}..."; + if (notificationText.Length >= 64) + { + string thingToRun = gameToRun.Name.Substring(0, 34); + notifyIcon.Text = $"DisplayMagician: Running {thingToRun}..."; + } + Application.DoEvents(); + // At this point, if the user wants to actually monitor a different process, // then we actually need to monitor that instead if (shortcutToUse.MonitorDifferentGameExe) @@ -1379,13 +1387,6 @@ namespace DisplayMagician // If we are monitoring a different executable rather than the game itself, then lets get that name ready instead string altGameProcessToMonitor = System.IO.Path.GetFileNameWithoutExtension(shortcutToUse.DifferentGameExeToMonitor); - // Add a status notification icon in the status area - if (gameToRun.Name.Length <= 41) - notifyIcon.Text = $"DisplayMagician: Running {gameToRun.Name}..."; - else - notifyIcon.Text = $"DisplayMagician: Running {gameToRun.Name.Substring(0, 41)}..."; - Application.DoEvents(); - // Now look for the thing we're supposed to monitor // and wait until it starts up List processesToMonitor = new List(); @@ -1621,13 +1622,6 @@ namespace DisplayMagician { // we are monitoring the game thats actually running (the most common scenario) - // Add a status notification icon in the status area - if (gameToRun.Name.Length <= 41) - notifyIcon.Text = $"DisplayMagician: Running {gameToRun.Name}..."; - else - notifyIcon.Text = $"DisplayMagician: Running {gameToRun.Name.Substring(0, 41)}..."; - Application.DoEvents(); - // Now we want to tell the user we're running a game! // Construct the Windows toast content tcBuilder = new ToastContentBuilder() @@ -1977,6 +1971,10 @@ namespace DisplayMagician logger.Debug($"ShortcutRepository/RunShortcut: Shortcut did not require changing Display Profile, so no need to change it back."); } + // Reset the popup over the system tray icon to what's normal for it. + notifyIcon.Text = $"DisplayMagician"; + Application.DoEvents(); + } #endregion