Exemplo n.º 1
0
        public static void SetKeyMapping(Key k, SemanticAction A)
        {
            if (CurrentContext == null) return;

            if (!Map.ContainsKey(CurrentContext))
            {
                Map.Add(CurrentContext, new KeyMap());
            }
            var map = Map[CurrentContext];

            if (!map.ContainsKey(CurrentChord1))
            {
                map.Add(CurrentChord1, KeyMapOrAction.MakeEmptyMap());
            }
            map = map[CurrentChord1].MyMap;

            if (CurrentChord2 != Key.None)
            {
                if (!map.ContainsKey(CurrentChord2))
                {
                    map.Add(CurrentChord2, KeyMapOrAction.MakeEmptyMap());
                }

                map = map[CurrentChord2].MyMap;
            }

            if (!map.ContainsKey(k))
            {
                map.Add(k, new KeyMapOrAction());
            }

            map[k].MyAction = A;
        }
        public static SemanticAction operator |(SemanticAction A, SemanticAction B)
        {
            var Sum = new SemanticAction();
            Sum.Representation = A.ToString() + " | " + B.ToString();

            Action<Context, ExecuteType> action = (context, type) =>
            {
                if (type == ExecuteType.Press || type == ExecuteType.Down)
                {
                    A.Execute(ExecuteType.Press);
                    B.Execute(ExecuteType.Press);
                }
            };

            Sum.ContextualEvents.Add(Contexts.Default, action);

            return Sum;
        }
 public static void DoDown(SemanticAction action)
 {
     action.Execute(ExecuteType.Down);
 }
 public static void DoUp(SemanticAction action)
 {
     action.Execute(ExecuteType.Up);
 }
 public static void Do(SemanticAction action)
 {
     action.Execute();
 }