diff --git a/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs b/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs index 8b253c5..a146845 100644 --- a/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs +++ b/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs @@ -58,6 +58,7 @@ namespace DisplayMagician.UIForms 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.lbl_hotkey_assigned = new System.Windows.Forms.Label(); this.menu_profiles.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pb_down_arrow)).BeginInit(); this.SuspendLayout(); @@ -345,6 +346,20 @@ namespace DisplayMagician.UIForms this.btn_hotkey.UseVisualStyleBackColor = true; this.btn_hotkey.Click += new System.EventHandler(this.btn_hotkey_Click); // + // lbl_hotkey_assigned + // + this.lbl_hotkey_assigned.AutoSize = true; + this.lbl_hotkey_assigned.BackColor = System.Drawing.Color.Transparent; + this.lbl_hotkey_assigned.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbl_hotkey_assigned.ForeColor = System.Drawing.Color.White; + this.lbl_hotkey_assigned.Location = new System.Drawing.Point(20, 785); + this.lbl_hotkey_assigned.Name = "lbl_hotkey_assigned"; + this.lbl_hotkey_assigned.Size = new System.Drawing.Size(57, 16); + this.lbl_hotkey_assigned.TabIndex = 36; + this.lbl_hotkey_assigned.Text = "Hotkey: "; + this.lbl_hotkey_assigned.Visible = false; + this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click); + // // DisplayProfileForm // this.AcceptButton = this.btn_apply; @@ -354,6 +369,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.lbl_hotkey_assigned); this.Controls.Add(this.btn_hotkey); this.Controls.Add(this.btn_save); this.Controls.Add(this.lbl_save_profile); @@ -412,6 +428,7 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.Button btn_save; private System.Windows.Forms.SaveFileDialog dialog_save; private System.Windows.Forms.Button btn_hotkey; + private System.Windows.Forms.Label lbl_hotkey_assigned; } } diff --git a/DisplayMagician/UIForms/DisplayProfileForm.cs b/DisplayMagician/UIForms/DisplayProfileForm.cs index d7eb37e..618718e 100644 --- a/DisplayMagician/UIForms/DisplayProfileForm.cs +++ b/DisplayMagician/UIForms/DisplayProfileForm.cs @@ -463,16 +463,25 @@ namespace DisplayMagician.UIForms private void btn_hotkey_Click(object sender, EventArgs e) { Hotkey testHotkey = new Hotkey(); - var displayHotkeyForm = new HotkeyForm(testHotkey); + string hotkeyHeading = $"Choose a '{_selectedProfile.Name}' Display Profile Hotkey"; + string hotkeyDescription = $"Choose a Hotkey (a keyboard shortcut) so that you can apply to this" + Environment.NewLine + + "screen using your keyboard. This must be a Hotkey that" + Environment.NewLine + + "is unique across all your applications otherwise DisplayMagician" + Environment.NewLine + + "might not see it."; + HotkeyForm displayHotkeyForm = new HotkeyForm(testHotkey,hotkeyHeading, hotkeyDescription); //ilv_saved_shortcuts.SuspendLayout(); displayHotkeyForm.ShowDialog(this); if (displayHotkeyForm.DialogResult == DialogResult.OK) { - MessageBox.Show($"We got the hotkey {displayHotkeyForm.Hotkey.ToString()}", "results", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show($"We got the hotkey {displayHotkeyForm.Hotkey}", "results", MessageBoxButtons.OK, MessageBoxIcon.Error); // As this is an edit, we need to manually force saving the shortcut library //ShortcutRepository.SaveShortcuts(); } } + private void lbl_hotkey_assigned_Click(object sender, EventArgs e) + { + btn_hotkey.PerformClick(); + } } } \ No newline at end of file diff --git a/DisplayMagician/UIForms/HotkeyForm.Designer.cs b/DisplayMagician/UIForms/HotkeyForm.Designer.cs index 3e552e2..27b473d 100644 --- a/DisplayMagician/UIForms/HotkeyForm.Designer.cs +++ b/DisplayMagician/UIForms/HotkeyForm.Designer.cs @@ -36,12 +36,13 @@ namespace DisplayMagician.UIForms this.btn_clear = new System.Windows.Forms.Button(); this.lbl_hotkey_heading = new System.Windows.Forms.Label(); this.lbl_hotkey_description = new System.Windows.Forms.Label(); + this.btn_back = new System.Windows.Forms.Button(); this.SuspendLayout(); // // txt_hotkey // this.txt_hotkey.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txt_hotkey.Location = new System.Drawing.Point(61, 152); + this.txt_hotkey.Location = new System.Drawing.Point(86, 153); this.txt_hotkey.Name = "txt_hotkey"; this.txt_hotkey.Size = new System.Drawing.Size(270, 26); this.txt_hotkey.TabIndex = 1; @@ -51,7 +52,7 @@ namespace DisplayMagician.UIForms this.lbl_hotkey_selector.AutoSize = true; this.lbl_hotkey_selector.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); this.lbl_hotkey_selector.ForeColor = System.Drawing.Color.White; - this.lbl_hotkey_selector.Location = new System.Drawing.Point(63, 182); + this.lbl_hotkey_selector.Location = new System.Drawing.Point(85, 182); this.lbl_hotkey_selector.Name = "lbl_hotkey_selector"; this.lbl_hotkey_selector.Size = new System.Drawing.Size(270, 13); this.lbl_hotkey_selector.TabIndex = 2; @@ -66,7 +67,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(162, 222); + this.btn_save.Location = new System.Drawing.Point(201, 222); this.btn_save.Name = "btn_save"; this.btn_save.Size = new System.Drawing.Size(118, 40); this.btn_save.TabIndex = 3; @@ -82,7 +83,7 @@ namespace DisplayMagician.UIForms this.btn_clear.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown; this.btn_clear.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn_clear.ForeColor = System.Drawing.Color.White; - this.btn_clear.Location = new System.Drawing.Point(337, 152); + this.btn_clear.Location = new System.Drawing.Point(363, 153); this.btn_clear.Name = "btn_clear"; this.btn_clear.Size = new System.Drawing.Size(75, 26); this.btn_clear.TabIndex = 6; @@ -92,33 +93,52 @@ namespace DisplayMagician.UIForms // // lbl_hotkey_heading // + this.lbl_hotkey_heading.Anchor = System.Windows.Forms.AnchorStyles.Top; this.lbl_hotkey_heading.AutoSize = true; this.lbl_hotkey_heading.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbl_hotkey_heading.ForeColor = System.Drawing.Color.White; - this.lbl_hotkey_heading.Location = new System.Drawing.Point(58, 23); + this.lbl_hotkey_heading.Location = new System.Drawing.Point(97, 23); this.lbl_hotkey_heading.Name = "lbl_hotkey_heading"; this.lbl_hotkey_heading.Size = new System.Drawing.Size(326, 20); this.lbl_hotkey_heading.TabIndex = 7; this.lbl_hotkey_heading.Text = "Choose a Hotkey for this Display Profile"; + this.lbl_hotkey_heading.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // lbl_hotkey_description // this.lbl_hotkey_description.AutoSize = true; this.lbl_hotkey_description.BackColor = System.Drawing.Color.Black; this.lbl_hotkey_description.ForeColor = System.Drawing.Color.White; - this.lbl_hotkey_description.Location = new System.Drawing.Point(66, 67); + this.lbl_hotkey_description.Location = new System.Drawing.Point(105, 67); this.lbl_hotkey_description.Name = "lbl_hotkey_description"; this.lbl_hotkey_description.Size = new System.Drawing.Size(318, 52); this.lbl_hotkey_description.TabIndex = 0; this.lbl_hotkey_description.Text = resources.GetString("lbl_hotkey_description.Text"); this.lbl_hotkey_description.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_back + // + this.btn_back.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btn_back.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btn_back.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed; + this.btn_back.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown; + this.btn_back.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_back.ForeColor = System.Drawing.Color.White; + this.btn_back.Location = new System.Drawing.Point(434, 239); + this.btn_back.Name = "btn_back"; + this.btn_back.Size = new System.Drawing.Size(75, 23); + this.btn_back.TabIndex = 8; + this.btn_back.Text = "&Back"; + this.btn_back.UseVisualStyleBackColor = true; + this.btn_back.Click += new System.EventHandler(this.btn_back_Click); + // // HotkeyForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(442, 274); + this.ClientSize = new System.Drawing.Size(521, 274); + this.Controls.Add(this.btn_back); this.Controls.Add(this.lbl_hotkey_heading); this.Controls.Add(this.btn_clear); this.Controls.Add(this.btn_save); @@ -142,5 +162,6 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.Button btn_clear; private System.Windows.Forms.Label lbl_hotkey_heading; private System.Windows.Forms.Label lbl_hotkey_description; + private System.Windows.Forms.Button btn_back; } } \ No newline at end of file diff --git a/DisplayMagician/UIForms/HotkeyForm.cs b/DisplayMagician/UIForms/HotkeyForm.cs index 75961a3..5572a54 100644 --- a/DisplayMagician/UIForms/HotkeyForm.cs +++ b/DisplayMagician/UIForms/HotkeyForm.cs @@ -16,17 +16,20 @@ namespace DisplayMagician.UIForms HotkeySelector hks; Hotkey myHotkey = null; - public Hotkey Hotkey { - get - { - return myHotkey; + public Hotkey Hotkey + { + get + { + return myHotkey; } - set + set { if (value is Hotkey) myHotkey = value; } + } + public HotkeyForm() { @@ -40,7 +43,7 @@ namespace DisplayMagician.UIForms this.ActiveControl = txt_hotkey; } - public HotkeyForm(Hotkey hotkeyToEdit = null, string hotkeyName = "") + public HotkeyForm(Hotkey hotkeyToEdit = null, string hotkeyHeading = "", string hotkeyDescription = "") { InitializeComponent(); @@ -52,13 +55,34 @@ namespace DisplayMagician.UIForms hks = new HotkeySelector(); hks.EmptyHotkeyText = ""; hks.Enable(txt_hotkey, hotkeyToEdit); - this.ActiveControl = txt_hotkey; + this.ActiveControl = txt_hotkey; + + if (!String.IsNullOrEmpty(hotkeyHeading)) + { + if (hotkeyHeading.Length > 60) + lbl_hotkey_heading.Text = hotkeyHeading.Substring(0,50); + else + lbl_hotkey_heading.Text = hotkeyHeading; + lbl_hotkey_description.Text = hotkeyDescription; + } + else + { + lbl_hotkey_heading.Text = $"Choose a Hotkey"; + lbl_hotkey_description.Text = $"Choose a Hotkey (a keyboard shortcut) so that you can apply to this" + Environment.NewLine + + "screen using your keyboard. This must be a Hotkey that" + Environment.NewLine + + "is unique across all your applications otherwise DisplayMagician" + Environment.NewLine + + "might not see it."; + } + Point newHeadingPoint = new Point((this.Width - lbl_hotkey_heading.Width) / 2, lbl_hotkey_heading.Location.Y); + lbl_hotkey_heading.Location = newHeadingPoint; } private void btn_clear_Click(object sender, EventArgs e) { - hks.Reset(txt_hotkey); + this.DialogResult = DialogResult.None; + hks.Clear(txt_hotkey); + this.ActiveControl = txt_hotkey; } private void btn_save_Click(object sender, EventArgs e) @@ -77,5 +101,11 @@ namespace DisplayMagician.UIForms this.DialogResult = DialogResult.OK; this.Close(); } + + private void btn_back_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } } } diff --git a/DisplayMagician/UIForms/ShortcutForm.Designer.cs b/DisplayMagician/UIForms/ShortcutForm.Designer.cs index 1feac7d..08104f1 100644 --- a/DisplayMagician/UIForms/ShortcutForm.Designer.cs +++ b/DisplayMagician/UIForms/ShortcutForm.Designer.cs @@ -153,6 +153,7 @@ namespace DisplayMagician.UIForms this.lbl_shortcut_name = new System.Windows.Forms.Label(); 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.tabc_shortcut.SuspendLayout(); this.tabp_display.SuspendLayout(); this.tabp_audio.SuspendLayout(); @@ -1685,6 +1686,21 @@ namespace DisplayMagician.UIForms this.btn_hotkey.TabIndex = 36; this.btn_hotkey.Text = "&Hotkey"; this.btn_hotkey.UseVisualStyleBackColor = true; + this.btn_hotkey.Click += new System.EventHandler(this.btn_hotkey_Click); + // + // lbl_hotkey_assigned + // + this.lbl_hotkey_assigned.AutoSize = true; + this.lbl_hotkey_assigned.BackColor = System.Drawing.Color.Transparent; + this.lbl_hotkey_assigned.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbl_hotkey_assigned.ForeColor = System.Drawing.Color.White; + this.lbl_hotkey_assigned.Location = new System.Drawing.Point(26, 793); + this.lbl_hotkey_assigned.Name = "lbl_hotkey_assigned"; + this.lbl_hotkey_assigned.Size = new System.Drawing.Size(57, 16); + this.lbl_hotkey_assigned.TabIndex = 37; + this.lbl_hotkey_assigned.Text = "Hotkey: "; + this.lbl_hotkey_assigned.Visible = false; + this.lbl_hotkey_assigned.Click += new System.EventHandler(this.lbl_hotkey_assigned_Click); // // ShortcutForm // @@ -1694,6 +1710,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.lbl_hotkey_assigned); this.Controls.Add(this.btn_hotkey); this.Controls.Add(this.cb_autosuggest); this.Controls.Add(this.txt_shortcut_save_name); @@ -1877,5 +1894,6 @@ namespace DisplayMagician.UIForms private System.Windows.Forms.TextBox txt_alternative_game; private System.Windows.Forms.CheckBox cb_wait_alternative_game; private System.Windows.Forms.Button btn_hotkey; + private System.Windows.Forms.Label lbl_hotkey_assigned; } } \ No newline at end of file diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index 5e987cb..3b5bb8a 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -15,6 +15,7 @@ using Manina.Windows.Forms; using System.Windows.Forms.VisualStyles; using AudioSwitcher.AudioApi.CoreAudio; using AudioSwitcher.AudioApi; +using WK.Libraries.HotkeyListenerNS; namespace DisplayMagician.UIForms { @@ -2225,5 +2226,29 @@ namespace DisplayMagician.UIForms } } } + + private void btn_hotkey_Click(object sender, EventArgs e) + { + Hotkey testHotkey = new Hotkey(); + string hotkeyHeading = $"Choose a '{_shortcutToEdit.Name}' Shortcut Hotkey"; + string hotkeyDescription = $"Choose a Hotkey (a keyboard shortcut) so that you can start this" + Environment.NewLine + + "game shortcut using your keyboard. This must be a Hotkey that" + Environment.NewLine + + "is unique across all your applications otherwise DisplayMagician" + Environment.NewLine + + "might not see it."; + HotkeyForm displayHotkeyForm = new HotkeyForm(testHotkey, hotkeyHeading, hotkeyDescription); + //ilv_saved_shortcuts.SuspendLayout(); + displayHotkeyForm.ShowDialog(this); + if (displayHotkeyForm.DialogResult == DialogResult.OK) + { + MessageBox.Show($"We got the hotkey {displayHotkeyForm.Hotkey}", "results", MessageBoxButtons.OK, MessageBoxIcon.Error); + // As this is an edit, we need to manually force saving the shortcut library + //ShortcutRepository.SaveShortcuts(); + } + } + + private void lbl_hotkey_assigned_Click(object sender, EventArgs e) + { + btn_hotkey.PerformClick(); + } } } \ No newline at end of file