Advertisement
wingman007

C#_WinForms_CreateGraphics

Jan 24th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace ParentWindow
  12. {
  13.     public partial class Paint : Form
  14.     {
  15.         bool paint = false;
  16.         SolidBrush color;
  17.         public Paint()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void Paint_Load(object sender, EventArgs e)
  23.         {
  24.         }
  25.  
  26.         private void panel1_MouseUp(object sender, MouseEventArgs e)
  27.         {
  28.             paint = false;
  29.         }
  30.  
  31.         private void panel1_MouseDown(object sender, MouseEventArgs e)
  32.         {
  33.             paint = true;
  34.         }
  35.  
  36.         private void panel1_MouseMove(object sender, MouseEventArgs e)
  37.         {
  38.             if (paint)
  39.             {
  40.                 color = new SolidBrush(Color.Black);
  41.                 Graphics g = panel1.CreateGraphics();
  42.                 g.FillEllipse(color, e.X, e.Y, 10, 10);
  43.                 g.Dispose();
  44.             }
  45.         }
  46.  
  47.         private void button1_Click(object sender, EventArgs e)
  48.         {
  49.             Graphics gl = panel1.CreateGraphics();
  50.             gl.Clear(panel1.BackColor);
  51.         }
  52.  
  53.         private void panel1_Paint(object sender, PaintEventArgs e)
  54.         {
  55.  
  56.         }
  57.  
  58.     }
  59.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement