-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHotKeyObject.cs
57 lines (52 loc) · 2.06 KB
/
HotKeyObject.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
namespace RConControl {
public class HotKeyObject {
//*************************************************
// Variables
//*************************************************
[XmlElement(ElementName = "Hotkey")]
public Keys HotKey { get; set; }
[XmlElement(ElementName = "Modifier")]
public HotKeyClass.MODKEY Modifier { get; set; }
[XmlElement(ElementName = "HotkeyID")]
public string HotKeyID { get; set; }
//*************************************************
// CTor
//*************************************************
public HotKeyObject() { Clear(); }
public HotKeyObject(HotKeyObject obj) {
HotKey = obj.HotKey;
Modifier = obj.Modifier;
HotKeyID = obj.HotKeyID;
}
//*************************************************
// Methods
//*************************************************
public void Clear() {
Modifier = HotKeyClass.MODKEY.MOD_NONE;
HotKey = Keys.None;
}
public override string ToString() {
StringBuilder sb = new StringBuilder();
if ((Modifier & HotKeyClass.MODKEY.MOD_CONTROL) == HotKeyClass.MODKEY.MOD_CONTROL) {
sb.Append(Keys.Control.ToString());
sb.Append(" + ");
}
if ((Modifier & HotKeyClass.MODKEY.MOD_ALT) == HotKeyClass.MODKEY.MOD_ALT) {
sb.Append(Keys.Alt.ToString());
sb.Append(" + ");
}
if ((Modifier & HotKeyClass.MODKEY.MOD_SHIFT) == HotKeyClass.MODKEY.MOD_SHIFT) {
sb.Append(Keys.Shift.ToString());
sb.Append(" + ");
}
if (HotKey != Keys.None) sb.Append(HotKey.ToString());
return sb.ToString().Trim().TrimEnd('+');
}
}
}