private void DrawBox_MouseMove(object sender, MouseEventArgs e) { if (Drawing) { Line.SecondPoint = new Point(e.X, e.Y); DrawBox.Refresh(); } }
private void DrawButton_Click(object sender, EventArgs e) { if (shapes == null) { shapes = new List <Shape>(); } Graphics draw = DrawBox.CreateGraphics(); int randomShape; if (checkBoxColorOfShapes.Checked) { color = colorDialog.Color; } else { color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)); } for (int i = 0; i < trackBarDrawings.Value; i++) { switch (randomShape = rnd.Next(0, 5)) { case 0: shapes.Add(new Point(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), pen = new Pen(color, 2))); break; case 1: shapes.Add(new Line(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), pen = new Pen(color, 2))); break; case 2: shapes.Add(new Rectangle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), rnd.Next(0, DrawBox.Width), rnd.Next(DrawBox.Height), pen = new Pen(color, 2))); break; case 3: shapes.Add(new Circle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), pen = new Pen(color, 2))); break; case 4: shapes.Add(new Ellipse(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), pen = new Pen(color, 2))); break; } } DrawBox.Refresh(); }
private void button1_Click(object sender, EventArgs e) { Pen pen; if (shapes == null) { shapes = new List <Shape>(); } if (checkBoxColorOfShapes.Checked) { color = colorDialog.Color; } else { color = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)); } for (int i = 0; i < trackBarDrawings.Value; i++) { switch (comboBoxAdd.SelectedIndex) { case 0: shapes.Add(new Point(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), pen = new Pen(color, 2))); break; case 1: shapes.Add(new Line(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), pen = new Pen(color, 2))); break; case 2: shapes.Add(new Rectangle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), rnd.Next(0, DrawBox.Width), rnd.Next(DrawBox.Height), pen = new Pen(color, 2))); break; case 3: shapes.Add(new Circle(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), pen = new Pen(color, 2))); break; case 4: shapes.Add(new Ellipse(rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), rnd.Next(0, DrawBox.Width), rnd.Next(0, DrawBox.Height), pen = new Pen(color, 2))); break; } } DrawBox.Refresh(); }
private void buttonRemove_Click(object sender, EventArgs e) { int number = (int)numericUpDownNumOfShape.Value; if (shapes == null) { shapes = new List <Shape>(); } if (number < shapes.Count) { shapes.RemoveAt(number); DrawBox.Refresh(); } }
private void button2_Click(object sender, EventArgs e) { if (textBoxChangeX.Text == null) { textBoxChangeX.Text = "0"; } if (textBoxChangeY.Text == null) { textBoxChangeY.Text = "0"; } if (shapes != null && textBoxChangeX.Text != "0" && textBoxChangeY.Text != "0") { shapes[(int)numericUpDownNumOfShape.Value].CoordsChange(int.Parse(textBoxChangeX.Text), int.Parse(textBoxChangeY.Text)); DrawBox.Refresh(); } }
private void buttonMoveAll_Click(object sender, EventArgs e) { if (textBoxChangeX.Text == null) { textBoxChangeX.Text = "0"; } if (textBoxChangeY.Text == null) { textBoxChangeY.Text = "0"; } if (shapes != null && textBoxChangeX.Text != "0" && textBoxChangeY.Text != "0") { for (int i = 0; i < shapes.Count; i++) { shapes[i].CoordsChange(int.Parse(textBoxChangeX.Text), int.Parse(textBoxChangeY.Text)); } DrawBox.Refresh(); } }
private void ClearButton_Click(object sender, EventArgs e) { ShapePoints.Clear(); DrawBox.Refresh(); }
private void CreateDraw_Click(object sender, EventArgs e) { ShapePoints.Clear(); DrawRandomShapes(Count.Value); DrawBox.Refresh(); }