internal static IEnumerable <T> FilterByWhenClause <T>( UserActionExecutionContext ctx, IEnumerable <T> gestureDef) where T : IWhenEvaluatable { return(FilterByWhenClause(ctx, gestureDef, new Dictionary <DSL.Def.WhenFunc, bool>())); }
protected internal void ExecuteUserAfterFuncInBackground( UserActionExecutionContext ctx, IEnumerable <IAfterExecutable> gestureDef) { Global.UserActionTaskFactory.StartNew(() => { foreach (var gDef in gestureDef) { gDef.ExecuteUserAfterFunc(ctx); } }); }
internal static IEnumerable <T> FilterByWhenClause <T>( UserActionExecutionContext ctx, IEnumerable <T> gestureDef, Dictionary <DSL.Def.WhenFunc, bool> cache) where T : IWhenEvaluatable { // This evaluation of functions given as the parameter of `@when` clause can be executed in parallel, // but executing it in sequential order here for simplicity. return(gestureDef .Where(x => x.EvaluateUserWhenFunc(ctx, cache)) .ToList()); }
public State1( StateGlobal Global, State0 S0, UserActionExecutionContext ctx, Def.Event.IDoubleActionSet primaryEvent, IEnumerable <OnButtonGestureDefinition> T1, IEnumerable <IfButtonGestureDefinition> T2 ) : base(Global) { this.S0 = S0; this.ctx = ctx; this.primaryEvent = primaryEvent; this.T0 = Transition.Gen1_0(T1); this.T1 = Transition.Gen1_1(T1); this.T2 = Transition.Gen1_2(T1); this.T3 = T2; this.S2 = new State2(Global, S0, ctx, primaryEvent, this.T0, this.T1, this.T2, this.T3); }
public State2( StateGlobal Global, State0 S0, UserActionExecutionContext ctx, Def.Event.IDoubleActionSet primaryEvent, IDictionary <Def.Event.ISingleAction, IEnumerable <OnButtonWithIfButtonGestureDefinition> > T0, IDictionary <Def.Event.IDoubleActionSet, IEnumerable <OnButtonWithIfButtonGestureDefinition> > T1, IDictionary <Def.Stroke, IEnumerable <OnButtonWithIfStrokeGestureDefinition> > T2, IEnumerable <IfButtonGestureDefinition> T3 ) : base(Global) { this.S0 = S0; this.ctx = ctx; this.primaryEvent = primaryEvent; this.T0 = T0; this.T1 = T1; this.T2 = T2; this.T3 = T3; }
public State3( StateGlobal Global, State0 S0, State2 S2, UserActionExecutionContext ctx, Def.Event.IDoubleActionSet primaryEvent, Def.Event.IDoubleActionSet secondaryEvent, IEnumerable <IfButtonGestureDefinition> T0, IEnumerable <OnButtonWithIfButtonGestureDefinition> T1 ) : base(Global) { this.S0 = S0; this.S2 = S2; this.ctx = ctx; this.primaryEvent = primaryEvent; this.secondaryEvent = secondaryEvent; this.T0 = T0; this.T1 = T1; }
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.ISingleAction) { var ev = evnt as Def.Event.ISingleAction; if (T0.Keys.Contains(ev)) { var ctx = new UserActionExecutionContext(point); var _T0 = FilterByWhenClause(ctx, T0[ev]); if (_T0.Count() > 0) { Debug.Print("[Transition 0_0]"); ExecuteUserDoFuncInBackground(ctx, _T0); return(Result.EventIsConsumed(nextState: this)); } } } else if (evnt is Def.Event.IDoubleActionSet) { var ev = evnt as Def.Event.IDoubleActionSet; if (T1.Keys.Contains(ev) || T2.Keys.Contains(ev)) { var ctx = new UserActionExecutionContext(point); var cache = new Dictionary <DSL.Def.WhenFunc, bool>(); var _T1 = T1.Keys.Contains(ev) ? FilterByWhenClause(ctx, T1[ev], cache) : new List <OnButtonGestureDefinition>(); var _T2 = T2.Keys.Contains(ev) ? FilterByWhenClause(ctx, T2[ev], cache) : new List <IfButtonGestureDefinition>(); if (_T1.Count() > 0 || _T2.Count() > 0) { Debug.Print("[Transition 0_1]"); ExecuteUserBeforeFuncInBackground(ctx, _T2); return(Result.EventIsConsumed(nextState: new State1(Global, this, ctx, ev, _T1, _T2))); } } } return(base.Input(evnt, point)); }
protected internal void ExecuteInBackground( UserActionExecutionContext ctx, Action action) { Global.UserActionTaskFactory.StartNew(action); }