This is my first program submittal to this site. I wrote this tiny snippet of code to show how to draw simple lines and rectangles in VS.NET using C#. The program is not perfect. The main problem to the procedure is, it doesn't bound the user from drawing beyond the form's boundary. Perhaps when I have time, I'll look into the ability to limit the selection process to the form. One solution would be to check the mouse pointer location on the form and restrict the user from going beyond the form's boundary. If anyone comes up with a better idea, please post your comments or solutions.
There were several submittals to this site regarding drawing selection rectangles and rubberband lines. For those of you who ran across these submittals, you might want to take a look at this tiny program to get some ideas.
The main trick to this program is in the mouse move:
pe = new Point(e.X, e.Y);
SelectRect.Width = e.X - SelectRect.X;
SelectRect.Height = e.Y - SelectRect.Y;
DrawReversible procedures toggle the drawing between the specified color and the background color. Also, you will need to attain the screen coordinates in order to begin drawing where the mouse is pointed to on the form.
I hope this program helps beginning control builders to gain some ideas on .NET drawing procedures.
A software programmer hobbyist who have been developing for a number of years spanning multiple languages and platforms.