forked from kurumpa/dotSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardEventArgs.cs
More file actions
63 lines (58 loc) · 1.83 KB
/
Copy pathKeyboardEventArgs.cs
File metadata and controls
63 lines (58 loc) · 1.83 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
using System;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Windows.Forms;
namespace dotSwitcher
{
[Serializable]
public class KeyboardEventArgs : KeyEventArgs, ISerializable
{
public KeyboardEventArgs() : base(Keys.None) { }
public bool Win { get; private set; }
public KeyboardEventArgs(SerializationInfo info, StreamingContext context)
: base((Keys)info.GetValue("keyData", typeof(Keys)))
{
Win = (bool)info.GetValue("winMod", typeof(bool));
}
public KeyboardEventArgs(Keys keyData, bool isWinDown)
: base(keyData)
{
Win = isWinDown;
}
public override bool Equals(Object obj)
{
if (obj == null)
{
return false;
}
var p = obj as KeyboardEventArgs;
if (p == null)
{
return false;
}
var equals = p.KeyData == KeyData &&
p.KeyCode == KeyCode &&
p.Win == Win;
return equals;
}
public override int GetHashCode()
{
return (int)(base.GetHashCode() ^ Win.GetHashCode());
}
public override string ToString()
{
var result =
(Shift ? Keys.Shift.ToString() + " + " : "") +
(Control ? Keys.Control.ToString() + " + " : "") +
(Alt ? Keys.Alt.ToString() + " + " : "") +
(Win ? "Win + " : "") +
((Keys)KeyCode).ToString();
return result;
}
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("keyData", KeyData, typeof(Keys));
info.AddValue("winMod", Win, typeof(bool));
}
}
}