예제 #1
0
        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}");
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 public void Remove(KeyMacroBinding emp)
 {
     this.List.Remove(emp);
 }
예제 #4
0
        // Collection methods

        public void Add(KeyMacroBinding emp)
        {
            this.List.Add(emp);
        }