WingMan
/trunk/WingMan/MouseKey/KeyBinding.cs |
@@ -0,0 +1,48 @@ |
using System; |
using System.Collections.Generic; |
using System.Linq; |
|
namespace WingMan.MouseKey |
{ |
public class KeyBinding : IEquatable<KeyBinding> |
{ |
public KeyBinding() |
{ |
} |
|
public KeyBinding(string name, List<string> keys) : this() |
{ |
Name = name; |
Keys = keys; |
} |
|
public string DisplayName => $"{Name} ({string.Join(" + ", Keys.ToArray())})"; |
|
public string Name { get; set; } = string.Empty; |
|
public List<string> Keys { get; set; } = new List<string>(); |
|
public bool Equals(KeyBinding other) |
{ |
if (ReferenceEquals(null, other)) return false; |
if (ReferenceEquals(this, other)) return true; |
return string.Equals(Name, other.Name) && Keys.SequenceEqual(other.Keys); |
} |
|
public override bool Equals(object obj) |
{ |
if (ReferenceEquals(null, obj)) return false; |
if (ReferenceEquals(this, obj)) return true; |
if (obj.GetType() != GetType()) return false; |
return Equals((KeyBinding) obj); |
} |
|
public override int GetHashCode() |
{ |
unchecked |
{ |
return ((Name != null ? Name.GetHashCode() : 0) * 397) ^ (Keys != null ? Keys.GetHashCode() : 0); |
} |
} |
} |
} |