-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHotkeyHelper.cs
More file actions
67 lines (56 loc) · 1.99 KB
/
Copy pathHotkeyHelper.cs
File metadata and controls
67 lines (56 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System.Text;
using System.Windows.Forms;
using RTSS_time_reader.WindowsInterop;
namespace RTSS_time_reader
{
public static class HotkeyHelper
{
public static string GetDescription(this Win32A.KeyModifiers p_value)
{
if (p_value == Win32A.KeyModifiers.None)
return p_value.ToString();
var result = string.Empty;
var firstMod = true;
result += KeyModifierToString(p_value, Win32A.KeyModifiers.Ctrl, ref firstMod);
result += KeyModifierToString(p_value, Win32A.KeyModifiers.Alt, ref firstMod);
result += KeyModifierToString(p_value, Win32A.KeyModifiers.Shift, ref firstMod);
result += KeyModifierToString(p_value, Win32A.KeyModifiers.Win, ref firstMod);
return result;
}
private static string KeyModifierToString(Win32A.KeyModifiers p_value, Win32A.KeyModifiers modifier, ref bool firstMod)
{
string result = string.Empty;
if ((p_value & modifier) != 0)
{
if (firstMod)
result += modifier;
else
result += "+" + modifier;
firstMod = false;
}
return result;
}
}
public struct Hotkey
{
public Hotkey(Win32A.KeyModifiers p_modifiers, Keys p_key)
{
Modifiers = p_modifiers;
Key = p_key;
}
public Win32A.KeyModifiers Modifiers;
public System.Windows.Forms.Keys Key;
public bool IsEmpty
{
get { return (Modifiers == Win32A.KeyModifiers.None) && (Key == Keys.None); }
}
public static bool operator ==(Hotkey p_left, Hotkey p_right)
{
return (p_left.Key == p_right.Key) && (p_left.Modifiers == p_right.Modifiers);
}
public static bool operator !=(Hotkey p_left, Hotkey p_right)
{
return false == (p_left == p_right);
}
}
}