Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4.  
  5. namespace WindowsFormsApplication1
  6. {
  7. public partial class Form1 : Form
  8. {
  9. Bitmap drawBitmap;
  10. public Form1()
  11. {
  12. InitializeComponent();
  13. }
  14.  
  15. private void Form1_Load(object sender, EventArgs e)
  16. {
  17. InitDraw();
  18. }
  19.  
  20. private void button1_Click(object sender, EventArgs e)
  21. {
  22. Draw();
  23. }
  24.  
  25. private void InitDraw()
  26. {
  27. drawBitmap = new Bitmap(500, 500);
  28. pictureBox1.Image = drawBitmap;
  29. }
  30.  
  31. private void Draw()
  32. {
  33. Graphics g = Graphics.FromImage(pictureBox1.Image);
  34. Pen myPen = new Pen(Color.Black);
  35. g.DrawLine(myPen, 0, 0, 100, 100);
  36. myPen.Dispose();
  37. g.Dispose();
  38. Invalidate();
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement