private void _handler_DragStart(object sender, MouseEventArgs e) { switch (_direction) { case SplitterDragHandlerDirection.EastWest: _setDragCursor = new SetCursor(Cursors.VSplit); _variantDimension = _dragHandler.Control.PointToClient(Cursor.Position).X; _invariantStartDimension = _dragHandler.Control.ClientRectangle.Top; _invariantEndDimension = _dragHandler.Control.ClientRectangle.Bottom; break; case SplitterDragHandlerDirection.NorthSouth: _setDragCursor = new SetCursor(Cursors.HSplit); _variantDimension = _dragHandler.Control.PointToClient(Cursor.Position).Y; _invariantStartDimension = _dragHandler.Control.ClientRectangle.Left; _invariantEndDimension = _dragHandler.Control.ClientRectangle.Right; break; default: break; } Rectangle bitmapRectangle = GetDragRectangle(); _bitmap = new Bitmap(bitmapRectangle.Width, bitmapRectangle.Height); _offset = 0; using (DesktopGraphics graphics = new DesktopGraphics()) { SaveBitmap(graphics); } }
public Rectangle End() { Rectangle result; using (DesktopGraphics graphics = new DesktopGraphics()) { result = _drag.End(graphics); } _drag.Dispose(); _drag = null; _setCursor.Dispose(); _setCursor = null; return(result); }
public void Start(Point startPoint) { if (_enabled) { _drag = new RectangleDrag(); _startPoint = startPoint; if (_dragCursor != null) { if (_setCursor != null) { _setCursor.Dispose(); } _setCursor = new SetCursor(_dragCursor); } using (DesktopGraphics graphics = new DesktopGraphics()) { _drag.Start(_control.Parent.RectangleToScreen(_control.Bounds), graphics); } } }
private void _handler_DragEnd(object sender, MouseEventArgs e) { using (DesktopGraphics graphics = new DesktopGraphics()) { RestoreBitmap(graphics); _bitmap.Dispose(); _bitmap = null; } _setDragCursor.Dispose(); _setDragCursor = null; switch (_direction) { case SplitterDragHandlerDirection.NorthSouth: OnEndSplitterDrag(_dragHandler.Offset.Y); break; case SplitterDragHandlerDirection.EastWest: OnEndSplitterDrag(_dragHandler.Offset.X); break; } }
private void SetCursor(Cursor cursor) { if (cursor == null) { if (_setCursor != null) { _setCursor.Dispose(); _setCursor = null; } } else { if (_setCursor != null && cursor != _setCursor.Cursor) { _setCursor.Dispose(); _setCursor = null; } if (_setCursor == null) { _setCursor = new SetCursor(Control, cursor); } } }