Files
FSI.BT.IR.Tools/FSI.BT.Tools/TimeStampToClipboard/Business/KeyboardInput.cs
Stephan Maier 647f938eee v1.2
2024-08-27 08:10:27 +02:00

56 lines
1.4 KiB
C#

// <copyright file="KeyboardInput.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
using FSI.BT.Tools.TimeStampToClipboard.Helper;
using System;
namespace FSI.BT.Tools.TimeStampToClipboard.Handler
{
internal class KeyboardInput : IDisposable
{
private readonly KeyboardHook hook = new();
private int iRowKey = -1;
private int iMenuKey;
public KeyboardInput()
{
}
public event Action HotKeyPressed;
public void Dispose()
{
hook.KeyPressed -= Hook_KeyPressed;
hook.Dispose();
}
public void RegisterHotKey()
{
if (!string.IsNullOrEmpty(Global.Vars.TimeStampSettings.HotKey))
{
try
{
hook.RegisterHotKey();
hook.KeyPressed += Hook_KeyPressed;
}
catch (InvalidOperationException ex)
{
//Log.Warn($"key:'{Properties.Settings.Default.HotKey}'", ex);
Global.Vars.TimeStampSettings.HotKey = string.Empty;
//Properties.Settings.Default.Save();
}
}
}
private void Hook_KeyPressed(object sender, FSI.BT.Tools.TimeStampToClipboard.Helper.KeyPressedEventArgs e)
{
HotKeyPressed?.Invoke();
}
}
}