diff --git a/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs b/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs
index f9de64b..8b253c5 100644
--- a/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs
+++ b/DisplayMagician/UIForms/DisplayProfileForm.Designer.cs
@@ -343,6 +343,7 @@ namespace DisplayMagician.UIForms
this.btn_hotkey.TabIndex = 35;
this.btn_hotkey.Text = "&Hotkey";
this.btn_hotkey.UseVisualStyleBackColor = true;
+ this.btn_hotkey.Click += new System.EventHandler(this.btn_hotkey_Click);
//
// DisplayProfileForm
//
diff --git a/DisplayMagician/UIForms/DisplayProfileForm.cs b/DisplayMagician/UIForms/DisplayProfileForm.cs
index 6ce5f83..d7eb37e 100644
--- a/DisplayMagician/UIForms/DisplayProfileForm.cs
+++ b/DisplayMagician/UIForms/DisplayProfileForm.cs
@@ -7,6 +7,7 @@ using DisplayMagicianShared;
using Manina.Windows.Forms;
using System.Drawing;
using System.Collections.Generic;
+using WK.Libraries.HotkeyListenerNS;
namespace DisplayMagician.UIForms
{
@@ -459,60 +460,19 @@ namespace DisplayMagician.UIForms
}
}
- /*private static void MainWindow_Closed(object sender, EventArgs e)
+ private void btn_hotkey_Click(object sender, EventArgs e)
{
- DeviceNotification.UnRegisterUsbDeviceNotification();
- DeviceNotification.UnRegisterMonitorDeviceNotification();
- }
-
- protected override void OnSourceInitialized(EventArgs e)
- {
- base.OnSourceInitialized(e);
-
- if (!(PresentationSource.FromVisual(this) is HwndSource source))
- return;
-
- source.AddHook(this.WndProc);
-
- DeviceNotification.RegisterUsbDeviceNotification(source.Handle);
- DeviceNotification.RegisterMonitorDeviceNotification(source.Handle);
- }*/
-
- // Notification registeration for display detection from here http://codetips.nl/detectmonitor.html
-
- /*protected override void WndProc(ref Message m)
- {
- const int WM_SETTINGCHANGE = 0x001A;
- const int SPI_SETWORKAREA = 0x02F;
- const int WM_DISPLAYCHANGE = 0x007E;
- const int WM_DEVICECHANGE = 0x0219; // WM Device change message ID
- const int DBT_DEVICEARRIVAL = 0x8000; // WM Device Change Event: System detected a new device
- const int DBT_DEVICEREMOVECOMPLETE = 0x8004; // WM Device Change Event: Device is gone
-
-
- const int x_bitshift = 0;
- const int y_bitshift = 16;
- const int xy_mask = 0xFFFF;
-
- bool displayChange = false;
-
- switch (m.Msg)
+ Hotkey testHotkey = new Hotkey();
+ var displayHotkeyForm = new HotkeyForm(testHotkey);
+ //ilv_saved_shortcuts.SuspendLayout();
+ displayHotkeyForm.ShowDialog(this);
+ if (displayHotkeyForm.DialogResult == DialogResult.OK)
{
- case WM_DISPLAYCHANGE:
- case DeviceNotification.DbtDeviceRemoveComplete:
- case DeviceNotification.DbtDeviceArrival:
- {
- if (DeviceNotification.IsMonitor(lParam))
- Debug.WriteLine($"Monitor {((int)wParam == DeviceNotification.DbtDeviceArrival ? "arrived" : "removed")}");
-
- if (DeviceNotification.IsUsbDevice(lParam))
- Debug.WriteLine($"Usb device {((int)wParam == DeviceNotification.DbtDeviceArrival ? "arrived" : "removed")}");
- }
- break;
+ MessageBox.Show($"We got the hotkey {displayHotkeyForm.Hotkey.ToString()}", "results", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ // As this is an edit, we need to manually force saving the shortcut library
+ //ShortcutRepository.SaveShortcuts();
}
-
- base.WndProc(ref m);
- }*/
+ }
}
}
\ No newline at end of file
diff --git a/DisplayMagician/UIForms/HotkeyForm.Designer.cs b/DisplayMagician/UIForms/HotkeyForm.Designer.cs
index 4dfe095..3e552e2 100644
--- a/DisplayMagician/UIForms/HotkeyForm.Designer.cs
+++ b/DisplayMagician/UIForms/HotkeyForm.Designer.cs
@@ -29,39 +29,118 @@ namespace DisplayMagician.UIForms
///
private void InitializeComponent()
{
- this.lbl_hotkey = new System.Windows.Forms.Label();
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HotkeyForm));
+ this.txt_hotkey = new System.Windows.Forms.TextBox();
+ this.lbl_hotkey_selector = new System.Windows.Forms.Label();
+ this.btn_save = new System.Windows.Forms.Button();
+ 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.SuspendLayout();
//
- // lbl_hotkey
+ // txt_hotkey
//
- this.lbl_hotkey.AutoSize = true;
- this.lbl_hotkey.BackColor = System.Drawing.Color.Black;
- this.lbl_hotkey.ForeColor = System.Drawing.Color.White;
- this.lbl_hotkey.Location = new System.Drawing.Point(42, 32);
- this.lbl_hotkey.Name = "lbl_hotkey";
- this.lbl_hotkey.Size = new System.Drawing.Size(525, 13);
- this.lbl_hotkey.TabIndex = 0;
- this.lbl_hotkey.Text = "You can set a Hotkey (a keyboard shortcut) so that you can apply this Display Pro" +
- "file just using your keyboard.";
+ 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.Name = "txt_hotkey";
+ this.txt_hotkey.Size = new System.Drawing.Size(270, 26);
+ this.txt_hotkey.TabIndex = 1;
+ //
+ // lbl_hotkey_selector
+ //
+ 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.Name = "lbl_hotkey_selector";
+ this.lbl_hotkey_selector.Size = new System.Drawing.Size(270, 13);
+ this.lbl_hotkey_selector.TabIndex = 2;
+ this.lbl_hotkey_selector.Text = "Hold down the keys you\'d like to use, then release them";
+ //
+ // btn_save
+ //
+ this.btn_save.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.btn_save.BackColor = System.Drawing.Color.Black;
+ this.btn_save.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
+ this.btn_save.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
+ 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.Name = "btn_save";
+ this.btn_save.Size = new System.Drawing.Size(118, 40);
+ this.btn_save.TabIndex = 3;
+ this.btn_save.Text = "&Save";
+ this.btn_save.UseVisualStyleBackColor = false;
+ this.btn_save.Click += new System.EventHandler(this.btn_save_Click);
+ //
+ // btn_clear
+ //
+ this.btn_clear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.btn_clear.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btn_clear.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
+ 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.Name = "btn_clear";
+ this.btn_clear.Size = new System.Drawing.Size(75, 26);
+ this.btn_clear.TabIndex = 6;
+ this.btn_clear.Text = "&Clear";
+ this.btn_clear.UseVisualStyleBackColor = true;
+ this.btn_clear.Click += new System.EventHandler(this.btn_clear_Click);
+ //
+ // lbl_hotkey_heading
+ //
+ 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.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";
+ //
+ // 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.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;
//
// 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, 221);
- this.Controls.Add(this.lbl_hotkey);
+ this.ClientSize = new System.Drawing.Size(442, 274);
+ this.Controls.Add(this.lbl_hotkey_heading);
+ this.Controls.Add(this.btn_clear);
+ this.Controls.Add(this.btn_save);
+ this.Controls.Add(this.lbl_hotkey_selector);
+ this.Controls.Add(this.txt_hotkey);
+ this.Controls.Add(this.lbl_hotkey_description);
this.Name = "HotkeyForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
- this.Text = "Select a Hotkey";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Choose a Hotkey";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
-
- private System.Windows.Forms.Label lbl_hotkey;
+ private System.Windows.Forms.TextBox txt_hotkey;
+ private System.Windows.Forms.Label lbl_hotkey_selector;
+ private System.Windows.Forms.Button btn_save;
+ private System.Windows.Forms.Button btn_clear;
+ private System.Windows.Forms.Label lbl_hotkey_heading;
+ private System.Windows.Forms.Label lbl_hotkey_description;
}
}
\ No newline at end of file
diff --git a/DisplayMagician/UIForms/HotkeyForm.cs b/DisplayMagician/UIForms/HotkeyForm.cs
index 05d4994..75961a3 100644
--- a/DisplayMagician/UIForms/HotkeyForm.cs
+++ b/DisplayMagician/UIForms/HotkeyForm.cs
@@ -7,14 +7,75 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using WK.Libraries.HotkeyListenerNS;
namespace DisplayMagician.UIForms
{
public partial class HotkeyForm : Form
{
+ HotkeySelector hks;
+ Hotkey myHotkey = null;
+
+ public Hotkey Hotkey {
+ get
+ {
+ return myHotkey;
+ }
+ set
+ {
+ if (value is Hotkey)
+ myHotkey = value;
+ }
+ }
+
public HotkeyForm()
{
InitializeComponent();
+
+ myHotkey = new Hotkey();
+
+ hks = new HotkeySelector();
+ hks.EmptyHotkeyText = "";
+ hks.Enable(txt_hotkey);
+ this.ActiveControl = txt_hotkey;
+ }
+
+ public HotkeyForm(Hotkey hotkeyToEdit = null, string hotkeyName = "")
+ {
+ InitializeComponent();
+
+ if (hotkeyToEdit == null)
+ myHotkey = new Hotkey();
+ else
+ myHotkey = hotkeyToEdit;
+
+ hks = new HotkeySelector();
+ hks.EmptyHotkeyText = "";
+ hks.Enable(txt_hotkey, hotkeyToEdit);
+ this.ActiveControl = txt_hotkey;
+ }
+
+
+ private void btn_clear_Click(object sender, EventArgs e)
+ {
+ hks.Reset(txt_hotkey);
+ }
+
+ private void btn_save_Click(object sender, EventArgs e)
+ {
+ Program.HotkeyListener.Update
+ (
+ // Reference the current clipping hotkey for directly updating
+ // the hotkey without a need for restarting your application.
+ ref myHotkey,
+
+ // Convert the selected hotkey's text representation
+ // to a Hotkey object and update it.
+ HotkeyListener.Convert(txt_hotkey.Text)
+ );
+ this.Hotkey = myHotkey;
+ this.DialogResult = DialogResult.OK;
+ this.Close();
}
}
}
diff --git a/DisplayMagician/UIForms/HotkeyForm.resx b/DisplayMagician/UIForms/HotkeyForm.resx
index 1af7de1..42566c4 100644
--- a/DisplayMagician/UIForms/HotkeyForm.resx
+++ b/DisplayMagician/UIForms/HotkeyForm.resx
@@ -117,4 +117,10 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Choose a Hotkey (a keyboard shortcut) so that you can apply this
+Display Profile using your keyboard. This must be a Hotkey that
+is unique across all your applications otherwise DisplayMagician
+might not see it.
+
\ No newline at end of file