WIP] commit where I'm up to

This is a stopgap place to commit
while I test out another hotkey lib.
This commit is contained in:
Terry MacDonald 2021-04-27 21:57:27 +12:00
parent 9dc68ff506
commit 92c0678e79
4 changed files with 63 additions and 7 deletions

View File

@ -245,6 +245,7 @@ namespace DisplayMagician.UIForms
// Refresh the Profile UI
RefreshDisplayProfileUI();
}
@ -478,6 +479,7 @@ namespace DisplayMagician.UIForms
"might not see it.";
HotkeyForm displayHotkeyForm = new HotkeyForm(testHotkey,hotkeyHeading, hotkeyDescription);
//ilv_saved_shortcuts.SuspendLayout();
//Program.HotkeyListener.SuspendOn(displayHotkeyForm);
displayHotkeyForm.ShowDialog(this);
if (displayHotkeyForm.DialogResult == DialogResult.OK)
{

View File

@ -13,6 +13,7 @@ namespace DisplayMagician.UIForms
{
public partial class HotkeyForm : Form
{
//HotkeyListener myHotkeyListener = null;
HotkeySelector hks;
Hotkey myHotkey = null;
@ -51,6 +52,8 @@ namespace DisplayMagician.UIForms
{
InitializeComponent();
//myHotkeyListener = hotkeyListener;
if (hotkeyToEdit == null)
myHotkey = new Hotkey();
else

View File

@ -11,6 +11,7 @@ using System.Net;
using Windows.Data.Xml.Dom;
using Microsoft.Toolkit.Uwp.Notifications;
using WK.Libraries.HotkeyListenerNS;
using System.Collections.Generic;
namespace DisplayMagician.UIForms
{
@ -19,7 +20,12 @@ namespace DisplayMagician.UIForms
private bool allowVisible; // ContextMenu's Show command used
private bool allowClose; // ContextMenu's Exit command used
private HotkeyListener hotkeyListener = new HotkeyListener();
private Hotkey hotkeyMainWindow;
private Hotkey hotkeyShortcutLibraryWindow;
private Hotkey hotkeyDisplayProfileWindow;
private Dictionary<Hotkey, string> hotkeyDisplayProfiles = new Dictionary<Hotkey, string>() { };
private Dictionary<Hotkey, string> hotkeyShortcuts = new Dictionary<Hotkey, string>() { };
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
@ -36,11 +42,36 @@ namespace DisplayMagician.UIForms
// 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);
//hotkeyMainWindow = new Hotkey(Keys.Control | Keys.Shift, Keys.W);
//Program.HotkeyListener.Add(hotkeyMainWindow);
/*if (Program.AppProgramSettings.MainWindowHotkey)
hotkeyMainWindow = new Hotkey(Program.AppProgramSettings.MainWindowHotkey);
if (Program.AppProgramSettings.ShortcutLibraryWindow)
hotkeyShortcutLibraryWindow = new Hotkey(Program.AppProgramSettings.ShortcutLibraryWindow);
if (Program.AppProgramSettings.DisplayProfileWindow)
hotkeyDisplayProfileWindow = new Hotkey(Program.AppProgramSettings.DisplayProfileWindow);*/
// Add all the Profile Hotkeys that are set
foreach (ProfileItem myProfile in ProfileRepository.AllProfiles)
{
if (myProfile.Hotkey is Hotkey && myProfile.Hotkey.Modifiers != Keys.None && myProfile.Hotkey.KeyCode != Keys.None)
{
hotkeyDisplayProfiles.Add(myProfile.Hotkey, myProfile.UUID);
}
}
// Add all the Shortcut Hotkeys that are set
foreach (ShortcutItem myShortcut in ShortcutRepository.AllShortcuts)
{
if (myShortcut.Hotkey is Hotkey && myShortcut.Hotkey.Modifiers != Keys.None && myShortcut.Hotkey.KeyCode != Keys.None)
{
hotkeyShortcuts.Add(myShortcut.Hotkey, myShortcut.UUID);
}
}
// And now connect up our processing function
Program.HotkeyListener.HotkeyPressed += Hkl_WindowHotkeyPressed;
// Register a HotkeyPressed event.
Program.HotkeyListener.HotkeyPressed += Hkl_MainWindowHotkeyPressed;
if (Program.AppProgramSettings.MinimiseOnStart)
@ -103,6 +134,8 @@ namespace DisplayMagician.UIForms
shortcutLibraryForm.ShowDialog(this);
}
}
protected override void SetVisibleCore(bool value)
@ -503,10 +536,28 @@ namespace DisplayMagician.UIForms
openApplicationWindow();
}
private void Hkl_MainWindowHotkeyPressed(object sender, HotkeyEventArgs e)
private void Hkl_WindowHotkeyPressed(object sender, HotkeyEventArgs e)
{
if (e.Hotkey == hotkeyMainWindow)
openApplicationWindow();
else if (e.Hotkey == hotkeyDisplayProfileWindow)
btn_setup_display_profiles.PerformClick();
else if (e.Hotkey == hotkeyDisplayProfileWindow)
btn_setup_game_shortcuts.PerformClick();
else if (hotkeyDisplayProfiles.ContainsKey(e.Hotkey))
{
string displayProfileUUID = hotkeyDisplayProfiles[e.Hotkey];
ProfileItem chosenProfile = ProfileRepository.GetProfile(displayProfileUUID);
if (chosenProfile is ProfileItem)
Program.ApplyProfile(chosenProfile);
}
else if (hotkeyShortcuts.ContainsKey(e.Hotkey))
{
string shortcutUUID = hotkeyShortcuts[e.Hotkey];
ShortcutItem chosenShortcut = ShortcutRepository.GetShortcut(shortcutUUID);
if (chosenShortcut is ShortcutItem)
ShortcutRepository.RunShortcut(chosenShortcut);
}
}
}
}

View File

@ -2241,7 +2241,7 @@ namespace DisplayMagician.UIForms
"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();
//Program.HotkeyListener.SuspendOn(displayHotkeyForm);
displayHotkeyForm.ShowDialog(this);
if (displayHotkeyForm.DialogResult == DialogResult.OK)
{