Example #1
0
        public static IEnumerable<Action<PadEditor>> ResolveMacro(Mode mode, string macro)
        {
            List<Action<PadEditor>> keys = new List<Action<PadEditor>>();

            macro = macro.Substring(0);

            while(macro.Length > 0) {
                if(Char.IsDigit(macro[0])) {
                    string digits = new String(macro.TakeWhile(c => Char.IsDigit(c)).ToArray());

                    macro = macro.Substring(digits.Length);
                    keys.Add(new Action<PadEditor>(pe =>
                        pe.AddToCount(digits)));
                }
                else {
                    EditGesture gesture = ResolveKeyName(ref macro);

                    if(mode.Gestures.ContainsKey(gesture))
                        keys.Add(mode.Gestures[gesture]);
                    else
                        throw new Exception("Key not found: " + gesture.ToString());
                }
            }

            return keys;
        }
Example #2
0
 public static bool HasMacros(Mode mode)
 {
     return maps.ContainsKey(mode);
 }
Example #3
0
        private void SetMode(Mode mode)
        {
            currentMode = mode;
            Pad.Cursor.Type = mode.Cursor;

            RevertMode();
        }
Example #4
0
 public static IDictionary<InputGesture, Action<PadEditor>> GetMacros(Mode mode)
 {
     return maps[mode];
 }
Example #5
0
 private void OnMappingAdded(Mode mode, InputGesture gesture, Action<PadEditor> action)
 {
     if(mode == currentMode)
         BindMacro(gesture, action);
 }