public void VisitDescendents(JSWrapper target, JSFunction action) { Element element = target?.As <Element>(); if (element == null) { throw new ObjectDisposedException("Cannot visit descendents of null"); } var views = element as IViewContainer <View>; if (views == null) { return; } foreach (var e in views.Children) { var ac = WAContext.GetAtomControl(e); var child = e.Wrap(Engine); var r = action.Call(null, new Java.Lang.Object[] { child, (JSValue)ac }); if ((bool)r.IsUndefined() || (bool)r.IsNull() || !((bool)r.ToBoolean())) { continue; } VisitDescendents(JSWrapper.Register(e), action); } }
public JSValue AtomParent(JSWrapper target, JSValue climbUp) { Element element = target.As <Element>(); bool cu = !((bool)climbUp.IsUndefined()) && !((bool)climbUp.IsNull()) && (bool)climbUp.ToBoolean(); if (cu) { element = element.Parent; if (element == null) { return(null); } } do { var e = WAContext.GetAtomControl(element); if (e != null) { return(e.Wrap(Engine)); } element = element.Parent; } while (cu && element != null); return(null); }
public void Broadcast(Page page, string str, object p = null) { var ac = (WAContext.GetAtomControl(page) as JSValue)?.ToObject(); var app = ac?.GetJSPropertyValue("app")?.ToObject(); var function = app?.GetJSPropertyValue("broadcast")?.ToFunction(); function.Call(app, new Java.Lang.Object[] { str, p == null ? null : p.Wrap(Engine) }); }
public void DisposePage(Element e, bool disposeFromCLR) { if (disposeFromCLR) { var ac = (WAContext.GetAtomControl(e) as JSValue)?.ToObject(); if (ac != null) { var func = ac.GetJSPropertyValue("dispose").ToFunction(); func.Call(ac); } return; } }
public void AttachControl(JSWrapper target, JSValue control) { Element element = target.As <Element>(); var ac = WAContext.GetAtomControl(element); if (ac != null) { if (ac == control as object) { return; } throw new InvalidOperationException("Control already attached"); } WAContext.SetAtomControl(element, control); }
public void SetImport(JSWrapper elementWrapper, string name, JSFunction factory) { var element = elementWrapper.As <Element>(); var d = WAContext.GetImports(element); if (d == null) { d = new Dictionary <string, Func <Element> >(); WAContext.SetImports(element, d); } d[name] = () => { var t = WAContext.GetAtomControl(element); var jv = factory.Call((JSObject)t.Wrap(Engine)) as JSValue; return(JSWrapper.FromKey(jv.ToObject().GetJSPropertyValue("element").ToString()).As <Element>()); }; }