From 07d1c040cbb1cd19bd290036462aac7383e7d9aa Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Tue, 13 Oct 2020 20:22:42 +1300 Subject: [PATCH] Added ApplyProfile exceptions and StartPrograms --- HeliosPlus/Program.cs | 2 ++ HeliosPlus/ShortcutRepository.cs | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/HeliosPlus/Program.cs b/HeliosPlus/Program.cs index b223ee2..ac89a2f 100644 --- a/HeliosPlus/Program.cs +++ b/HeliosPlus/Program.cs @@ -310,6 +310,7 @@ namespace HeliosPlus { if (!ProfileRepository.ApplyNVIDIAGridTopology(profile)) { // Somehow return that this profile topology didn't apply + throw new ApplyTopologyException("Program/ApplyProfile: ApplyNVIDIAGridTopology: Error setting up the NVIDIA Surround Grid Topology"); } }); @@ -318,6 +319,7 @@ namespace HeliosPlus { if (!ProfileRepository.ApplyWindowsDisplayPathInfo(profile)) { // Somehow return that this profile path info didn't apply + throw new ApplyPathInfoException("Program/ApplyProfile: ApplyWindowsDisplayPathInfo: Error configuring the Windows Display Devices"); } }); diff --git a/HeliosPlus/ShortcutRepository.cs b/HeliosPlus/ShortcutRepository.cs index fc1ce66..c8d5850 100644 --- a/HeliosPlus/ShortcutRepository.cs +++ b/HeliosPlus/ShortcutRepository.cs @@ -506,16 +506,17 @@ namespace HeliosPlus List startProgramsToStop = new List(); if (shortcutToUse.StartPrograms is List && shortcutToUse.StartPrograms.Count > 0) { - foreach (StartProgram myStartProgram in shortcutToUse.StartPrograms - .Where(program => program.Enabled == true && program.CloseOnFinish == true) + foreach (StartProgram processToStart in shortcutToUse.StartPrograms + .Where(program => program.Enabled == true) .OrderBy(program => program.Priority)) { // Start the executable + Console.WriteLine($"Starting process {processToStart.Executable}"); Process process = null; - if (myStartProgram.ExecutableArgumentsRequired) - process = System.Diagnostics.Process.Start(myStartProgram.Executable, myStartProgram.Arguments); + if (processToStart.ExecutableArgumentsRequired) + process = System.Diagnostics.Process.Start(processToStart.Executable, processToStart.Arguments); else - process = System.Diagnostics.Process.Start(myStartProgram.Executable); + process = System.Diagnostics.Process.Start(processToStart.Executable); // Record t startProgramsToStop.Add(process); } @@ -657,7 +658,7 @@ namespace HeliosPlus IPCService.GetInstance().HoldProcessId = steamProcess?.Id ?? 0; IPCService.GetInstance().Status = InstanceStatus.OnHold; - // Add a status notification icon in the status area + /*// Add a status notification icon in the status area NotifyIcon notify = null; try { @@ -675,7 +676,7 @@ namespace HeliosPlus { Console.WriteLine($"Program/SwitchToSteamGame exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); // ignored - } + }*/ // Wait for the game to exit if (steamGameToRun.IsRunning) @@ -692,13 +693,13 @@ namespace HeliosPlus } // Remove the status notification icon from the status area - // once we've existed the game - if (notify != null) + // once we've exited the game + /*if (notify != null) { notify.Visible = false; notify.Dispose(); Application.DoEvents(); - } + }*/ } @@ -723,6 +724,7 @@ namespace HeliosPlus // Stop the programs in the reverse order we started them foreach (Process processToStop in startProgramsToStop.Reverse()) { + Console.WriteLine($"Stopping process {processToStop.StartInfo.FileName}"); // Stop the program processToStop.Close(); }