Skip to content

Instantly share code, notes, and snippets.

@vivosmith
Created April 23, 2016 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vivosmith/6439a6b14cded8cb3a7c3e3f31ba8316 to your computer and use it in GitHub Desktop.
Save vivosmith/6439a6b14cded8cb3a7c3e3f31ba8316 to your computer and use it in GitHub Desktop.
C# paint program
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
bool shouldPaint = false;
public Form1()
{
InitializeComponent();
}
private void Form1_MouseDown(object sender, MouseEventArgs x) { shouldPaint= true; }
private void Form1_MouseUp(object sender, MouseEventArgs x) { shouldPaint = false; }
private void Form1_MouseMove(object sender, MouseEventArgs x) { if (shouldPaint) { using (Graphics graphics = CreateGraphics()) { graphics.FillEllipse(new SolidBrush(Color.BlueViolet), x.X, x.Y, 4, 4); } } }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment