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; }
public static bool HasMacros(Mode mode) { return maps.ContainsKey(mode); }
private void SetMode(Mode mode) { currentMode = mode; Pad.Cursor.Type = mode.Cursor; RevertMode(); }
public static IDictionary<InputGesture, Action<PadEditor>> GetMacros(Mode mode) { return maps[mode]; }
private void OnMappingAdded(Mode mode, InputGesture gesture, Action<PadEditor> action) { if(mode == currentMode) BindMacro(gesture, action); }