private void TransformationButton_Click(object sender, EventArgs e) { ResultLabel.Show(); ResultLabel.Text = "Выберите преобразование"; comboBox1.Show(); comboBox1.SelectedItem = comboBox1.Items[0]; textBox1.Show(); textBox2.Show(); label1.Show(); label2.Show(); OkButton.Show(); mode = "transform"; }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { switch (comboBox1.SelectedItem.ToString()) { case "Смещение": { if (current_transformation == "find point" && Points.Count == 4) { draw_point(Points[2].X, Points[2].Y, this.pictureBox1.BackColor); draw_point(Points[3].X, Points[3].Y, this.pictureBox1.BackColor); g.DrawLine(new Pen(this.pictureBox1.BackColor, 3), Points[2], Points[3]); Points.Remove(Points[3]); Points.Remove(Points[2]); g.DrawLine(new Pen(Color.Black, 3), Points[0], Points[1]); pictureBox1.Image = bmp; } current_transformation = "shift"; OkButton.Show(); textBox1.Show(); textBox2.Show(); label1.Show(); label2.Show(); label1.Text = "Введите сдвиг по X: "; label2.Text = "Введите сдвиг по Y: "; textBox1.Text = "0"; textBox2.Text = "0"; break; } case "Поворот примитива": { if (current_transformation == "find point" && Points.Count == 4) { draw_point(Points[2].X, Points[2].Y, this.pictureBox1.BackColor); draw_point(Points[3].X, Points[3].Y, this.pictureBox1.BackColor); g.DrawLine(new Pen(this.pictureBox1.BackColor, 3), Points[2], Points[3]); Points.Remove(Points[3]); Points.Remove(Points[2]); g.DrawLine(new Pen(Color.Black, 3), Points[0], Points[1]); pictureBox1.Image = bmp; } current_transformation = "rotation"; OkButton.Show(); textBox1.Show(); textBox2.Hide(); label1.Show(); label2.Hide(); label1.Text = "Введите угол поворота: "; textBox1.Text = "0"; break; } case "Поворот ребра": { if (current_transformation == "find point" && Points.Count == 4) { draw_point(Points[2].X, Points[2].Y, this.pictureBox1.BackColor); draw_point(Points[3].X, Points[3].Y, this.pictureBox1.BackColor); g.DrawLine(new Pen(this.pictureBox1.BackColor, 3), Points[2], Points[3]); Points.Remove(Points[3]); Points.Remove(Points[2]); g.DrawLine(new Pen(Color.Black, 3), Points[0], Points[1]); pictureBox1.Image = bmp; } if (current_primitive != "Edge") { OkButton.Hide(); textBox1.Hide(); textBox2.Hide(); label1.Hide(); label2.Hide(); MessageBox.Show("Выбран неправильный примитив", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } current_transformation = "edge rotation"; OkButton.Show(); textBox1.Hide(); textBox2.Hide(); label1.Hide(); label2.Hide(); break; } case "Масштабирование": { if (current_transformation == "find point" && Points.Count == 4) { draw_point(Points[2].X, Points[2].Y, this.pictureBox1.BackColor); draw_point(Points[3].X, Points[3].Y, this.pictureBox1.BackColor); g.DrawLine(new Pen(this.pictureBox1.BackColor, 3), Points[2], Points[3]); Points.Remove(Points[3]); Points.Remove(Points[2]); g.DrawLine(new Pen(Color.Black, 3), Points[0], Points[1]); pictureBox1.Image = bmp; } current_transformation = "scale"; OkButton.Show(); textBox1.Show(); textBox2.Show(); label1.Show(); label2.Show(); label1.Text = "Введите коэффициент по X: "; label2.Text = "Введите коэффициент по Y: "; textBox1.Text = "0"; textBox2.Text = "0"; break; } case "Поиск точки пересечения": { if (current_primitive != "Edge") { OkButton.Hide(); textBox1.Hide(); textBox2.Hide(); label1.Hide(); label2.Hide(); MessageBox.Show("Выбран неправильный примитив", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } current_transformation = "find point"; OkButton.Show(); textBox1.Hide(); textBox2.Hide(); label1.Show(); label2.Hide(); label1.Text = "Нарисуйте второе ребро"; break; } } }