Created
April 23, 2016 04:00
-
-
Save vivosmith/6439a6b14cded8cb3a7c3e3f31ba8316 to your computer and use it in GitHub Desktop.
C# paint program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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