Windows Develop Bookmark and Share   
 index > Windows Forms General > [C#] Drawing like MS Paint
 

[C#] Drawing like MS Paint

Hello,

How to draw in C# just like MS Paint? I tried but I can't get it exactly like Paint. Here's my code:
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
   if (e.Button == MouseButtons.Left)
   {
      Graphics g = this.CreateGraphics();
      Rectangle rect = new Rectangle(e.X, e.Y, 5, 5);
      g.FillEllipse(new SolidBrush(Color.Red), rect);
   }
}

The above code gives me a bad result. Here's a screenshot: http://img143.imageshack.us/img143/3517/painty.gif

Is it possible to draw like Ms Paint?

Thanks
farooqaaa  Saturday, September 12, 2009 12:48 PM
Hmmm ok, there's no download link there. I also checked the local samples in the installation folder - not there either (on VS 2010). This earlier thread :

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5ab468b6-0571-4a73-8687-e107f976cd3c

has an alternate link to :

http://www.csharphelp.com/archives/archive222.html

which is a similar app (but not same as the msdn sample).
http://blog.voidnish.com
Nishant Sivakumar  Saturday, September 12, 2009 1:34 PM
Nishant Sivakumar  Saturday, September 12, 2009 12:56 PM
Check this,
http://www.codeproject.com/KB/graphics/drawtools.aspx
AUmidh  Saturday, September 12, 2009 12:56 PM
Take a look at the C# version of Scribble :

http://msdn.microsoft.com/en-us/library/aa645520(VS.71).aspx
http://blog.voidnish.com


I have never found the download for the C# sample. Only C++ versions. Just checked again today.
Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Saturday, September 12, 2009 1:22 PM
Hmmm ok, there's no download link there. I also checked the local samples in the installation folder - not there either (on VS 2010). This earlier thread :

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5ab468b6-0571-4a73-8687-e107f976cd3c

has an alternate link to :

http://www.csharphelp.com/archives/archive222.html

which is a similar app (but not same as the msdn sample).
http://blog.voidnish.com
Nishant Sivakumar  Saturday, September 12, 2009 1:34 PM
Thanks! that was helpful. But now what I was looking for.

I've found what I was looking for:

http://www.java2s.com/Code/CSharp/2D-Graphics/Scribbledraganddraw.htm

To make the drawing smoother use: "g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;"

Thanks to all who replied.
farooqaaa  Saturday, September 12, 2009 2:15 PM
Please close the thread by marking one of the replies as "Answer". Thanks.
Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Saturday, September 12, 2009 2:38 PM
I used 2 as the width and height and that did the job for me.

Thanks SivaKumar.
farooqaaa  Saturday, September 12, 2009 2:53 PM
I used 2 as the width and height and that did the job for me.

Thanks SivaKumar.

Not if you're still using CreateGraphics and drawing in the MouseMove event. BobPowell.Net might help.
JohnWein  Saturday, September 12, 2009 3:13 PM

You can use google to search for other answers

Custom Search

More Threads

• ToolstripContainers
• How do I display images in my embedded HTML?
• Form.ShowIcon = False Causing Invalid Icon in Taskbar
• Controls with Vista Look and Feel
• loading text from file into listbox
• Open/ Save/ Print?
• Cache in Windows Applications
• Immediate window doesn't take string function in C#
• How to show a form depending on ListView selected item
• loading application after logon