static void SetEventOrigin(UIEventArgs e, SvgHitChain hitChain) { int count = hitChain.Count; if (count > 0) { var hitInfo = hitChain.GetHitInfo(count - 1); e.ExactHitObject = hitInfo; } }
static void ForEachSvgElementBubbleUp(UIEventArgs e, SvgHitChain hitChain, EventListenerAction listenerAction) { for (int i = hitChain.Count - 1; i >= 0; --i) { //propagate up var hitInfo = hitChain.GetHitInfo(i); //--------------------- //hit on element e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (listenerAction()) { return; } } }
static void ForEachEventListenerBubbleUp(UIEventArgs e, SvgHitChain hitChain, EventListenerAction listenerAction) { for (int i = hitChain.Count - 1; i >= 0; --i) { //propagate up var hitInfo = hitChain.GetHitInfo(i); IEventListener controller = SvgElement.UnsafeGetController(hitInfo.svg) as IEventListener; //switch (hitInfo.hitObjectKind) //{ // default: // { // continue; // } // case HitObjectKind.Run: // { // CssRun run = (CssRun)hitInfo.hitObject; // controller = CssBox.UnsafeGetController(run.OwnerBox) as IEventListener; // } break; // case HitObjectKind.CssBox: // { // CssBox box = (CssBox)hitInfo.hitObject; // controller = CssBox.UnsafeGetController(box) as IEventListener; // } break; //} //--------------------- if (controller != null) { //found controller e.CurrentContextElement = controller; e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (listenerAction()) { return; } } } }
static void ForEachOnlyEventPortalBubbleUp(UIEventArgs e, SvgHitChain hitPointChain, EventPortalAction eventPortalAction) { //only listener that need tunnel down for (int i = hitPointChain.Count - 1; i >= 0; --i) { //propagate up var hitInfo = hitPointChain.GetHitInfo(i); SvgElement svg = hitInfo.svg; if (svg != null) { var controller = SvgElement.UnsafeGetController(hitInfo.svg) as IEventPortal; if (controller != null) { e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (eventPortalAction(controller)) { return; } } } } }