예제 #1
0
 static void ForEachOnlyEventPortalBubbleUp(UIEventArgs e, VgHitChain hitPointChain, System.Func<IEventPortal, bool> eventPortalAction)
 {
     //only listener that need tunnel down 
     for (int i = hitPointChain.Count - 1; i >= 0; --i)
     {
         //propagate up 
         VgHitInfo hitInfo = hitPointChain.GetHitInfo(i);
         if (hitInfo.hitElem.GetController() is SvgElement svg &&
            SvgElement.UnsafeGetController(svg) is IEventPortal controller)
         {
             e.SetLocation((int)hitInfo.x, (int)hitInfo.y);
             if (eventPortalAction(controller))
             {
                 return;
             }
         }
     }
 }
예제 #2
0
        static void ForEachEventListenerBubbleUp(UIEventArgs e, VgHitChain hitChain, System.Func <bool> listenerAction)
        {
            for (int i = hitChain.Count - 1; i >= 0; --i)
            {
                //propagate up
                VgHitInfo hitInfo = hitChain.GetHitInfo(i);

                IUIEventListener controller = SvgElement.UnsafeGetController(hitInfo.GetSvgElement()) as IUIEventListener;
                //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.SetCurrentContextElement(controller);
                    e.SetLocation((int)hitInfo.x, (int)hitInfo.y);
                    if (listenerAction())
                    {
                        return;
                    }
                }
            }
        }
 static void ForEachOnlyEventPortalBubbleUp(UIEventArgs e, VgHitChain 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.hitElem.GetController() as SvgElement;
         if (svg != null)
         {
             var controller = SvgElement.UnsafeGetController(svg) as IEventPortal;
             if (controller != null)
             {
                 e.SetLocation((int)hitInfo.x, (int)hitInfo.y);
                 if (eventPortalAction(controller))
                 {
                     return;
                 }
             }
         }
     }
 }