public static string ConvertToString(KeyMacroBinding v) { var strHK = ""; switch (v.Hotkey) { case Key.Unknown: break; default: strHK = v.Hotkey.ToString(); break; } var strMethod = "No Action"; switch (v.Action) { case null: break; default: strMethod = v.Action.Method.Name; break; } return($"[{strHK}]-{strMethod}"); }
public DefaultMacroController() { var typeattr = typeof(DefaultValueAttribute); var type1 = this.GetType(); foreach (var method1 in type1.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance)) { //if (method1.IsPublic)//&& method1.IsStatic) //{ //} var arro = method1.GetCustomAttributes(typeof(MacroActionAttribute), false); if (arro != null && arro.Length > 0) { } else { continue; } var em = new KeyMacroBinding(); //this.GetType().GetMethod("dummy").CreateDelegate(typeof(Action), this) as Action; if (method1.IsStatic) { em.Action = method1.CreateDelegate(typeof(Action)) as Action; } else { em.Action = method1.CreateDelegate(typeof(Action), this) as Action; } arro = method1.GetCustomAttributes(typeattr, false); if (arro != null && arro.Length > 0) { var k = Key.Unknown; k = (Key)(arro[0] as DefaultValueAttribute).Value; em.Hotkey = k; } keybindings.Add(em); } }
public void Remove(KeyMacroBinding emp) { this.List.Remove(emp); }
// Collection methods public void Add(KeyMacroBinding emp) { this.List.Add(emp); }