-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
126 lines (112 loc) · 3.38 KB
/
Form1.cs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Paint
{
public partial class Form1 : Form
{
// Variables
Graphics draw;
int pen_x = -1, pen_y = -1;
bool pen_moving = false;
Pen my_pen;
bool my_dots = true;
public Form1()
{
InitializeComponent();
draw = flowLayoutPanel1.CreateGraphics();
draw.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
my_pen = new Pen(Color.Black, 3);
pictureBox6.BackColor = Color.Black;
my_pen.StartCap = my_pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
label4.Text = my_pen.Width.ToString();
my_dots = true;
Dots_check.Text = "Dots";
}
private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
PictureBox my_picture = (PictureBox)sender;
my_pen.Color = my_picture.BackColor;
pictureBox6.BackColor = my_picture.BackColor;
}
private void flowLayoutPanel1_MouseDown(object sender, MouseEventArgs e)
{
pen_moving = true;
pen_x = e.X;
pen_y = e.Y;
}
private void flowLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
{
if (pen_moving && pen_x != -1 && pen_y != -1)
{
if (my_dots)
{
draw.DrawLine(my_pen, new Point(pen_x, pen_y), e.Location);
pen_x = e.X;
pen_y = e.Y;
}
else
{
draw.DrawLine(my_pen, new Point(pen_x, pen_y), e.Location);
}
}
}
private void Dots_Click(object sender, EventArgs e)
{
Button my_obj = (Button)sender;
if (my_obj.Text == "Dots")
{
my_obj.Text = "Lines";
my_dots = false;
}
else if (my_obj.Text == "Lines")
{
my_obj.Text = "Dots";
my_dots = true;
}
}
private void pictureBox6_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
my_pen.Width += 2;
if (my_pen.Width > 0)
label4.Text = my_pen.Width.ToString();
else
{
label4.Text = Convert.ToString(1);
}
}
private void button2_Click(object sender, EventArgs e)
{
my_pen.Width -= 2;
if (my_pen.Width > 0)
label4.Text = my_pen.Width.ToString();
else
{
label4.Text = Convert.ToString(1);
my_pen.Width = 1;
}
}
private void clearbtn_Click(object sender, EventArgs e)
{
draw.Clear(BackColor);
}
private void flowLayoutPanel1_MouseUp(object sender, MouseEventArgs e)
{
pen_moving = false;
pen_x = -1;
pen_y = -1;
}
}
}