I am drawing rectangles or ellipses (depends on what is chosen) on a form using the Graphics object. Is there any way one can manipulate these graphical objects after they've been drawn? I mean actions such as resizing, deleting, dragging etc. Also, worth mentioning is the fact that there can be multiple shapes drawn on the same form and that they can overlap.
Drawing itself looks like this, triggered by the ScrollableControl's OnPaint() event - simply passing these methods a PaintEventArgs's Graphics object.
protected override void Fill(System.Drawing.Graphics g, Brush b)
{
g.FillEllipse(b, m_topLeft.X, m_topLeft.Y, m_width, m_height);
}
protected override void Draw(System.Drawing.Graphics g, Pen p)
{
g.DrawEllipse(p, m_topLeft.X, m_topLeft.Y, m_width, m_height);
}
I'd like to be able to click on a shape, choose what to do with it and act accordingly. I was thinking maybe I could check whether the cursor's position is within bounds of the shape (m_topLeft, m_width and m_height data members) and go from there. That doesn't take care of the potential overlapping though, even if it did work. There would be two (or more) shapes to which the selected point could belong to.
This is an example of two overlapping shapes (a rectangle and an ellipse) drawn using the user-defined parameters: