public void AddWishForOutsideAction(AnyUiLambdaActionBase action) { if (action != null && WishForOutsideAction != null) { WishForOutsideAction.Add(action); } }
public void PushEvent(AnyUiLambdaActionBase la) { lock (_eventQueue) { _eventQueue.Add(la); } }
/// <summary> /// This function attaches the above lambdas accordingly to a given user control. /// It is to be used, when an abstract AnyUi... is being created and the according WPF element /// will be activated later. /// Note: use of this is for legacy reasons; basically the class members can be used directly /// </summary> /// <param name="cntl">User control (passed thru)</param> /// <param name="setValue">Lambda called, whenever the value is changed</param> /// <param name="takeOverLambda">Lamnda called at the end of a modification</param> /// <returns>Passes thru the user control</returns> public static AnyUiUIElement RegisterControl( AnyUiUIElement cntl, Func <object, AnyUiLambdaActionBase> setValue, AnyUiLambdaActionBase takeOverLambda = null) { // access if (cntl == null) { return(null); } // crude test cntl.setValueLambda = setValue; cntl.takeOverLambda = takeOverLambda; return(cntl); }
public static void htmlDotnetLoop() { AnyUiUIElement el; while (true) { // ReSharper disable InconsistentlySynchronizedField int i = 0; while (i < sessions.Count) { var s = sessions[i]; if (s.htmlDotnetEventIn) { switch (s.htmlDotnetEventType) { case "setValueLambda": el = (AnyUiUIElement)s.htmlDotnetEventInputs[0]; object o = s.htmlDotnetEventInputs[1]; s.htmlDotnetEventIn = false; s.htmlDotnetEventInputs.Clear(); AnyUiLambdaActionBase ret = el.setValueLambda?.Invoke(o); break; case "contextMenu": el = (AnyUiUIElement)s.htmlDotnetEventInputs[0]; AnyUiSpecialActionContextMenu cntlcm = (AnyUiSpecialActionContextMenu) s.htmlDotnetEventInputs[1]; s.htmlEventType = "contextMenu"; s.htmlEventInputs.Add(el); s.htmlEventInputs.Add(cntlcm); s.htmlDotnetEventIn = false; s.htmlDotnetEventInputs.Clear(); s.htmlEventIn = true; Program.signalNewData(1, s.sessionNumber); // same tree, but structure may change while (!s.htmlEventOut) { ; } int bufferedI = 0; if (s.htmlEventOutputs.Count == 1) { bufferedI = (int)s.htmlEventOutputs[0]; var action2 = cntlcm.MenuItemLambda?.Invoke(bufferedI); } s.htmlEventOutputs.Clear(); s.htmlEventType = ""; s.htmlEventOut = false; //// AnyUiLambdaActionBase ret = el.setValueLambda?.Invoke(o); break; } while (s.htmlDotnetEventOut) { ; } Program.signalNewData(2, s.sessionNumber); // build new tree } i++; } // ReSharper enable InconsistentlySynchronizedField Thread.Sleep(100); } }
private static void htmlDotnetLoop() { AnyUiUIElement el; bool newData = false; while (true) { lock (htmlDotnetLock) { if (htmlDotnetEventIn) { switch (htmlDotnetEventType) { case "setValueLambda": el = (AnyUiUIElement)htmlDotnetEventInputs[0]; object o = htmlDotnetEventInputs[1]; htmlDotnetEventInputs.Clear(); AnyUiLambdaActionBase ret = el.setValueLambda?.Invoke(o); break; case "contextMenu": el = (AnyUiUIElement)htmlDotnetEventInputs[0]; AnyUiSpecialActionContextMenu cntlcm = (AnyUiSpecialActionContextMenu) htmlDotnetEventInputs[1]; htmlEventType = "contextMenu"; htmlEventInputs.Add(el); htmlEventInputs.Add(cntlcm); htmlEventIn = true; Program.signalNewData(1); // same tree, but structure may change while (!htmlEventOut) { ; } int bufferedI = 0; if (htmlEventOutputs.Count == 1) { bufferedI = (int)htmlEventOutputs[0]; var action2 = cntlcm.MenuItemLambda?.Invoke(bufferedI); } htmlEventOutputs.Clear(); htmlEventType = ""; htmlEventOut = false; htmlDotnetEventIn = false; htmlDotnetEventInputs.Clear(); //// AnyUiLambdaActionBase ret = el.setValueLambda?.Invoke(o); break; } while (htmlDotnetEventOut) { ; } htmlDotnetEventIn = false; newData = true; } } if (newData) { newData = false; Program.signalNewData(2); // build new tree } Thread.Sleep(100); } }
/// <summary> /// This function is called from multiple places inside this class to emit an labda action /// to the superior logic of the application /// </summary> /// <param name="action"></param> public virtual void EmitOutsideAction(AnyUiLambdaActionBase action) { }