Beispiel #1
0
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_moving != null)
                {
                    MoveCommand moveCommand = new MoveCommand(_shapeList, _moving.Shape, _moving.StartMoveMousePoint,
                        e.Location);
                    //moveCommand.Do();
                    _commandStack.Push(moveCommand);
                    _undoneCommands.Clear();
                    UpdateControls();
                    Invalidate();
                    Capture = false;
                    _moving = null;
                }
                if (_resizing != null)
                {
                    ResizeCommand resizeCommand = new ResizeCommand(_resizing.Shape, _mouseDownLocation, e.Location);
                    //moveCommand.Do();
                    _commandStack.Push(resizeCommand);
                    _undoneCommands.Clear();
                    UpdateControls();
                    Capture = false;
                    _resizing = null;
                }

                switch (_activemode)
                {
                    case Mode.Controller:
                        RefreshShapeSelection(e.Location);
                        break;
                    case Mode.Rectangle:
                        if (_startLocation.X != e.X && _startLocation.Y != e.Y)
                        {
                            DrawCommand rectangleCommand = new DrawCommand(_shapeList,
                                new DrawRectangle(_startLocation.X, _startLocation.Y, e.X, e.Y));
                            rectangleCommand.Do();
                            _commandStack.Push(rectangleCommand);
                            _undoneCommands.Clear();
                        }

                        UpdateControls();
                        Invalidate();
                        break;
                    case Mode.Ellipse:
                        if (_startLocation.X != e.X && _startLocation.Y != e.Y)
                        {
                            DrawCommand ellipseCommand = new DrawCommand(_shapeList,
                                new DrawEllipse(_startLocation.X, _startLocation.Y, e.X, e.Y));
                            ellipseCommand.Do();
                            _commandStack.Push(ellipseCommand);
                            _undoneCommands.Clear();
                        }

                        UpdateControls();
                        Invalidate();
                        break;
                } //end mode switch
            } //end leftclick
            else if (e.Button == MouseButtons.Right)
            {
                if (_activemode == Mode.Controller)
                {
                    SetupRightClickmenu();
                }
            }
        }
Beispiel #2
0
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_moving != null)
                {
                    MoveCommand moveCommand = new MoveCommand(_shapeList, _moving.Shape, _moving.StartMoveMousePoint,
                                                              e.Location);
                    //moveCommand.Do();
                    _commandStack.Push(moveCommand);
                    _undoneCommands.Clear();
                    UpdateControls();
                    Invalidate();
                    Capture = false;
                    _moving = null;
                }
                if (_resizing != null)
                {
                    ResizeCommand resizeCommand = new ResizeCommand(_resizing.Shape, _mouseDownLocation, e.Location);
                    //moveCommand.Do();
                    _commandStack.Push(resizeCommand);
                    _undoneCommands.Clear();
                    UpdateControls();
                    Capture   = false;
                    _resizing = null;
                }

                switch (_activemode)
                {
                case Mode.Controller:
                    RefreshShapeSelection(e.Location);
                    break;

                case Mode.Rectangle:
                    if (_startLocation.X != e.X && _startLocation.Y != e.Y)
                    {
                        DrawCommand rectangleCommand = new DrawCommand(_shapeList,
                                                                       new DrawRectangle(_startLocation.X, _startLocation.Y, e.X, e.Y));
                        rectangleCommand.Do();
                        _commandStack.Push(rectangleCommand);
                        _undoneCommands.Clear();
                    }

                    UpdateControls();
                    Invalidate();
                    break;

                case Mode.Ellipse:
                    if (_startLocation.X != e.X && _startLocation.Y != e.Y)
                    {
                        DrawCommand ellipseCommand = new DrawCommand(_shapeList,
                                                                     new DrawEllipse(_startLocation.X, _startLocation.Y, e.X, e.Y));
                        ellipseCommand.Do();
                        _commandStack.Push(ellipseCommand);
                        _undoneCommands.Clear();
                    }

                    UpdateControls();
                    Invalidate();
                    break;
                } //end mode switch
            }     //end leftclick
            else if (e.Button == MouseButtons.Right)
            {
                if (_activemode == Mode.Controller)
                {
                    SetupRightClickmenu();
                }
            }
        }