Exemple #1
0
        private void pictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            _pictureBox.Parent.Focus(); // Fix the mouse wheel scroll

            if (Selected != null)
            {
                if (_isMoving)
                {
                    if (!_controlMove.Contains(e.Location))
                    {
                        _lastPosition = _controlMove.GetCenter();
                    }

                    Selected.Move(ref _lastPosition, e.Location, _pictureBox.ClientRectangle);
                    _pictureBox.Invalidate();
                }
                else if (_isResizing)
                {
                    if (!_controlResize.Contains(e.Location))
                    {
                        _lastPosition = _controlResize.GetCenter();
                    }

                    Selected.Resize(ref _lastPosition, e.Location, _pictureBox.ClientRectangle);
                    _pictureBox.Invalidate();
                }
                else
                {
                    // Change the cursor only for the resize, move mouse looks weird
                    _pictureBox.Cursor = _controlResize.Contains(e.Location) ? Cursors.SizeNWSE : Cursors.Default;
                }
            }
            else
            {
                _pictureBox.Cursor = Cursors.Default;
            }
        }