views:

65

answers:

2

Hi,

I want to be able to allow users of my program to click on a button, for example, a button for freehand rectangles to be drawn onto a picturebox. I need code for allowing me to first draw on the picturebox, and secondly for all the shapes that can possibly be drawn free hand in c#, e.g. line, ellipse, freehand drawing, text.

Thanks in advance,

Chris

A: 

http://www.codeproject.com/KB/graphics/drawtools.aspx

Alex Farber
The problem is i have looked at this project and i can't make it work with a picturebox. I need it to allow the user to draw a desired shape onto a picturebox not a draw area.
Chris Bacon
I don't know any PictureBox feature which prevents it to be used as drawing canvas. I would try to create PictureBox-derived drawing area. Alternatively, you can use DrawArea control from the article, and draw picture on background.
Alex Farber
Anyway, the main idea of drawing is mouse messages handling. In the mouse message handlers drawing objects should be created and updated (moved, resized), following mouse move. Paint message handler redraws them.
Alex Farber
A: 

This seems closely related to this question: http://stackoverflow.com/questions/3805437/drawing-with-graphics-class-in-c

Which links to a pretty good looking article on CodeProject: http://www.codeproject.com/KB/graphics/drawtools.aspx

Guy