WingMan – Diff between revs 10 and 14
?pathlinks?
Rev 10 | Rev 14 | |||
---|---|---|---|---|
1 | using System; |
1 | using System; |
|
2 | using System.Collections.Generic; |
2 | using System.Collections.Generic; |
|
3 | using System.Linq; |
3 | using System.Linq; |
|
4 | |
4 | |
|
5 | namespace WingMan.MouseKey |
5 | namespace WingMan.Bindings |
|
6 | { |
6 | { |
|
7 | public class KeyBinding : IEquatable<KeyBinding> |
7 | public class KeyBinding : IEquatable<KeyBinding> |
|
8 | { |
8 | { |
|
9 | public KeyBinding() |
9 | public KeyBinding() |
|
10 | { |
10 | { |
|
11 | } |
11 | } |
|
12 | |
12 | |
|
13 | public KeyBinding(string name, List<string> keys) : this() |
13 | public KeyBinding(string name, List<string> keys) : this() |
|
14 | { |
14 | { |
|
15 | Name = name; |
15 | Name = name; |
|
16 | Keys = keys; |
16 | Keys = keys; |
|
17 | } |
17 | } |
|
18 | |
18 | |
|
19 | public string DisplayName => $"{Name} ({string.Join(" + ", Keys.ToArray())})"; |
19 | public string DisplayName => $"{Name} ({string.Join(" + ", Keys.ToArray())})"; |
|
20 | |
20 | |
|
21 | public string Name { get; set; } = string.Empty; |
21 | public string Name { get; set; } = string.Empty; |
|
22 | |
22 | |
|
23 | public List<string> Keys { get; set; } = new List<string>(); |
23 | public List<string> Keys { get; set; } = new List<string>(); |
|
24 | |
24 | |
|
25 | public bool Equals(KeyBinding other) |
25 | public bool Equals(KeyBinding other) |
|
26 | { |
26 | { |
|
27 | if (ReferenceEquals(null, other)) return false; |
27 | if (ReferenceEquals(null, other)) return false; |
|
28 | if (ReferenceEquals(this, other)) return true; |
28 | if (ReferenceEquals(this, other)) return true; |
|
29 | return string.Equals(Name, other.Name) && Keys.SequenceEqual(other.Keys); |
29 | return string.Equals(Name, other.Name) && Keys.SequenceEqual(other.Keys); |
|
30 | } |
30 | } |
|
31 | |
31 | |
|
32 | public override bool Equals(object obj) |
32 | public override bool Equals(object obj) |
|
33 | { |
33 | { |
|
34 | if (ReferenceEquals(null, obj)) return false; |
34 | if (ReferenceEquals(null, obj)) return false; |
|
35 | if (ReferenceEquals(this, obj)) return true; |
35 | if (ReferenceEquals(this, obj)) return true; |
|
36 | if (obj.GetType() != GetType()) return false; |
36 | if (obj.GetType() != GetType()) return false; |
|
37 | return Equals((KeyBinding) obj); |
37 | return Equals((KeyBinding) obj); |
|
38 | } |
38 | } |
|
39 | |
39 | |
|
40 | public override int GetHashCode() |
40 | public override int GetHashCode() |
|
41 | { |
41 | { |
|
42 | unchecked |
42 | unchecked |
|
43 | { |
43 | { |
|
44 | return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ (Keys != null ? Keys.GetHashCode() : 0); |
44 | return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ (Keys != null ? Keys.GetHashCode() : 0); |
|
45 | } |
45 | } |
|
46 | } |
46 | } |
|
47 | } |
47 | } |
|
48 | } |
48 | } |
|
49 | |
49 | |