Example #1
0
        private void PictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (_operation == 1)
            {
                if (_regularPolygonCache != null)
                {
                    var center = _regularPolygonCache.Center;
                    var x      = center.X - e.X;
                    var y      = center.Y - e.Y;
                    _regularPolygonCache.Radius = (float)Math.Sqrt(x * x + y * y);
                    Redraw();
                }

                return;
            }

            if (_primaryOperand != null && e.Button == MouseButtons.Left)
            {
                switch (_operation)
                {
                case 2:
                    _primaryOperand.Move(e.X - _mouseStartPosition.X, e.Y - _mouseStartPosition.Y);
                    Redraw();
                    _mouseStartPosition = e.Location;
                    break;

                case 3:
                    _primaryOperand.Rotate(_mouseStartPosition, (e.X > _mouseStartPosition.X ? 1 : -1) * (Math.PI / 180.0));
                    Redraw();
                    break;

                case 4:
                    _primaryOperand.Scale(_mouseStartPosition, e.X > _mouseStartPosition.X ? 1.01 : 0.99);
                    Redraw();
                    break;
                }
            }
        }
Example #2
0
 public void Move(int dx, int dy)
 {
     _operand1.Move(dx, dy);
     _operand2.Move(dx, dy);
     RecalculateSides();
 }