public static HotKey Get(HotKeyType type) { var text = Get(type.ToString()); if (string.IsNullOrWhiteSpace(text)) { return(null); } var temp = text.Split('#'); var hotkey = HotKey.FromType(type); hotkey.Modifiers = (KeyModifier)Enum.Parse(typeof(KeyModifier), temp[0]); switch (temp[1]) { case "`": hotkey.Key = Keys.Oemtilde; break; case "Enter": hotkey.Key = Keys.Enter; break; case "CapsLock": hotkey.Key = Keys.CapsLock; break; default: hotkey.Key = (Keys)Enum.Parse(typeof(Keys), temp[1]); break; } return(hotkey); }
public static HotKey FromType(HotKeyType hotKeyType) { var type = typeof(HotKeyType); var attrs = type.GetField(hotKeyType.ToString()).GetCustomAttributes(typeof(HotKey), false); if (attrs.Length == 0) { return(null); } var attr = attrs[0] as HotKey; // ReSharper disable once PossibleNullReferenceException attr.HotKeyType = hotKeyType; return(attr); }
void IHotKey.getHotKeyDownEvent() { Debug.Log(keyType.ToString() + "== is down"); }