Personally, I'd use a List of Rectangles (rectangles) to save the "regions". The other two variables are used to create (new_rectangle) and draw (path_rectangles) the rectangles.
Rectangle new_rectangle = new Rectangle ( );
Rectangle [ ] path_rectangles;
List <Rectangle> rectangles = new List < Rectangle > ( );
Your MouseDown event handler must populate the upper left corner of new_rectangle.
new_rectangle.X = e.X;
new_rectangle.Y = e.Y;
new_rectangle.Width = 0;
new_rectangle.Height = 0;
Your MouseUp event handler must populate the width and height of new_rectangle and also add the new_rectangle to the List of Rectangles.
new_rectangle.Width = Math.Abs ( new_rectangle.X - e.X );
new_rectangle.Height = Math.Abs ( new_rectangle.Y - e.Y );
rectangles.Add ( new_rectangle );
The button click event handler would then convert the List of rectangles into an array of rectangles and then invoke the Invalidate method.
path_rectangles = rectangles.ToArray ( );
this.Invalidate ( );
Finally, your OnPaint event handler would look something like:
protected override void OnPaint ( PaintEventArgs e )
{
GraphicsPath path;
base.OnPaint ( e );
path = new GraphicsPath ( );
path.AddRectangles ( path_rectangles );
e.Graphics.DrawPath ( Pens.Black, path );
}
I point out that the GraphicsPath object can be composed of polygons so your lines need not necessarily form rectangles.
Note that you must solve the problem of the initial point being below or to the right of the final point. The solution that I give does not consider this.