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
This commit is contained in:
Terry MacDonald 2021-10-30 17:11:24 +13:00
parent b44bc3f269
commit a8a27bddde
2 changed files with 15 additions and 17 deletions

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")] [assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information // Version information
[assembly: AssemblyVersion("2.1.0.36")] [assembly: AssemblyVersion("2.1.0.37")]
[assembly: AssemblyFileVersion("2.1.0.36")] [assembly: AssemblyFileVersion("2.1.0.37")]
[assembly: NeutralResourcesLanguageAttribute( "en" )] [assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]

View File

@ -1119,7 +1119,7 @@ namespace DisplayMagician
string notificationText = $"DisplayMagician: Running {shortcutToUse.ExecutableNameAndPath}..."; string notificationText = $"DisplayMagician: Running {shortcutToUse.ExecutableNameAndPath}...";
if (notificationText.Length >= 64) if (notificationText.Length >= 64)
{ {
string thingToRun = shortcutToUse.ExecutableNameAndPath.Substring(0, 35); string thingToRun = shortcutToUse.ExecutableNameAndPath.Substring(0, 34);
notifyIcon.Text = $"DisplayMagician: Running {thingToRun}..."; notifyIcon.Text = $"DisplayMagician: Running {thingToRun}...";
} }
Application.DoEvents(); 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, // At this point, if the user wants to actually monitor a different process,
// then we actually need to monitor that instead // then we actually need to monitor that instead
if (shortcutToUse.MonitorDifferentGameExe) 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 // 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); 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 // Now look for the thing we're supposed to monitor
// and wait until it starts up // and wait until it starts up
List<Process> processesToMonitor = new List<Process>(); List<Process> processesToMonitor = new List<Process>();
@ -1621,13 +1622,6 @@ namespace DisplayMagician
{ {
// we are monitoring the game thats actually running (the most common scenario) // 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! // Now we want to tell the user we're running a game!
// Construct the Windows toast content // Construct the Windows toast content
tcBuilder = new ToastContentBuilder() 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."); 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 #endregion