예제 #1
0
        public void TestSelectionPoint()
        {
            RectangleF box = GetViewSelBox();

            hitCorner = SelectionHitCorner.None;

            if (VectorMath.PointInsideBox(viewCursorPos, GetHitBox(SelectionHitCorner.TopLeft)))
            {
                hitCorner = SelectionHitCorner.TopLeft;
            }

            if (VectorMath.PointInsideBox(viewCursorPos, GetHitBox(SelectionHitCorner.TopRight)))
            {
                hitCorner = SelectionHitCorner.TopRight;
            }

            if (VectorMath.PointInsideBox(viewCursorPos, GetHitBox(SelectionHitCorner.BottomRight)))
            {
                hitCorner = SelectionHitCorner.BottomRight;
            }

            if (VectorMath.PointInsideBox(viewCursorPos, GetHitBox(SelectionHitCorner.BottomLeft)))
            {
                hitCorner = SelectionHitCorner.BottomLeft;
            }

            cursorInsideSelection = false;
            if (VectorMath.PointInsideBox(viewCursorPos, box))
            {
                cursorInsideSelection = true;
            }
        }
예제 #2
0
        RectangleF GetHitBox(SelectionHitCorner corner)
        {
            RectangleF hit = RectangleF.Empty;

            if (selection.Count > 0)
            {
                RectangleF r = GetViewSelBox();

                float halfSize = hitCornerSize / 2;

                switch (corner)
                {
                case SelectionHitCorner.TopLeft:
                    hit.X = r.X - hitCornerMargin - halfSize;
                    hit.Y = r.Y - hitCornerMargin - halfSize;
                    break;

                case SelectionHitCorner.TopRight:
                    hit.X = r.Right + hitCornerMargin - halfSize;
                    hit.Y = r.Y - hitCornerMargin - halfSize;
                    break;

                case SelectionHitCorner.BottomRight:
                    hit.X = r.Right + hitCornerMargin - halfSize;
                    hit.Y = r.Bottom + hitCornerMargin - halfSize;
                    break;

                case SelectionHitCorner.BottomLeft:
                    hit.X = r.X - hitCornerMargin - halfSize;
                    hit.Y = r.Bottom + hitCornerMargin - halfSize;
                    break;
                }

                hit.Width  = hitCornerSize;
                hit.Height = hitCornerSize;
            }

            return(hit);
        }