コード例 #1
0
        void HitTestCoreWithChain(HitChain hitPointChain, int x, int y)
        {
            hitPointChain.ClearAll();
            hitPointChain.SetStartTestPoint(x, y);
            RenderElement commonElement = this.topRenderElement;

            commonElement.HitTestCore(hitPointChain);
        }
コード例 #2
0
        static RenderElement HitTestOnPreviousChain(HitChain hitPointChain, HitChain previousChain, int x, int y)
        {
#if DEBUG
            if (hitPointChain == previousChain)
            {
                throw new NotSupportedException();
            }
#endif

            if (previousChain.Count > 0)
            {
                previousChain.SetStartTestPoint(x, y);
                //test on prev chain top to bottom
                int j = previousChain.Count;

                for (int i = 0; i < j; ++i)
                {
                    HitInfo       hitInfo = previousChain.GetHitInfo(i);
                    RenderElement elem    = hitInfo.hitElement;
                    if (elem != null && elem.VisibleAndHasParent)
                    {
                        if (elem.Contains(hitInfo.point))
                        {
                            RenderElement found = elem.FindUnderlyingSiblingAtPoint(hitInfo.point);
                            if (found == null)
                            {
                                Point leftTop = elem.Location;
                                hitPointChain.OffsetTestPoint(leftTop.X, leftTop.Y);
                                hitPointChain.AddHitObject(elem);
                                //add to chain
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            //---------------------------------
            if (hitPointChain.Count > 0)
            {
                var commonElement = hitPointChain.GetHitInfo(hitPointChain.Count - 1).hitElement;
                hitPointChain.RemoveCurrentHit();
                return(commonElement);
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        //        static RenderElement HitTestOnPreviousChain(HitChain hitPointChain, HitChain previousChain, int x, int y)
        //        {
        //#if DEBUG
        //            if (hitPointChain == previousChain)
        //            {
        //                throw new NotSupportedException();
        //            }
        //#endif

        //            if (previousChain.Count > 0)
        //            {
        //                previousChain.SetStartTestPoint(x, y);
        //                //test on prev chain top to bottom
        //                int j = previousChain.Count;
        //                for (int i = 0; i < j; ++i)
        //                {
        //                    HitInfo hitInfo = previousChain.GetHitInfo(i);
        //                    RenderElement elem = hitInfo.HitElemAsRenderElement;
        //                    if (elem != null && elem.VisibleAndHasParent)
        //                    {
        //                        if (elem.Contains(hitInfo.point))
        //                        {
        //                            RenderElement found = elem.FindUnderlyingSiblingAtPoint(hitInfo.point);
        //                            if (found == null)
        //                            {
        //                                Point leftTop = elem.Location;
        //                                hitPointChain.OffsetTestPoint(leftTop.X, leftTop.Y);
        //                                hitPointChain.AddHitObject(elem);
        //                                //add to chain
        //                            }
        //                            else
        //                            {
        //                                break;
        //                            }
        //                        }
        //                    }
        //                    else
        //                    {
        //                        break;
        //                    }
        //                }
        //            }
        //            //---------------------------------
        //            if (hitPointChain.Count > 0)
        //            {
        //                var commonElement = hitPointChain.GetHitInfo(hitPointChain.Count - 1).HitElemAsRenderElement;
        //                hitPointChain.RemoveCurrentHit();
        //                return commonElement;
        //            }
        //            else
        //            {
        //                return null;
        //            }
        //        }


        void HitTestCoreWithPrevChainHint(HitChain hitPointChain, HitChain previousChain, int x, int y)
        {
            //---------------------------------
            //test on previous chain first , find common element
            hitPointChain.ClearAll();
            hitPointChain.SetStartTestPoint(x, y);
#if DEBUG
            hitPointChain.dbugHitPhase = _dbugHitChainPhase;
#endif
            //if (this.dbugId > 0 && isDragging && previousChain.Count > 1)
            //{

            //}

            //RenderElement commonElement = HitTestOnPreviousChain(hitPointChain, previousChain, x, y);

            //temp fix
            //TODO: fix bug on HitTestOnPreviousChain()
            RenderElement commonElement = _topRenderElement;
            ////use root
            //if (isDragging)
            //{
            //    if (commonElement != this.topRenderElement)
            //    {

            //    }
            //}


            //if (lastCommonElement != null && commonElement != null &&
            //    lastCommonElement != commonElement && isDragging)
            //{
            //    Console.WriteLine(commonElement.dbug_GetBoundInfo());
            //}
            //if (commonElement == null)
            //{
            //    commonElement = this.topRenderElement;
            //}

            //if (commonElement != this.topRenderElement)
            //{

            //}

            //lastCommonElement = commonElement;
            commonElement.HitTestCore(hitPointChain);
            //this.topRenderElement.HitTestCore(hitPointChain);
        }
コード例 #4
0
        //        static RenderElement HitTestOnPreviousChain(HitChain hitPointChain, HitChain previousChain, int x, int y)
        //        {
        //#if DEBUG
        //            if (hitPointChain == previousChain)
        //            {
        //                throw new NotSupportedException();
        //            }
        //#endif

        //            if (previousChain.Count > 0)
        //            {
        //                previousChain.SetStartTestPoint(x, y);
        //                //test on prev chain top to bottom
        //                int j = previousChain.Count;
        //                for (int i = 0; i < j; ++i)
        //                {
        //                    HitInfo hitInfo = previousChain.GetHitInfo(i);
        //                    RenderElement elem = hitInfo.HitElemAsRenderElement;
        //                    if (elem != null && elem.VisibleAndHasParent)
        //                    {
        //                        if (elem.Contains(hitInfo.point))
        //                        {
        //                            RenderElement found = elem.FindUnderlyingSiblingAtPoint(hitInfo.point);
        //                            if (found == null)
        //                            {
        //                                Point leftTop = elem.Location;
        //                                hitPointChain.OffsetTestPoint(leftTop.X, leftTop.Y);
        //                                hitPointChain.AddHitObject(elem);
        //                                //add to chain
        //                            }
        //                            else
        //                            {
        //                                break;
        //                            }
        //                        }
        //                    }
        //                    else
        //                    {
        //                        break;
        //                    }
        //                }
        //            }
        //            //---------------------------------
        //            if (hitPointChain.Count > 0)
        //            {
        //                var commonElement = hitPointChain.GetHitInfo(hitPointChain.Count - 1).HitElemAsRenderElement;
        //                hitPointChain.RemoveCurrentHit();
        //                return commonElement;
        //            }
        //            else
        //            {
        //                return null;
        //            }
        //        }


        void HitTestCoreWithPrevChainHint(HitChain hitChain, HitChain previousChain, int x, int y)
        {
            //---------------------------------
            //test on previous chain first , find common element
            hitChain.Reset();
            hitChain.SetStartTestPoint(x, y);
#if DEBUG
            hitChain.dbugHitPhase = _dbugHitChainPhase;
#endif
            //if (this.dbugId > 0 && isDragging && previousChain.Count > 1)
            //{

            //}

            //RenderElement commonElement = HitTestOnPreviousChain(hitPointChain, previousChain, x, y);

            //temp fix
            //TODO: fix bug on HitTestOnPreviousChain()
            RenderElement commonElement = _topRenderElement;
            commonElement.HitTestCore(hitChain);

            //remove disable elements
            //if (hitPointChain.dbugHitPhase == dbugHitChainPhase.MouseDown)
            //{
            int j = hitChain.Count;
            for (int i = 0; i < j; ++i)
            {
                HitInfo       info    = hitChain.GetHitInfo(i);
                RenderElement renderE = info.HitElemAsRenderElement;
                if (renderE != null && renderE.GetController() is IUIEventListener ui && !ui.Enabled)
                {
                    HitChain.UnsafeClear(hitChain);
                    break;//stop loop and exit
                }
            }
            //}
        }