-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathocksusu.cs
More file actions
57 lines (50 loc) · 1.43 KB
/
ocksusu.cs
File metadata and controls
57 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Drawing;
using System.Windows.Forms;
public class PaintForm : Form
{
private Point lastPoint;
private bool isMouseDown = false;
private Pen pen = new Pen(Color.Black, 5);
private Bitmap bitmap;
public PaintForm()
{
this.bitmap = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
this.DoubleBuffered = true;
this.Paint += PaintForm_Paint;
this.MouseDown += PaintForm_MouseDown;
this.MouseMove += PaintForm_MouseMove;
this.MouseUp += PaintForm_MouseUp;
}
private void PaintForm_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(bitmap, 0, 0);
}
private void PaintForm_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.lastPoint = e.Location;
this.isMouseDown = true;
}
}
private void PaintForm_MouseMove(object sender, MouseEventArgs e)
{
if (this.isMouseDown)
{
using (Graphics g = Graphics.FromImage(this.bitmap))
{
g.DrawLine(this.pen, this.lastPoint, e.Location);
this.lastPoint = e.Location;
}
this.Invalidate();
}
}
private void PaintForm_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.isMouseDown = false;
}
}
}