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; } } }
public void Scale(PointF center, double f) { _operand1.Scale(center, f); _operand2.Scale(center, f); RecalculateSides(); }