diff --git a/DisplayMagician/Program.cs b/DisplayMagician/Program.cs
index 0dabe6f..1e87e73 100644
--- a/DisplayMagician/Program.cs
+++ b/DisplayMagician/Program.cs
@@ -17,6 +17,7 @@ using DesktopNotifications;
using System.Runtime.Serialization;
using NLog.Config;
using System.Collections.Generic;
+using WK.Libraries.HotkeyListenerNS;
namespace DisplayMagician {
@@ -44,6 +45,7 @@ namespace DisplayMagician {
public static bool WaitingForGameToExit = false;
public static ProgramSettings AppProgramSettings;
public static MainForm AppMainForm;
+ public static HotkeyListener HotkeyListener;
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private static SharedLogger sharedLogger;
@@ -202,6 +204,10 @@ namespace DisplayMagician {
//Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+
+ // Create a program-wide HotKeyListener
+ HotkeyListener = new HotkeyListener();
logger.Debug($"Setting up commandline processing configuration");
var app = new CommandLineApplication
@@ -354,10 +360,6 @@ namespace DisplayMagician {
{
logger.Debug($"Program/CreateProfile: Starting");
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
-
try
{
// Start the IPC Service to
@@ -390,10 +392,6 @@ namespace DisplayMagician {
{
logger.Debug($"Program/StartUpApplication: Starting");
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
-
try
{
// Start the IPC Service to
diff --git a/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs b/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs
index d749a67..f9de64b 100644
--- a/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs
+++ b/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs
@@ -57,6 +57,7 @@ namespace DisplayMagician.UIForms
this.dv_profile = new DisplayMagicianShared.UserControls.DisplayView();
this.btn_save = new System.Windows.Forms.Button();
this.dialog_save = new System.Windows.Forms.SaveFileDialog();
+ this.btn_hotkey = new System.Windows.Forms.Button();
this.menu_profiles.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pb_down_arrow)).BeginInit();
this.SuspendLayout();
@@ -70,9 +71,9 @@ namespace DisplayMagician.UIForms
this.btn_apply.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_apply.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_apply.ForeColor = System.Drawing.Color.White;
- this.btn_apply.Location = new System.Drawing.Point(245, 769);
+ this.btn_apply.Location = new System.Drawing.Point(194, 769);
this.btn_apply.Name = "btn_apply";
- this.btn_apply.Size = new System.Drawing.Size(120, 40);
+ this.btn_apply.Size = new System.Drawing.Size(118, 40);
this.btn_apply.TabIndex = 2;
this.btn_apply.Text = "&Apply";
this.btn_apply.UseVisualStyleBackColor = false;
@@ -102,7 +103,7 @@ namespace DisplayMagician.UIForms
this.btn_delete.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_delete.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_delete.ForeColor = System.Drawing.Color.White;
- this.btn_delete.Location = new System.Drawing.Point(384, 769);
+ this.btn_delete.Location = new System.Drawing.Point(446, 769);
this.btn_delete.Name = "btn_delete";
this.btn_delete.Size = new System.Drawing.Size(120, 40);
this.btn_delete.TabIndex = 4;
@@ -236,7 +237,6 @@ namespace DisplayMagician.UIForms
this.ilv_saved_profiles.AllowPaneResize = false;
this.ilv_saved_profiles.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.ilv_saved_profiles.Colors = new Manina.Windows.Forms.ImageListViewColor(resources.GetString("ilv_saved_profiles.Colors"));
this.ilv_saved_profiles.Location = new System.Drawing.Point(0, 601);
this.ilv_saved_profiles.MultiSelect = false;
this.ilv_saved_profiles.Name = "ilv_saved_profiles";
@@ -314,7 +314,7 @@ namespace DisplayMagician.UIForms
this.btn_save.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_save.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_save.ForeColor = System.Drawing.Color.White;
- this.btn_save.Location = new System.Drawing.Point(521, 769);
+ this.btn_save.Location = new System.Drawing.Point(572, 769);
this.btn_save.Name = "btn_save";
this.btn_save.Size = new System.Drawing.Size(211, 40);
this.btn_save.TabIndex = 34;
@@ -329,6 +329,21 @@ namespace DisplayMagician.UIForms
this.dialog_save.Filter = global::DisplayMagician.Resources.Language.Shortcuts_Filter;
this.dialog_save.RestoreDirectory = true;
//
+ // btn_hotkey
+ //
+ this.btn_hotkey.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.btn_hotkey.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
+ this.btn_hotkey.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
+ this.btn_hotkey.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.btn_hotkey.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.btn_hotkey.ForeColor = System.Drawing.Color.White;
+ this.btn_hotkey.Location = new System.Drawing.Point(320, 769);
+ this.btn_hotkey.Name = "btn_hotkey";
+ this.btn_hotkey.Size = new System.Drawing.Size(120, 40);
+ this.btn_hotkey.TabIndex = 35;
+ this.btn_hotkey.Text = "&Hotkey";
+ this.btn_hotkey.UseVisualStyleBackColor = true;
+ //
// DisplayProfileForm
//
this.AcceptButton = this.btn_apply;
@@ -338,6 +353,7 @@ namespace DisplayMagician.UIForms
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.CancelButton = this.btn_back;
this.ClientSize = new System.Drawing.Size(976, 829);
+ this.Controls.Add(this.btn_hotkey);
this.Controls.Add(this.btn_save);
this.Controls.Add(this.lbl_save_profile);
this.Controls.Add(this.label1);
@@ -394,6 +410,7 @@ namespace DisplayMagician.UIForms
private System.Windows.Forms.Label lbl_save_profile;
private System.Windows.Forms.Button btn_save;
private System.Windows.Forms.SaveFileDialog dialog_save;
+ private System.Windows.Forms.Button btn_hotkey;
}
}
diff --git a/DisplayMagician/UIForms/DisplayProfileForm.resx b/DisplayMagician/UIForms/DisplayProfileForm.resx
index d48d675..ce90d56 100644
--- a/DisplayMagician/UIForms/DisplayProfileForm.resx
+++ b/DisplayMagician/UIForms/DisplayProfileForm.resx
@@ -156,9 +156,6 @@
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0riv8AqmJbqTbWBoYAAAAASUVORK5CYII=
-
- BorderColor = 406d6d6d; UnFocusedColor1 = ffff8080; UnFocusedColor2 = LightCoral; UnFocusedBorderColor = Maroon; HoverColor1 = 80078d7; HoverColor2 = 400078d7; HoverBorderColor = 400078d7; SelectedColor1 = ffff8080; SelectedColor2 = LightCoral; SelectedBorderColor = Maroon; DisabledColor1 = 6d6d6d; DisabledColor2 = 206d6d6d; DisabledBorderColor = 206d6d6d; DisabledForeColor = ff808080; ColumnHeaderBackColor1 = 20f0f0f0; ColumnHeaderBackColor2 = c4f0f0f0; ColumnHeaderHoverColor1 = 100078d7; ColumnHeaderHoverColor2 = 400078d7; ColumnSelectColor = 106d6d6d; ColumnSeparatorColor = 206d6d6d; PaneBackColor = 106d6d6d; PaneSeparatorColor = 806d6d6d; SelectionRectangleColor1 = 800078d7; SelectionRectangleColor2 = 800078d7
-
248, 17
diff --git a/DisplayMagician/UIForms/MainForm.cs b/DisplayMagician/UIForms/MainForm.cs
index 822de40..3660553 100644
--- a/DisplayMagician/UIForms/MainForm.cs
+++ b/DisplayMagician/UIForms/MainForm.cs
@@ -10,6 +10,7 @@ using Newtonsoft.Json;
using System.Net;
using Windows.Data.Xml.Dom;
using Microsoft.Toolkit.Uwp.Notifications;
+using WK.Libraries.HotkeyListenerNS;
namespace DisplayMagician.UIForms
{
@@ -18,6 +19,7 @@ namespace DisplayMagician.UIForms
private bool allowVisible; // ContextMenu's Show command used
private bool allowClose; // ContextMenu's Exit command used
+ private Hotkey hotkeyMainWindow;
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
@@ -31,6 +33,16 @@ namespace DisplayMagician.UIForms
notifyIcon.ContextMenuStrip = mainContextMenuStrip;
RefreshNotifyIconMenus();
+
+ // Define a new hotkey using the Hotkey class.
+ // Parameters are: [modifiers], [keys].
+ hotkeyMainWindow = new Hotkey(Keys.Control | Keys.Shift, Keys.W);
+ Program.HotkeyListener.Add(hotkeyMainWindow);
+
+ // Register a HotkeyPressed event.
+ Program.HotkeyListener.HotkeyPressed += Hkl_MainWindowHotkeyPressed;
+
+
if (Program.AppProgramSettings.MinimiseOnStart)
{
// Make the form minimised on start
@@ -490,5 +502,11 @@ namespace DisplayMagician.UIForms
{
openApplicationWindow();
}
+
+ private void Hkl_MainWindowHotkeyPressed(object sender, HotkeyEventArgs e)
+ {
+ if (e.Hotkey == hotkeyMainWindow)
+ openApplicationWindow();
+ }
}
}
diff --git a/DisplayMagician/UIForms/ShortcutForm.Designer.cs b/DisplayMagician/UIForms/ShortcutForm.Designer.cs
index 90607d2..1feac7d 100644
--- a/DisplayMagician/UIForms/ShortcutForm.Designer.cs
+++ b/DisplayMagician/UIForms/ShortcutForm.Designer.cs
@@ -121,6 +121,7 @@ namespace DisplayMagician.UIForms
this.rb_standalone = new System.Windows.Forms.RadioButton();
this.rb_no_game = new System.Windows.Forms.RadioButton();
this.p_game = new System.Windows.Forms.Panel();
+ this.cb_wait_alternative_game = new System.Windows.Forms.CheckBox();
this.btn_choose_alternative_game = new System.Windows.Forms.Button();
this.txt_alternative_game = new System.Windows.Forms.TextBox();
this.txt_game_launcher = new System.Windows.Forms.TextBox();
@@ -151,7 +152,7 @@ namespace DisplayMagician.UIForms
this.lbl_title = new System.Windows.Forms.Label();
this.lbl_shortcut_name = new System.Windows.Forms.Label();
this.cb_autosuggest = new System.Windows.Forms.CheckBox();
- this.cb_wait_alternative_game = new System.Windows.Forms.CheckBox();
+ this.btn_hotkey = new System.Windows.Forms.Button();
this.tabc_shortcut.SuspendLayout();
this.tabp_display.SuspendLayout();
this.tabp_audio.SuspendLayout();
@@ -187,7 +188,7 @@ namespace DisplayMagician.UIForms
this.btn_save.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_save.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_save.ForeColor = System.Drawing.Color.White;
- this.btn_save.Location = new System.Drawing.Point(517, 778);
+ this.btn_save.Location = new System.Drawing.Point(560, 778);
this.btn_save.Name = "btn_save";
this.btn_save.Size = new System.Drawing.Size(120, 40);
this.btn_save.TabIndex = 6;
@@ -295,7 +296,6 @@ namespace DisplayMagician.UIForms
this.ilv_saved_profiles.AllowPaneResize = false;
this.ilv_saved_profiles.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
- this.ilv_saved_profiles.Colors = new Manina.Windows.Forms.ImageListViewColor(resources.GetString("ilv_saved_profiles.Colors"));
this.ilv_saved_profiles.Location = new System.Drawing.Point(0, 466);
this.ilv_saved_profiles.MultiSelect = false;
this.ilv_saved_profiles.Name = "ilv_saved_profiles";
@@ -1308,6 +1308,17 @@ namespace DisplayMagician.UIForms
this.p_game.Size = new System.Drawing.Size(1006, 278);
this.p_game.TabIndex = 7;
//
+ // cb_wait_alternative_game
+ //
+ this.cb_wait_alternative_game.AutoSize = true;
+ this.cb_wait_alternative_game.Location = new System.Drawing.Point(451, 214);
+ this.cb_wait_alternative_game.Name = "cb_wait_alternative_game";
+ this.cb_wait_alternative_game.Size = new System.Drawing.Size(220, 44);
+ this.cb_wait_alternative_game.TabIndex = 27;
+ this.cb_wait_alternative_game.Text = "Wait until this executable \r\nis closed before continuing:";
+ this.cb_wait_alternative_game.UseVisualStyleBackColor = true;
+ this.cb_wait_alternative_game.CheckedChanged += new System.EventHandler(this.cb_wait_alternative_game_CheckedChanged);
+ //
// btn_choose_alternative_game
//
this.btn_choose_alternative_game.Enabled = false;
@@ -1660,16 +1671,20 @@ namespace DisplayMagician.UIForms
this.cb_autosuggest.UseVisualStyleBackColor = true;
this.cb_autosuggest.CheckedChanged += new System.EventHandler(this.cb_autosuggest_CheckedChanged);
//
- // cb_wait_alternative_game
+ // btn_hotkey
//
- this.cb_wait_alternative_game.AutoSize = true;
- this.cb_wait_alternative_game.Location = new System.Drawing.Point(451, 214);
- this.cb_wait_alternative_game.Name = "cb_wait_alternative_game";
- this.cb_wait_alternative_game.Size = new System.Drawing.Size(220, 44);
- this.cb_wait_alternative_game.TabIndex = 27;
- this.cb_wait_alternative_game.Text = "Wait until this executable \r\nis closed before continuing:";
- this.cb_wait_alternative_game.UseVisualStyleBackColor = true;
- this.cb_wait_alternative_game.CheckedChanged += new System.EventHandler(this.cb_wait_alternative_game_CheckedChanged);
+ this.btn_hotkey.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.btn_hotkey.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
+ this.btn_hotkey.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
+ this.btn_hotkey.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.btn_hotkey.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.btn_hotkey.ForeColor = System.Drawing.Color.White;
+ this.btn_hotkey.Location = new System.Drawing.Point(434, 778);
+ this.btn_hotkey.Name = "btn_hotkey";
+ this.btn_hotkey.Size = new System.Drawing.Size(120, 40);
+ this.btn_hotkey.TabIndex = 36;
+ this.btn_hotkey.Text = "&Hotkey";
+ this.btn_hotkey.UseVisualStyleBackColor = true;
//
// ShortcutForm
//
@@ -1679,6 +1694,7 @@ namespace DisplayMagician.UIForms
this.BackColor = System.Drawing.Color.Black;
this.CancelButton = this.btn_cancel;
this.ClientSize = new System.Drawing.Size(1114, 830);
+ this.Controls.Add(this.btn_hotkey);
this.Controls.Add(this.cb_autosuggest);
this.Controls.Add(this.txt_shortcut_save_name);
this.Controls.Add(this.lbl_shortcut_name);
@@ -1860,5 +1876,6 @@ namespace DisplayMagician.UIForms
private System.Windows.Forms.Button btn_choose_alternative_game;
private System.Windows.Forms.TextBox txt_alternative_game;
private System.Windows.Forms.CheckBox cb_wait_alternative_game;
+ private System.Windows.Forms.Button btn_hotkey;
}
}
\ No newline at end of file
diff --git a/DisplayMagician/UIForms/ShortcutForm.resx b/DisplayMagician/UIForms/ShortcutForm.resx
index ba331a4..02f7332 100644
--- a/DisplayMagician/UIForms/ShortcutForm.resx
+++ b/DisplayMagician/UIForms/ShortcutForm.resx
@@ -123,9 +123,6 @@
17, 17
-
- BorderColor = 406d6d6d; UnFocusedColor1 = ffff8080; UnFocusedColor2 = LightCoral; UnFocusedBorderColor = Maroon; HoverColor1 = Transparent; HoverColor2 = Transparent; HoverBorderColor = Transparent; SelectedColor1 = ffff8080; SelectedColor2 = LightCoral; SelectedBorderColor = Maroon; DisabledColor1 = 6d6d6d; DisabledColor2 = 206d6d6d; DisabledBorderColor = 206d6d6d; DisabledForeColor = ff808080; ColumnHeaderBackColor1 = 20f0f0f0; ColumnHeaderBackColor2 = c4f0f0f0; ColumnHeaderHoverColor1 = 100078d7; ColumnHeaderHoverColor2 = 400078d7; ColumnSelectColor = 106d6d6d; ColumnSeparatorColor = 206d6d6d; PaneBackColor = 106d6d6d; PaneSeparatorColor = 806d6d6d; SelectionRectangleColor1 = ffff8080; SelectionRectangleColor2 = 800078d7
-
67