private void canvas_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { _selectedFigure = null; for (int i = 0; i < _figures.Count; i++) { Figure fig = _figures.getAt(i); if (fig.ptInRegion(e.X, e.Y)) { _selectedFigure = fig; break; } } if (_selectedFigure != null) { _selectedFigure.popup(canvas, e.Location); } else { mainPopup.popup(canvas, e.Location); } } else { _selectedFigure = null; for (int i = 0; i < _figures.Count; i++) { Figure fig = _figures.getAt(i); if (fig.ptInRegion(e.X, e.Y)) { _selectedFigure = fig; break; } } if (_selectedFigure != null) { _figures.removeFigure(_selectedFigure); _currentX = e.X; _currentY = e.Y; _actionMode = MOVING; canvas.Invalidate(); return; } Graphics g = canvas.CreateGraphics(); Pen aPen = new Pen(Color.Black, 2); if (whatToDraw == DRAW_RECT) { _selectedFigure = new Box(canvas, e.X, e.Y, e.X, e.Y); _selectedFigure.setPopup(boxPopup); } else if (whatToDraw == DRAW_LINE) { _selectedFigure = new Line(canvas, e.X, e.Y, e.X, e.Y); _selectedFigure.setPopup(linePopup); } else if (whatToDraw == DRAW_CIRCLE) { _selectedFigure = new Circle(canvas, e.X, e.Y, e.X, e.Y); _selectedFigure.setPopup(circlePopup); } else if (whatToDraw == DRAW_POINT) { _selectedFigure = new Point(canvas, e.X, e.Y); _selectedFigure.setPopup(pointPopup); } _selectedFigure.draw(g); bMousePressed = true; _actionMode = DRAWING; } }
public void popup(PictureBox canvas, System.Drawing.Point pos) { _popup.popup(canvas, pos); }