protected override DragHandleAnchor SetCursor(Point point, ImageBox box) { Cursor cursor = Cursors.Default; DragHandleAnchor handleAnchor = DragHandleAnchor.None; if (Selected) { var handle = HitTest(point); if (handle != null) { handleAnchor = handle.Anchor; if (handleAnchor != DragHandleAnchor.None && handle.Enabled) { _selectHandle = handle; switch (handleAnchor) { case DragHandleAnchor.TopLeft: cursor = Cursors.SizeAll; break; case DragHandleAnchor.MiddleCenter: cursor = Cursors.SizeAll; break; default: throw new ArgumentOutOfRangeException(); } } } } box.Cursor = cursor; return(handleAnchor); }
protected virtual void DrawDragHandle(Graphics graphics, DragHandle handle) { int left; int top; int width; int height; Pen outerPen; Brush innerBrush; left = handle.Bounds.Left; top = handle.Bounds.Top; width = handle.Bounds.Width; height = handle.Bounds.Height; if (handle.Enabled) { outerPen = new Pen(Color.Orange); innerBrush = Brushes.OrangeRed; } else { outerPen = SystemPens.ControlDark; innerBrush = SystemBrushes.Control; } graphics.FillRectangle(innerBrush, left + 1, top + 1, width - 2, height - 2); graphics.DrawLine(outerPen, left + 1, top, left + width - 2, top); graphics.DrawLine(outerPen, left, top + 1, left, top + height - 2); graphics.DrawLine(outerPen, left + 1, top + height - 1, left + width - 2, top + height - 1); graphics.DrawLine(outerPen, left + width - 1, top + 1, left + width - 1, top + height - 2); }
public override DragHandle HitTest(Point point) { if (DragHandleList == null || DragHandleList.Count < 1) { return(null); } DragHandle result = null; foreach (DragHandle handle in DragHandleList) { if (handle.Visible && handle.Bounds.Contains(point)) { result = handle; break; } } return(result); }