Exemplo n.º 1
0
        public override Result Input(Def.Event.IEvent evnt, Point point)
        {
            // Special side effect 3, 4
            if (MustBeIgnored(evnt))
            {
                return(Result.EventIsConsumed(nextState: this));
            }

            if (evnt is Def.Event.IDoubleActionRelease)
            {
                var ev = evnt as Def.Event.IDoubleActionRelease;
                if (ev == secondaryEvent.GetPair())
                {
                    Debug.Print("[Transition 3_0]");
                    ExecuteUserDoFuncInBackground(ctx, T1);
                    ExecuteUserAfterFuncInBackground(ctx, T1);
                    return(Result.EventIsConsumed(nextState: S2));
                }
                else if (ev == primaryEvent.GetPair())
                {
                    Debug.Print("[Transition 3_1]");
                    IgnoreNext(secondaryEvent.GetPair());
                    ExecuteUserAfterFuncInBackground(ctx, T1);
                    ExecuteUserAfterFuncInBackground(ctx, T0);
                    return(Result.EventIsConsumed(nextState: S0));
                }
            }
            return(base.Input(evnt, point));
        }
Exemplo n.º 2
0
        public override Result Input(Def.Event.IEvent evnt, Point point)
        {
            // Special side effect 3, 4
            if (MustBeIgnored(evnt))
            {
                return(Result.EventIsConsumed(nextState: this));
            }
            // Special side effect 2
            Global.StrokeWatcher.Queue(point);

            if (evnt is Def.Event.ISingleAction)
            {
                var ev = evnt as Def.Event.ISingleAction;
                if (T0.Keys.Contains(ev))
                {
                    Debug.Print("[Transition 2_0]");
                    ExecuteUserDoFuncInBackground(ctx, T0[ev]);
                    return(Result.EventIsConsumed(nextState: this));
                }
            }
            else if (evnt is Def.Event.IDoubleActionSet)
            {
                var ev = evnt as Def.Event.IDoubleActionSet;
                if (T1.Keys.Contains(ev))
                {
                    Debug.Print("[Transition 2_1]");
                    ExecuteUserBeforeFuncInBackground(ctx, T1[ev]);
                    return(Result.EventIsConsumed(nextState: new State3(Global, S0, this, ctx, primaryEvent, ev, T3, T1[ev])));
                }
            }
            else if (evnt is Def.Event.IDoubleActionRelease)
            {
                var ev = evnt as Def.Event.IDoubleActionRelease;
                if (ev == primaryEvent.GetPair())
                {
                    var stroke = Global.StrokeWatcher.GetStorke();
                    if (stroke.Count() > 0)
                    {
                        Debug.Print("Stroke: {0}", stroke.ToString());
                        if (T2.Keys.Contains(stroke))
                        {
                            Debug.Print("[Transition 2_2]");
                            ExecuteUserDoFuncInBackground(ctx, T2[stroke]);
                            ExecuteUserAfterFuncInBackground(ctx, T3);
                        }
                    }
                    else
                    {
                        Debug.Print("[Transition 2_3]");
                        ExecuteUserAfterFuncInBackground(ctx, T3);
                    }
                    return(Result.EventIsConsumed(nextState: S0));
                }
            }
            return(base.Input(evnt, point));
        }