From fd98c2e5ca086c690253668914977b11a3c796f3 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sat, 21 Aug 2021 21:31:48 +1200 Subject: [PATCH] [WIP] Game Library updates --- DisplayMagician/GameLibraries/EpicLibrary.cs | 3 +- DisplayMagician/GameLibraries/GOGLibrary.cs | 11 +- DisplayMagician/GameLibraries/GameLibrary.cs | 3 +- .../GameLibraries/OriginLibrary.cs | 4 +- DisplayMagician/GameLibraries/SteamLibrary.cs | 3 +- DisplayMagician/GameLibraries/UplayLibrary.cs | 3 +- DisplayMagician/ProcessUtils.cs | 148 ++++++++++++++++++ DisplayMagician/ShortcutRepository.cs | 39 +++-- .../UIForms/ShortcutForm.Designer.cs | 93 ++++++----- DisplayMagician/UIForms/ShortcutForm.cs | 12 +- 10 files changed, 257 insertions(+), 62 deletions(-) diff --git a/DisplayMagician/GameLibraries/EpicLibrary.cs b/DisplayMagician/GameLibraries/EpicLibrary.cs index d358174..a60f3de 100644 --- a/DisplayMagician/GameLibraries/EpicLibrary.cs +++ b/DisplayMagician/GameLibraries/EpicLibrary.cs @@ -556,7 +556,7 @@ namespace DisplayMagician.GameLibraries return true; } - public override Process StartGame(Game game, string gameArguments = "") + public override Process StartGame(Game game, string gameArguments = "", ProcessPriorityClass processPriority = ProcessPriorityClass.Normal) { string address = $@"com.epicgames.launcher://apps/{game.Id}?action=launch&silent=true"; if (String.IsNullOrWhiteSpace(gameArguments)) @@ -564,6 +564,7 @@ namespace DisplayMagician.GameLibraries address += "/" + gameArguments; } Process gameProcess = Process.Start(address); + gameProcess.PriorityClass = processPriority; return gameProcess; } diff --git a/DisplayMagician/GameLibraries/GOGLibrary.cs b/DisplayMagician/GameLibraries/GOGLibrary.cs index 9baf9c5..2269732 100644 --- a/DisplayMagician/GameLibraries/GOGLibrary.cs +++ b/DisplayMagician/GameLibraries/GOGLibrary.cs @@ -551,15 +551,20 @@ namespace DisplayMagician.GameLibraries return true; } - public override Process StartGame(Game game, string gameArguments = "") - { + public override Process StartGame(Game game, string gameArguments = "", ProcessPriorityClass processPriority = ProcessPriorityClass.Normal) + { string args = $@"/command=runGame /gameId={game.Id} /path=""{game.Directory}"""; if (String.IsNullOrWhiteSpace(gameArguments)) { args += gameArguments; } - Process gameProcess = Process.Start(_gogExe,args); + Process gameProcess = null; + uint processID = 0; + if (ProcessUtils.LaunchProcessWithPriority(_gogExe, args, processPriority, out processID)) + { + gameProcess = Process.GetProcessById((int)processID); + } return gameProcess; } #endregion diff --git a/DisplayMagician/GameLibraries/GameLibrary.cs b/DisplayMagician/GameLibraries/GameLibrary.cs index 96cc464..1900e69 100644 --- a/DisplayMagician/GameLibraries/GameLibrary.cs +++ b/DisplayMagician/GameLibraries/GameLibrary.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using DisplayMagician; namespace DisplayMagician.GameLibraries { @@ -102,7 +103,7 @@ namespace DisplayMagician.GameLibraries return false; } - public virtual Process StartGame(Game game, string gameArguments = "") + public virtual Process StartGame(Game game, string gameArguments = "", ProcessPriorityClass processPriority = ProcessPriorityClass.Normal) { return null; } diff --git a/DisplayMagician/GameLibraries/OriginLibrary.cs b/DisplayMagician/GameLibraries/OriginLibrary.cs index 6a9b0b8..79a20ed 100644 --- a/DisplayMagician/GameLibraries/OriginLibrary.cs +++ b/DisplayMagician/GameLibraries/OriginLibrary.cs @@ -738,7 +738,7 @@ namespace DisplayMagician.GameLibraries return true; } - public override Process StartGame(Game game, string gameArguments = "") + public override Process StartGame(Game game, string gameArguments = "", ProcessPriorityClass processPriority = ProcessPriorityClass.Normal) { string address = $"origin2://game/launch?offerIds={game.Id}"; if (String.IsNullOrWhiteSpace(gameArguments)) @@ -746,8 +746,10 @@ namespace DisplayMagician.GameLibraries address += "/" + gameArguments; } Process gameProcess = Process.Start(address); + gameProcess.PriorityClass = processPriority; return gameProcess; } + #endregion } diff --git a/DisplayMagician/GameLibraries/SteamLibrary.cs b/DisplayMagician/GameLibraries/SteamLibrary.cs index 056b2da..be1027d 100644 --- a/DisplayMagician/GameLibraries/SteamLibrary.cs +++ b/DisplayMagician/GameLibraries/SteamLibrary.cs @@ -755,7 +755,7 @@ namespace DisplayMagician.GameLibraries } - public override Process StartGame(Game game, string gameArguments = "") + public override Process StartGame(Game game, string gameArguments = "", ProcessPriorityClass processPriority = ProcessPriorityClass.Normal) { string address = $@"steam://rungameid/{game.Id}"; if (!String.IsNullOrWhiteSpace(gameArguments)) @@ -763,6 +763,7 @@ namespace DisplayMagician.GameLibraries address += @"//" + gameArguments; } Process gameProcess = Process.Start(address); + gameProcess.PriorityClass = processPriority; return gameProcess; } #endregion diff --git a/DisplayMagician/GameLibraries/UplayLibrary.cs b/DisplayMagician/GameLibraries/UplayLibrary.cs index c2f1b2d..3c281bc 100644 --- a/DisplayMagician/GameLibraries/UplayLibrary.cs +++ b/DisplayMagician/GameLibraries/UplayLibrary.cs @@ -717,7 +717,7 @@ namespace DisplayMagician.GameLibraries return true; } - public override Process StartGame(Game game, string gameArguments = "") + public override Process StartGame(Game game, string gameArguments = "", ProcessPriorityClass processPriority = ProcessPriorityClass.Normal) { string address = $@"uplay://launch/{game.Id}"; if (String.IsNullOrWhiteSpace(gameArguments)) @@ -729,6 +729,7 @@ namespace DisplayMagician.GameLibraries address += "/0"; } Process gameProcess = Process.Start(address); + gameProcess.PriorityClass = processPriority; return gameProcess; } diff --git a/DisplayMagician/ProcessUtils.cs b/DisplayMagician/ProcessUtils.cs index 71d7999..cb2fa64 100644 --- a/DisplayMagician/ProcessUtils.cs +++ b/DisplayMagician/ProcessUtils.cs @@ -4,12 +4,87 @@ using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Management; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace DisplayMagician { + [Flags] + public enum ProcessCreationFlags : uint + { + ZERO_FLAG = 0x00000000, + CREATE_BREAKAWAY_FROM_JOB = 0x01000000, + CREATE_DEFAULT_ERROR_MODE = 0x04000000, + CREATE_NEW_CONSOLE = 0x00000010, + CREATE_NEW_PROCESS_GROUP = 0x00000200, + CREATE_NO_WINDOW = 0x08000000, + CREATE_PROTECTED_PROCESS = 0x00040000, + CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000, + CREATE_SEPARATE_WOW_VDM = 0x00001000, + CREATE_SHARED_WOW_VDM = 0x00001000, + CREATE_SUSPENDED = 0x00000004, + CREATE_UNICODE_ENVIRONMENT = 0x00000400, + DEBUG_ONLY_THIS_PROCESS = 0x00000002, + DEBUG_PROCESS = 0x00000001, + DETACHED_PROCESS = 0x00000008, + EXTENDED_STARTUPINFO_PRESENT = 0x00080000, + INHERIT_PARENT_AFFINITY = 0x00010000, + + // Process creations flags + ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000, + BELOW_NORMAL_PRIORITY_CLASS = 0x00004000, + HIGH_PRIORITY_CLASS = 0x00000080, + IDLE_PRIORITY_CLASS = 0x00000040, + NORMAL_PRIORITY_CLASS = 0x00000020, + REALTIME_PRIORITY_CLASS = 0x00000100, + } + + public struct PROCESS_INFORMATION + { + public IntPtr hProcess; + public IntPtr hThread; + public uint dwProcessId; + public uint dwThreadId; + } + + public struct STARTUPINFO + { + public uint cb; + public string lpReserved; + public string lpDesktop; + public string lpTitle; + public uint dwX; + public uint dwY; + public uint dwXSize; + public uint dwYSize; + public uint dwXCountChars; + public uint dwYCountChars; + public uint dwFillAttribute; + public uint dwFlags; + public short wShowWindow; + public short cbReserved2; + public IntPtr lpReserved2; + public IntPtr hStdInput; + public IntPtr hStdOutput; + public IntPtr hStdError; + } + + public static class NativeMethods + { + [DllImport("kernel32.dll")] + public static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, + bool bInheritHandles, ProcessCreationFlags dwCreationFlags, IntPtr lpEnvironment, + string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation); + + [DllImport("kernel32.dll")] + public static extern uint ResumeThread(IntPtr hThread); + + [DllImport("kernel32.dll")] + public static extern uint SuspendThread(IntPtr hThread); + } + class ProcessInfo : IComparable { public Process TheProcess; @@ -38,6 +113,7 @@ namespace DisplayMagician { private static Dictionary allProcessInfosDict; private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + private static IntPtr ThreadHandle = IntPtr.Zero; public static void Initialise() { @@ -170,5 +246,77 @@ namespace DisplayMagician } return false; } + + public static ProcessPriorityClass TranslatePriorityToClass(ProcessPriority processPriorityClass) + { + ProcessPriorityClass wantedPriorityClass = ProcessPriorityClass.Normal; + switch (processPriorityClass) + { + case ProcessPriority.High: + wantedPriorityClass = ProcessPriorityClass.High; + break; + case ProcessPriority.AboveNormal: + wantedPriorityClass = ProcessPriorityClass.AboveNormal; + break; + case ProcessPriority.Normal: + wantedPriorityClass = ProcessPriorityClass.Normal; + break; + case ProcessPriority.BelowNormal: + wantedPriorityClass = ProcessPriorityClass.BelowNormal; + break; + case ProcessPriority.Idle: + wantedPriorityClass = ProcessPriorityClass.Idle; + break; + default: + wantedPriorityClass = ProcessPriorityClass.Normal; + break; + } + return wantedPriorityClass; + } + + public static ProcessCreationFlags TranslatePriorityClassToFlags(ProcessPriorityClass processPriorityClass) + { + ProcessCreationFlags wantedPriorityClass = ProcessCreationFlags.NORMAL_PRIORITY_CLASS; + switch (processPriorityClass) + { + case ProcessPriorityClass.High: + wantedPriorityClass = ProcessCreationFlags.HIGH_PRIORITY_CLASS; + break; + case ProcessPriorityClass.AboveNormal: + wantedPriorityClass = ProcessCreationFlags.ABOVE_NORMAL_PRIORITY_CLASS; + break; + case ProcessPriorityClass.Normal: + wantedPriorityClass = ProcessCreationFlags.NORMAL_PRIORITY_CLASS; + break; + case ProcessPriorityClass.BelowNormal: + wantedPriorityClass = ProcessCreationFlags.BELOW_NORMAL_PRIORITY_CLASS; + break; + case ProcessPriorityClass.Idle: + wantedPriorityClass = ProcessCreationFlags.IDLE_PRIORITY_CLASS; + break; + default: + wantedPriorityClass = ProcessCreationFlags.NORMAL_PRIORITY_CLASS; + break; + } + return wantedPriorityClass; + } + + public static bool LaunchProcessWithPriority(string exeName, string cmdLine, ProcessPriorityClass priorityClass, out uint PID) + { + ProcessCreationFlags processFlags = TranslatePriorityClassToFlags(priorityClass); + + STARTUPINFO si = new STARTUPINFO(); + PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); + bool success = NativeMethods.CreateProcess(exeName, cmdLine, IntPtr.Zero, IntPtr.Zero, false, processFlags, IntPtr.Zero, null, ref si, out pi); + ThreadHandle = pi.hThread; + PID = pi.dwProcessId; + + return success; + } + + public static void ResumeProcess() + { + NativeMethods.ResumeThread(ThreadHandle); + } } } diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index 65dcc3c..c8c65b6 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -544,7 +544,7 @@ namespace DisplayMagician } } - private static ProcessPriorityClass TranslatePriorityClass(ProcessPriority processPriority) + private static ProcessPriorityClass TranslatePriorityClassToClass(ProcessPriority processPriority) { ProcessPriorityClass wantedPriorityClass = ProcessPriorityClass.Normal; switch (processPriority.ToString("G")) @@ -573,7 +573,6 @@ namespace DisplayMagician } - // ReSharper disable once CyclomaticComplexity public static void RunShortcut(ShortcutItem shortcutToUse, NotifyIcon notifyIcon = null) { @@ -821,7 +820,7 @@ namespace DisplayMagician foreach (Process runningProcess in alreadyRunningProcesses) { logger.Trace($"ShortcutRepository/RunShortcut: Setting priority of already running process {processToStart.Executable} to {processToStart.ProcessPriority.ToString("G")}"); - runningProcess.PriorityClass = TranslatePriorityClass(processToStart.ProcessPriority); + runningProcess.PriorityClass = TranslatePriorityClassToClass(processToStart.ProcessPriority); } } catch (Exception ex) @@ -839,16 +838,23 @@ namespace DisplayMagician Process process = null; try { - if (processToStart.ExecutableArgumentsRequired) + uint processID = 0; + if (ProcessUtils.LaunchProcessWithPriority(processToStart.Executable, processToStart.Arguments, ProcessUtils.TranslatePriorityToClass(processToStart.ProcessPriority), out processID)) + { + process = Process.GetProcessById((int)processID); + } + + /*if (processToStart.ExecutableArgumentsRequired) { process = System.Diagnostics.Process.Start(processToStart.Executable, processToStart.Arguments); + } else { process = System.Diagnostics.Process.Start(processToStart.Executable); - } + }*/ - try + /*try { // Attempt to set the process priority to whatever the user wanted logger.Trace($"ShortcutRepository/RunShortcut: Setting the start program process priority of start program we started to {shortcutToUse.ProcessPriority.ToString("G")}"); @@ -857,7 +863,7 @@ namespace DisplayMagician catch (Exception ex) { logger.Warn(ex, $"ShortcutRepository/RunShortcut: Exception setting the start program process priority of start program we started to {shortcutToUse.ProcessPriority.ToString("G")}"); - } + }*/ // Record the program we started so we can close it later @@ -963,15 +969,20 @@ namespace DisplayMagician try { Process process = null; - if (shortcutToUse.ExecutableArgumentsRequired) + /*if (shortcutToUse.ExecutableArgumentsRequired) { process = System.Diagnostics.Process.Start(shortcutToUse.ExecutableNameAndPath, shortcutToUse.ExecutableArguments); } else { process = System.Diagnostics.Process.Start(shortcutToUse.ExecutableNameAndPath); + }*/ + uint processID = 0; + if (ProcessUtils.LaunchProcessWithPriority(shortcutToUse.ExecutableNameAndPath, shortcutToUse.ExecutableArguments, ProcessUtils.TranslatePriorityToClass(shortcutToUse.ProcessPriority), out processID)) + { + process = Process.GetProcessById((int)processID); } - + } catch (Win32Exception ex) { @@ -1023,7 +1034,7 @@ namespace DisplayMagician foreach (Process monitoredProcess in processesToMonitor) { logger.Trace($"ShortcutRepository/RunShortcut: Setting priority of monitored executable process {processNameToLookFor} to {shortcutToUse.ProcessPriority.ToString("G")}"); - monitoredProcess.PriorityClass = TranslatePriorityClass(shortcutToUse.ProcessPriority); + monitoredProcess.PriorityClass = TranslatePriorityClassToClass(shortcutToUse.ProcessPriority); } } catch(Exception ex) @@ -1190,7 +1201,7 @@ namespace DisplayMagician Process gameProcess; //string gameRunCmd = gameLibraryToUse.GetRunCmd(gameToRun, shortcutToUse.GameArguments); //gameProcess = Process.Start(gameRunCmd); - gameProcess = gameLibraryToUse.StartGame(gameToRun, shortcutToUse.GameArguments); + gameProcess = gameLibraryToUse.StartGame(gameToRun, shortcutToUse.GameArguments, ProcessUtils.TranslatePriorityToClass(shortcutToUse.ProcessPriority)); // Delay 500ms Thread.Sleep(500); @@ -1338,7 +1349,7 @@ namespace DisplayMagician foreach (Process monitoredProcess in processesToMonitor) { logger.Trace($"ShortcutRepository/RunShortcut: Setting priority of alternative game monitored process {altGameProcessToMonitor} to {shortcutToUse.ProcessPriority.ToString("G")}"); - monitoredProcess.PriorityClass = TranslatePriorityClass(shortcutToUse.ProcessPriority); + monitoredProcess.PriorityClass = TranslatePriorityClassToClass(shortcutToUse.ProcessPriority); } } catch (Exception ex) @@ -1374,7 +1385,7 @@ namespace DisplayMagician foreach (Process monitoredProcess in gameToRun.Processes) { logger.Trace($"ShortcutRepository/RunShortcut: Setting priority of fallback game monitored process {gameToRun.ProcessName} to {shortcutToUse.ProcessPriority.ToString("G")}"); - monitoredProcess.PriorityClass = TranslatePriorityClass(shortcutToUse.ProcessPriority); + monitoredProcess.PriorityClass = TranslatePriorityClassToClass(shortcutToUse.ProcessPriority); } } catch (Exception ex) @@ -1582,7 +1593,7 @@ namespace DisplayMagician foreach (Process monitoredProcess in gameToRun.Processes) { logger.Trace($"ShortcutRepository/RunShortcut: Setting priority of fallback game monitored process {gameToRun.ProcessName} to {shortcutToUse.ProcessPriority.ToString("G")}"); - monitoredProcess.PriorityClass = TranslatePriorityClass(shortcutToUse.ProcessPriority); + monitoredProcess.PriorityClass = TranslatePriorityClassToClass(shortcutToUse.ProcessPriority); } } catch(Exception ex) diff --git a/DisplayMagician/UIForms/ShortcutForm.Designer.cs b/DisplayMagician/UIForms/ShortcutForm.Designer.cs index 1c5614b..059a328 100644 --- a/DisplayMagician/UIForms/ShortcutForm.Designer.cs +++ b/DisplayMagician/UIForms/ShortcutForm.Designer.cs @@ -41,7 +41,6 @@ namespace DisplayMagician.UIForms this.lbl_profile_shown_subtitle = new System.Windows.Forms.Label(); this.lbl_profile_shown = new System.Windows.Forms.Label(); this.ilv_saved_profiles = new Manina.Windows.Forms.ImageListView(); - this.dv_profile = new DisplayMagicianShared.UserControls.DisplayView(); this.tabp_audio = new System.Windows.Forms.TabPage(); this.lbl_no_active_capture_devices = new System.Windows.Forms.Label(); this.lbl_no_active_audio_devices = new System.Windows.Forms.Label(); @@ -67,7 +66,7 @@ namespace DisplayMagician.UIForms this.rb_change_audio = new System.Windows.Forms.RadioButton(); this.rb_no_change_audio = new System.Windows.Forms.RadioButton(); this.tabp_before = new System.Windows.Forms.TabPage(); - this.btn_find_examples = new System.Windows.Forms.Button(); + this.btn_find_examples_startprograms = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.btn_add_new_start_program = new System.Windows.Forms.Button(); this.flp_start_programs = new System.Windows.Forms.FlowLayoutPanel(); @@ -119,6 +118,8 @@ namespace DisplayMagician.UIForms this.cb_autosuggest = new System.Windows.Forms.CheckBox(); this.btn_hotkey = new System.Windows.Forms.Button(); this.lbl_hotkey_assigned = new System.Windows.Forms.Label(); + this.dv_profile = new DisplayMagicianShared.UserControls.DisplayView(); + this.btn_find_examples_game = new System.Windows.Forms.Button(); this.tabc_shortcut.SuspendLayout(); this.tabp_display.SuspendLayout(); this.tabp_audio.SuspendLayout(); @@ -270,23 +271,6 @@ namespace DisplayMagician.UIForms this.ilv_saved_profiles.View = Manina.Windows.Forms.View.HorizontalStrip; this.ilv_saved_profiles.ItemClick += new Manina.Windows.Forms.ItemClickEventHandler(this.ilv_saved_profiles_ItemClick); // - // dv_profile - // - this.dv_profile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.dv_profile.BackColor = System.Drawing.Color.DimGray; - this.dv_profile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.dv_profile.Font = new System.Drawing.Font("Consolas", 50F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.dv_profile.ForeColor = System.Drawing.Color.MidnightBlue; - this.dv_profile.Location = new System.Drawing.Point(0, 0); - this.dv_profile.Margin = new System.Windows.Forms.Padding(18); - this.dv_profile.Name = "dv_profile"; - this.dv_profile.PaddingX = 100; - this.dv_profile.PaddingY = 100; - this.dv_profile.Profile = null; - this.dv_profile.Size = new System.Drawing.Size(1082, 467); - this.dv_profile.TabIndex = 23; - // // tabp_audio // this.tabp_audio.BackColor = System.Drawing.Color.Black; @@ -617,7 +601,7 @@ namespace DisplayMagician.UIForms // tabp_before // this.tabp_before.BackColor = System.Drawing.Color.Black; - this.tabp_before.Controls.Add(this.btn_find_examples); + this.tabp_before.Controls.Add(this.btn_find_examples_startprograms); this.tabp_before.Controls.Add(this.label3); this.tabp_before.Controls.Add(this.btn_add_new_start_program); this.tabp_before.Controls.Add(this.flp_start_programs); @@ -630,21 +614,21 @@ namespace DisplayMagician.UIForms this.tabp_before.TabIndex = 1; this.tabp_before.Text = "3. Choose what happens before"; // - // btn_find_examples + // btn_find_examples_startprograms // - this.btn_find_examples.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btn_find_examples.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed; - this.btn_find_examples.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown; - this.btn_find_examples.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_find_examples.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btn_find_examples.ForeColor = System.Drawing.Color.White; - this.btn_find_examples.Location = new System.Drawing.Point(976, 72); - this.btn_find_examples.Name = "btn_find_examples"; - this.btn_find_examples.Size = new System.Drawing.Size(94, 25); - this.btn_find_examples.TabIndex = 40; - this.btn_find_examples.Text = "Find &Examples"; - this.btn_find_examples.UseVisualStyleBackColor = true; - this.btn_find_examples.Click += new System.EventHandler(this.btn_find_examples_Click); + this.btn_find_examples_startprograms.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btn_find_examples_startprograms.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed; + this.btn_find_examples_startprograms.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown; + this.btn_find_examples_startprograms.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_find_examples_startprograms.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_find_examples_startprograms.ForeColor = System.Drawing.Color.White; + this.btn_find_examples_startprograms.Location = new System.Drawing.Point(953, 72); + this.btn_find_examples_startprograms.Name = "btn_find_examples_startprograms"; + this.btn_find_examples_startprograms.Size = new System.Drawing.Size(117, 25); + this.btn_find_examples_startprograms.TabIndex = 40; + this.btn_find_examples_startprograms.Text = "Show me &Examples"; + this.btn_find_examples_startprograms.UseVisualStyleBackColor = true; + this.btn_find_examples_startprograms.Click += new System.EventHandler(this.btn_find_examples_startprograms_Click); // // label3 // @@ -689,6 +673,7 @@ namespace DisplayMagician.UIForms // tabp_game // this.tabp_game.BackColor = System.Drawing.Color.Black; + this.tabp_game.Controls.Add(this.btn_find_examples_game); this.tabp_game.Controls.Add(this.lbl_no_game_libraries); this.tabp_game.Controls.Add(this.p_standalone); this.tabp_game.Controls.Add(this.rb_standalone); @@ -1082,10 +1067,10 @@ namespace DisplayMagician.UIForms this.rb_launcher.ForeColor = System.Drawing.Color.White; this.rb_launcher.Location = new System.Drawing.Point(15, 262); this.rb_launcher.Name = "rb_launcher"; - this.rb_launcher.Size = new System.Drawing.Size(417, 24); + this.rb_launcher.Size = new System.Drawing.Size(466, 24); this.rb_launcher.TabIndex = 6; this.rb_launcher.TabStop = true; - this.rb_launcher.Text = "Launch a Game installed in Steam, Uplay, Epic or GOG"; + this.rb_launcher.Text = "Launch a Game installed in Steam, Origin, Uplay, Epic or GOG"; this.rb_launcher.UseVisualStyleBackColor = true; this.rb_launcher.CheckedChanged += new System.EventHandler(this.rb_launcher_CheckedChanged); // @@ -1304,6 +1289,39 @@ namespace DisplayMagician.UIForms this.lbl_hotkey_assigned.Visible = false; this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click); // + // dv_profile + // + this.dv_profile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dv_profile.BackColor = System.Drawing.Color.DimGray; + this.dv_profile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.dv_profile.Font = new System.Drawing.Font("Consolas", 50F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.dv_profile.ForeColor = System.Drawing.Color.MidnightBlue; + this.dv_profile.Location = new System.Drawing.Point(0, 0); + this.dv_profile.Margin = new System.Windows.Forms.Padding(18); + this.dv_profile.Name = "dv_profile"; + this.dv_profile.PaddingX = 100; + this.dv_profile.PaddingY = 100; + this.dv_profile.Profile = null; + this.dv_profile.Size = new System.Drawing.Size(1082, 467); + this.dv_profile.TabIndex = 23; + // + // btn_find_examples_game + // + this.btn_find_examples_game.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btn_find_examples_game.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed; + this.btn_find_examples_game.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown; + this.btn_find_examples_game.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_find_examples_game.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_find_examples_game.ForeColor = System.Drawing.Color.White; + this.btn_find_examples_game.Location = new System.Drawing.Point(953, 17); + this.btn_find_examples_game.Name = "btn_find_examples_game"; + this.btn_find_examples_game.Size = new System.Drawing.Size(117, 25); + this.btn_find_examples_game.TabIndex = 41; + this.btn_find_examples_game.Text = "Show me &Examples"; + this.btn_find_examples_game.UseVisualStyleBackColor = true; + this.btn_find_examples_game.Click += new System.EventHandler(this.btn_find_examples_game_Click); + // // ShortcutForm // this.AcceptButton = this.btn_save; @@ -1451,9 +1469,10 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.Button btn_add_new_start_program; private System.Windows.Forms.Label label3; internal Manina.Windows.Forms.ImageListView ilv_games; - private System.Windows.Forms.Button btn_find_examples; + private System.Windows.Forms.Button btn_find_examples_startprograms; private System.Windows.Forms.ComboBox cbx_game_priority; private System.Windows.Forms.ComboBox cbx_exe_priority; private System.Windows.Forms.Label lbl_exe_priority; + private System.Windows.Forms.Button btn_find_examples_game; } } \ No newline at end of file diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index 9be77af..2dd76c7 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -834,7 +834,7 @@ namespace DisplayMagician.UIForms }; cbx_game_priority.ValueMember = "Value"; cbx_game_priority.DisplayMember = "Text"; - cbx_game_priority.SelectedItem = "Normal"; + cbx_game_priority.SelectedIndex = 2; //Normal cbx_game_priority.Enabled = true; // Prepare the exe process priority combo box @@ -847,7 +847,7 @@ namespace DisplayMagician.UIForms }; cbx_exe_priority.ValueMember = "Value"; cbx_exe_priority.DisplayMember = "Text"; - cbx_exe_priority.SelectedItem = "Normal"; + cbx_exe_priority.SelectedIndex = 2; //Normal cbx_exe_priority.Enabled = true; // Populate all the Audio devices in the audio devices list. @@ -2303,11 +2303,17 @@ namespace DisplayMagician.UIForms SelectGameInImageListView(); } - private void btn_find_examples_Click(object sender, EventArgs e) + private void btn_find_examples_startprograms_Click(object sender, EventArgs e) { string targetURL = @"https://github.com/terrymacdonald/DisplayMagician/wiki/Start-Program-Examples"; System.Diagnostics.Process.Start(targetURL); } + + private void btn_find_examples_game_Click(object sender, EventArgs e) + { + string targetURL = @"https://github.com/terrymacdonald/DisplayMagician/wiki/Main-Game-and-Application-Examples"; + System.Diagnostics.Process.Start(targetURL); + } } // Class used to populate combo boxes