Ejemplo n.º 1
0
 public void SetRectangle(Rectangle rectangle)
 {
     using (DesktopGraphics graphics = new DesktopGraphics())
     {
         _drag.Size(rectangle, graphics);
     }
 }
Ejemplo n.º 2
0
        private void _handler_Drag(object sender, MouseEventArgs e)
        {
            using (DesktopGraphics graphics = new DesktopGraphics())
            {
                RestoreBitmap(graphics);

                switch (_direction)
                {
                case SplitterDragHandlerDirection.EastWest:
                    _offset = _dragHandler.Offset.X;
                    break;

                case SplitterDragHandlerDirection.NorthSouth:
                    _offset = _dragHandler.Offset.Y;
                    break;
                }

                Rectangle dragRectangle = GetDragRectangle();
                SaveBitmap(graphics);

                using (SolidBrush brush = new SolidBrush(Color.FromKnownColor(KnownColor.MenuHighlight)))
                {
                    graphics.Graphics.FillRectangle(brush, dragRectangle);
                }
            }
        }
Ejemplo n.º 3
0
 private void _dragHandler_DragCancelled(object sender, EventArgs e)
 {
     using (DesktopGraphics graphics = new DesktopGraphics())
     {
         RestoreBitmap(graphics);
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        public void Offset(Point offset)
        {
            using (DesktopGraphics graphics = new DesktopGraphics())
            {
                _drag.Offset(offset, graphics);
            }

            _startPoint.X += offset.X;
            _startPoint.Y += offset.Y;
        }
Ejemplo n.º 6
0
        protected override void OnDrag(MouseEventArgs args)
        {
            base.OnDrag(args);

            Rectangle bounds = GetSizedRectangle();

            using (DesktopGraphics graphics = new DesktopGraphics())
            {
                _rectangleDrag.Size(bounds, graphics);
            }
        }
Ejemplo n.º 7
0
        protected override void OnDragStart(MouseEventArgs args)
        {
            base.OnDragStart(args);

            _dragging = true;

            _rectangleDrag = new RectangleDrag();
            _bounds        = Control.Bounds;

            using (DesktopGraphics graphics = new DesktopGraphics())
            {
                _rectangleDrag.Start(GetScreenRectangle(_bounds), graphics);
            }

            _flags = GetDirectionFlags(GetDragDirection(args.Location));
        }
Ejemplo n.º 8
0
        public Rectangle End()
        {
            Rectangle result;

            using (DesktopGraphics graphics = new DesktopGraphics())
            {
                result = _drag.End(graphics);
            }

            _drag.Dispose();
            _drag = null;

            _setCursor.Dispose();
            _setCursor = null;

            return(result);
        }
Ejemplo n.º 9
0
        protected override void OnDragCancelled()
        {
            _dragging = false;

            using (DesktopGraphics graphics = new DesktopGraphics())
            {
                if (_rectangleDrag != null)
                {
                    _rectangleDrag.End(graphics);
                    _rectangleDrag.Dispose();
                    _rectangleDrag = null;
                }
            }

            SetCursor(null);

            base.OnDragCancelled();
        }
Ejemplo n.º 10
0
        protected override void OnDragEnd(MouseEventArgs args)
        {
            _dragging = false;

            Rectangle bounds = GetSizedRectangle();

            using (DesktopGraphics graphics = new DesktopGraphics())
            {
                if (_rectangleDrag != null)
                {
                    _rectangleDrag.End(graphics);
                    _rectangleDrag.Dispose();
                    _rectangleDrag = null;
                }
            }

            SetCursor(null);
            Control.Bounds = bounds;
            Control.Invalidate();

            base.OnDragEnd(args);
        }
Ejemplo n.º 11
0
        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);
                }
            }
        }
Ejemplo n.º 12
0
        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;
            }
        }