protected override Cursor GetHoverCursor(Point pPoint) { Cursor lRet = Cursors.Default; RectPointIndex lIndex = (RectPointIndex)HitTest(pPoint); switch (lIndex) { case RectPointIndex.eTopLeft: case RectPointIndex.eBottomRight: lRet = Cursors.SizeNWSE; break; case RectPointIndex.eTopRight: case RectPointIndex.eBottomLeft: lRet = Cursors.SizeNESW; break; case RectPointIndex.eTopCenter: case RectPointIndex.eBottomCenter: lRet = Cursors.SizeNS; break; case RectPointIndex.eMidLeft: case RectPointIndex.eMidRight: lRet = Cursors.SizeWE; break; } return(lRet); }
protected override void OnResize(Point pPoint, ref Rectangle pRect) { Rectangle lRect = pRect; Point lLocation = lRect.Location; Size lSize = lRect.Size; RectPointIndex lMovingPointIndex = (RectPointIndex)MovingPointIndex; switch (lMovingPointIndex) { case RectPointIndex.eTopLeft: lLocation = pPoint; lSize = new Size(lRect.Right - pPoint.X, lRect.Bottom - pPoint.Y); break; case RectPointIndex.eTopCenter: lLocation.Y = pPoint.Y; lSize.Height = lRect.Bottom - pPoint.Y; break; case RectPointIndex.eTopRight: lLocation.Y = pPoint.Y; lSize = new Size(pPoint.X - lRect.Left, lRect.Bottom - pPoint.Y); break; case RectPointIndex.eMidLeft: lLocation.X = pPoint.X; lSize.Width = lRect.Right - pPoint.X; break; case RectPointIndex.eMidRight: lSize.Width = pPoint.X - lRect.Left; break; case RectPointIndex.eBottomLeft: lLocation.X = pPoint.X; lSize = new Size(lRect.Right - pPoint.X, pPoint.Y - lRect.Top); break; case RectPointIndex.eBottomCenter: lSize.Height = pPoint.Y - lRect.Top; break; case RectPointIndex.eBottomRight: lSize = new Size(pPoint.X - lRect.Left, pPoint.Y - lRect.Top); break; } OnRectify(lSize); Rectify(lRect, pPoint, ref lLocation, ref lSize, ref lMovingPointIndex); MovingPointIndex = (int)lMovingPointIndex; // draw circle/square when Control key is pressing if (KeyboardHelper.Instance.IsCtrlPressing) { int lLen = Math.Min(lSize.Width, lSize.Height); lSize = new Size(lLen, lLen); } pRect = new Rectangle(lLocation, lSize); }
private void Rectify(Rectangle pRect, Point pPoint, ref Point pLocation, ref Size pSize, ref RectPointIndex pIndex) { VIndex lVIndex; HIndex lHIndex; GetIndex((byte)pIndex, out lVIndex, out lHIndex); if (pSize.Height < 0) { pLocation.Y = lVIndex == VIndex.eTop ? pRect.Bottom : pPoint.Y; lVIndex = (lVIndex == VIndex.eTop) ? VIndex.eBottom : VIndex.eTop; pSize.Height = -pSize.Height; } if (pSize.Width < 0) { pLocation.X = lHIndex == HIndex.eLeft ? pRect.Right : pPoint.X; lHIndex = (lHIndex == HIndex.eLeft) ? HIndex.eRight : HIndex.eLeft; pSize.Width = -pSize.Width; } pIndex = (RectPointIndex)GetIndex(lVIndex, lHIndex); }