diff --git a/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooper.cs b/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooper.cs index 96fc949..98fdfb0 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooper.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/FormStormtrooper.cs @@ -9,13 +9,22 @@ namespace ProjectStormtrooper /// Поле-объект для прорисовки объекта /// private DrawingPlane? _drawingPlane; - private AbstractStrategy? _abstractStrategy; + /// + /// Стратегия перемещения + /// + private AbstractStrategy? _strategy; + /// + /// Выбранный автомобиль + /// + public DrawingPlane? SelectedPlane { get; private set; } /// /// Инициализация формы /// public FormStormtrooper() { InitializeComponent(); + _strategy = null; + SelectedPlane = null; } /// /// Метод прорисовки объекта @@ -39,11 +48,23 @@ namespace ProjectStormtrooper private void buttonCreateStormtrooper_Click(object sender, EventArgs e) { Random random = new(); + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + dopColor = dialog.Color; + } _drawingPlane = new DrawingStormtrooper( random.Next(100, 300), random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + color, + dopColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxStormtrooper.Width, @@ -60,10 +81,16 @@ namespace ProjectStormtrooper private void buttonCreatePlane_Click(object sender, EventArgs e) { Random random = new(); + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } _drawingPlane = new DrawingPlane( random.Next(100, 300), random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + color, pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height ); @@ -112,30 +139,40 @@ namespace ProjectStormtrooper } if (comboBoxStrategy.Enabled) { - _abstractStrategy = comboBoxStrategy.SelectedIndex switch + _strategy = comboBoxStrategy.SelectedIndex switch { 0 => new MoveToCenter(), 1 => new MoveToRightBottom(), _ => null, }; - if (_abstractStrategy == null) + if (_strategy == null) { return; } - _abstractStrategy.SetData(new DrawingObjectPlane(_drawingPlane), pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height); - comboBoxStrategy.Enabled = false; + _strategy.SetData(new DrawingObjectPlane(_drawingPlane), pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height); } - if (_abstractStrategy == null) + if (_strategy == null) { return; } - _abstractStrategy.MakeStep(); + comboBoxStrategy.Enabled = false; + _strategy.MakeStep(); Draw(); - if (_abstractStrategy.GetStatus() == Status.Finish) + if (_strategy.GetStatus() == Status.Finish) { comboBoxStrategy.Enabled = true; - _abstractStrategy = null; + _strategy = null; } } + /// + /// Выбор самолета + /// + /// + /// + private void ButtonSelectPlane_Click(object sender, EventArgs e) + { + SelectedPlane = _drawingPlane; + DialogResult = DialogResult.OK; + } } } \ No newline at end of file