コード例 #1
0
        static void ForEachEventListenerBubbleUp(UIEventArgs e, CssBoxHitChain hitChain, System.Func <bool> listenerAction)
        {
            for (int i = hitChain.Count - 1; i >= 0; --i)
            {
                //propagate up
                var hitInfo = hitChain.GetHitInfo(i);
                IUIEventListener controller = null;
                switch (hitInfo.hitObjectKind)
                {
                default:
                {
                    continue;
                }

                case HitObjectKind.Run:
                {
                    CssRun run = (CssRun)hitInfo.hitObject;
                    controller = CssBox.UnsafeGetController(run.OwnerBox) as IUIEventListener;
                }
                break;

                case HitObjectKind.CssBox:
                {
                    CssBox box = (CssBox)hitInfo.hitObject;
                    controller = CssBox.UnsafeGetController(box) as IUIEventListener;
                }
                break;
                }

                //---------------------
                if (controller != null)
                {
                    //found controller
                    if (e.SourceHitElement == null)
                    {
                        e.SetSourceHitObject(controller);
                    }

                    e.SetCurrentContextElement(controller);
                    e.SetLocation(hitInfo.localX, hitInfo.localY);
                    if (listenerAction())
                    {
                        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;
                    }
                }
            }
        }