OffsetTestPoint() public method

public OffsetTestPoint ( int dx, int dy ) : void
dx int
dy int
return void
Beispiel #1
0
        public override bool HitTestCore(HitChain hitChain)
        {
            int testX;
            int testY;
            hitChain.GetTestPoint(out testX, out testY);
            GridCell cell = GetGridItemByPosition(testX, testY);
            if (cell != null && cell.HasContent)
            {
                hitChain.OffsetTestPoint(-cell.X, -cell.Y);
                var renderE = cell.ContentElement as RenderElement;
                if (renderE != null)
                {
                    renderE.HitTestCore(hitChain);
                }

                hitChain.OffsetTestPoint(cell.X, cell.Y);
                return true;
            }
            return false;
        }
        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;
            }
        }
        //==============================================================
        //hit test

        public bool HitTestCore(HitChain hitChain)
        {
            if ((propFlags & RenderElementConst.HIDDEN) != 0)
            {
                return false;
            }

            int testX;
            int testY;
            hitChain.GetTestPoint(out testX, out testY);
            if ((testY >= b_top && testY <= (b_top + b_height)
            && (testX >= b_left && testX <= (b_left + b_width))))
            {
                if (this.MayHasViewport)
                {
                    hitChain.OffsetTestPoint(
                        -b_left + this.ViewportX,
                        -b_top + this.ViewportY);
                }
                else
                {
                    hitChain.OffsetTestPoint(-b_left, -b_top);
                }

                hitChain.AddHitObject(this);
                if (this.MayHasChild)
                {
                    this.ChildrenHitTestCore(hitChain);
                }

                if (this.MayHasViewport)
                {
                    hitChain.OffsetTestPoint(
                            b_left - this.ViewportX,
                            b_top - this.ViewportY);
                }
                else
                {
                    hitChain.OffsetTestPoint(b_left, b_top);
                }

                if ((propFlags & RenderElementConst.TRANSPARENT_FOR_ALL_EVENTS) != 0 &&
                    hitChain.TopMostElement == this)
                {
                    hitChain.RemoveCurrentHit();
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                return false;
            }
        }