diff --git a/Airbus/Airbus/AbstractMap.cs b/Airbus/Airbus/AbstractMap.cs index e7bdd22..bcb2d68 100644 --- a/Airbus/Airbus/AbstractMap.cs +++ b/Airbus/Airbus/AbstractMap.cs @@ -16,7 +16,8 @@ namespace Airbus protected float _size_y; protected readonly Random _random = new(); protected readonly int _freeRoad = 0; - protected readonly int _barrier = 1; + protected readonly int _barrier = 1; + public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject) { diff --git a/Airbus/Airbus/DrawningAirbus.cs b/Airbus/Airbus/DrawningAirbus.cs index 6392333..7d06a71 100644 --- a/Airbus/Airbus/DrawningAirbus.cs +++ b/Airbus/Airbus/DrawningAirbus.cs @@ -24,6 +24,7 @@ namespace Airbus { Plane = new EntityAirbus(speed, weight, bodyColor, dopColor, bodyKit, wing, sportLine); } + public override void DrawTransport(Graphics g) { if (Plane is not EntityAirbus Airbus) @@ -60,12 +61,9 @@ namespace Airbus g.DrawEllipse(pen, _startPosX, _startPosY + 18, 16, 16); g.FillEllipse(fireBrush, _startPosX, _startPosY + 18, 16, 16); - - } if (Airbus.Wing) { - g.DrawLine(pen, _startPosX + 70, _startPosY + 20, _startPosX + 70, _startPosY + 35); g.DrawLine(pen, _startPosX + 70, _startPosY + 20, _startPosX + 90, _startPosY + 35); } @@ -73,11 +71,7 @@ namespace Airbus { g.DrawEllipse(pen, _startPosX + 110, _startPosY + 40, 9, 9); g.FillEllipse(WindowBrush, _startPosX + 110, _startPosY + 40, 9, 9); - } - - } - } } diff --git a/Airbus/Airbus/EntityAirbus.cs b/Airbus/Airbus/EntityAirbus.cs index 22d0bb4..128229d 100644 --- a/Airbus/Airbus/EntityAirbus.cs +++ b/Airbus/Airbus/EntityAirbus.cs @@ -11,7 +11,7 @@ namespace Airbus /// /// Дополнительный цвет /// - public Color DopColor { get; private set; } + public Color DopColor { get; set; } /// /// Признак наличия обвеса /// diff --git a/Airbus/Airbus/EntityPlane.cs b/Airbus/Airbus/EntityPlane.cs index a86e8b2..9f7b845 100644 --- a/Airbus/Airbus/EntityPlane.cs +++ b/Airbus/Airbus/EntityPlane.cs @@ -19,7 +19,7 @@ namespace Airbus /// /// Цвет кузова /// - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } /// /// Шаг перемещения автомобиля /// diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 2404f83..9bbe79c 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -111,24 +111,27 @@ namespace Airbus /// /// private void buttonAddPlane_Click_1(object sender, EventArgs e) + { + var formPlaneConfig = new FormPlaneConfig(); + formPlaneConfig.AddEvent(AddPlane); + // TODO + formPlaneConfig.Show(); + } + + private void AddPlane(DrawningPlane plane) { if (listBoxMaps.SelectedIndex == -1) { - return; + MessageBox.Show("Перед добавлением объекта необходимо создать карту"); } - FormPlane form = new(); - if (form.ShowDialog() == DialogResult.OK) + else if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectPlane(plane) != -1) { - DrawningObjectPlane plane = new(form.SelectedPlane); - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + plane >= 0) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); } } /// diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs new file mode 100644 index 0000000..1d81cc3 --- /dev/null +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -0,0 +1,394 @@ +namespace Airbus +{ + partial class FormPlaneConfig + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxConfig = new System.Windows.Forms.GroupBox(); + this.labelModifiedObject = new System.Windows.Forms.Label(); + this.labelSimpleObject = new System.Windows.Forms.Label(); + this.groupBoxColor = new System.Windows.Forms.GroupBox(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelPink = new System.Windows.Forms.Panel(); + this.panelGol = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelOrange = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.checkBoxSportLine = new System.Windows.Forms.CheckBox(); + this.checkBoxWing = new System.Windows.Forms.CheckBox(); + this.checkBoxBodyKit = new System.Windows.Forms.CheckBox(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.labelWeight = new System.Windows.Forms.Label(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.labelSpeed = new System.Windows.Forms.Label(); + this.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.panelObject = new System.Windows.Forms.Panel(); + this.labelBaseColor = new System.Windows.Forms.Label(); + this.labelDopColor = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxConfig.SuspendLayout(); + this.groupBoxColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.panelObject.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxConfig + // + this.groupBoxConfig.Controls.Add(this.labelModifiedObject); + this.groupBoxConfig.Controls.Add(this.labelSimpleObject); + this.groupBoxConfig.Controls.Add(this.groupBoxColor); + this.groupBoxConfig.Controls.Add(this.checkBoxSportLine); + this.groupBoxConfig.Controls.Add(this.checkBoxWing); + this.groupBoxConfig.Controls.Add(this.checkBoxBodyKit); + this.groupBoxConfig.Controls.Add(this.numericUpDownWeight); + this.groupBoxConfig.Controls.Add(this.labelWeight); + this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed); + this.groupBoxConfig.Controls.Add(this.labelSpeed); + this.groupBoxConfig.Location = new System.Drawing.Point(14, 16); + this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxConfig.Name = "groupBoxConfig"; + this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxConfig.Size = new System.Drawing.Size(569, 233); + this.groupBoxConfig.TabIndex = 0; + this.groupBoxConfig.TabStop = false; + this.groupBoxConfig.Text = "Параметры"; + // + // labelModifiedObject + // + this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelModifiedObject.Location = new System.Drawing.Point(453, 173); + this.labelModifiedObject.Name = "labelModifiedObject"; + this.labelModifiedObject.Size = new System.Drawing.Size(109, 46); + this.labelModifiedObject.TabIndex = 7; + this.labelModifiedObject.Text = "Продвинутый"; + this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + // + // labelSimpleObject + // + this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelSimpleObject.Location = new System.Drawing.Point(341, 173); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(105, 46); + this.labelSimpleObject.TabIndex = 1; + this.labelSimpleObject.Text = "Простой"; + this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + // + // groupBoxColor + // + this.groupBoxColor.Controls.Add(this.panelBlack); + this.groupBoxColor.Controls.Add(this.panelPink); + this.groupBoxColor.Controls.Add(this.panelGol); + this.groupBoxColor.Controls.Add(this.panelBlue); + this.groupBoxColor.Controls.Add(this.panelOrange); + this.groupBoxColor.Controls.Add(this.panelYellow); + this.groupBoxColor.Controls.Add(this.panelGreen); + this.groupBoxColor.Controls.Add(this.panelRed); + this.groupBoxColor.Location = new System.Drawing.Point(341, 20); + this.groupBoxColor.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxColor.Name = "groupBoxColor"; + this.groupBoxColor.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxColor.Size = new System.Drawing.Size(222, 149); + this.groupBoxColor.TabIndex = 1; + this.groupBoxColor.TabStop = false; + this.groupBoxColor.Text = "Цвета"; + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(165, 91); + this.panelBlack.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(46, 53); + this.panelBlack.TabIndex = 1; + this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelPink + // + this.panelPink.BackColor = System.Drawing.Color.Fuchsia; + this.panelPink.Location = new System.Drawing.Point(112, 91); + this.panelPink.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelPink.Name = "panelPink"; + this.panelPink.Size = new System.Drawing.Size(46, 53); + this.panelPink.TabIndex = 1; + this.panelPink.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGol + // + this.panelGol.BackColor = System.Drawing.Color.Cyan; + this.panelGol.Location = new System.Drawing.Point(59, 91); + this.panelGol.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelGol.Name = "panelGol"; + this.panelGol.Size = new System.Drawing.Size(46, 53); + this.panelGol.TabIndex = 1; + this.panelGol.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192))))); + this.panelBlue.Location = new System.Drawing.Point(7, 91); + this.panelBlue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(46, 53); + this.panelBlue.TabIndex = 2; + this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelOrange + // + this.panelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); + this.panelOrange.Location = new System.Drawing.Point(165, 29); + this.panelOrange.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelOrange.Name = "panelOrange"; + this.panelOrange.Size = new System.Drawing.Size(46, 53); + this.panelOrange.TabIndex = 1; + this.panelOrange.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(112, 29); + this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(46, 53); + this.panelYellow.TabIndex = 1; + this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.Lime; + this.panelGreen.Location = new System.Drawing.Point(59, 29); + this.panelGreen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(46, 53); + this.panelGreen.TabIndex = 1; + this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(7, 29); + this.panelRed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(46, 53); + this.panelRed.TabIndex = 0; + this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // checkBoxSportLine + // + this.checkBoxSportLine.AutoSize = true; + this.checkBoxSportLine.Location = new System.Drawing.Point(19, 195); + this.checkBoxSportLine.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.checkBoxSportLine.Name = "checkBoxSportLine"; + this.checkBoxSportLine.Size = new System.Drawing.Size(320, 24); + this.checkBoxSportLine.TabIndex = 6; + this.checkBoxSportLine.Text = "Признак наличия отсека для пассажиров"; + this.checkBoxSportLine.UseVisualStyleBackColor = true; + // + // checkBoxWing + // + this.checkBoxWing.AutoSize = true; + this.checkBoxWing.Location = new System.Drawing.Point(19, 161); + this.checkBoxWing.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.checkBoxWing.Name = "checkBoxWing"; + this.checkBoxWing.Size = new System.Drawing.Size(233, 24); + this.checkBoxWing.TabIndex = 5; + this.checkBoxWing.Text = "Признак наличия антикрыла"; + this.checkBoxWing.UseVisualStyleBackColor = true; + // + // checkBoxBodyKit + // + this.checkBoxBodyKit.AutoSize = true; + this.checkBoxBodyKit.Location = new System.Drawing.Point(19, 128); + this.checkBoxBodyKit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.checkBoxBodyKit.Name = "checkBoxBodyKit"; + this.checkBoxBodyKit.Size = new System.Drawing.Size(265, 24); + this.checkBoxBodyKit.TabIndex = 4; + this.checkBoxBodyKit.Text = "Признак наличия доп.двигателей"; + this.checkBoxBodyKit.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(94, 89); + this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(111, 27); + this.numericUpDownWeight.TabIndex = 3; + // + // labelWeight + // + this.labelWeight.AutoSize = true; + this.labelWeight.Location = new System.Drawing.Point(19, 92); + this.labelWeight.Name = "labelWeight"; + this.labelWeight.Size = new System.Drawing.Size(36, 20); + this.labelWeight.TabIndex = 2; + this.labelWeight.Text = "Вес:"; + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(94, 37); + this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; + this.numericUpDownSpeed.Size = new System.Drawing.Size(111, 27); + this.numericUpDownSpeed.TabIndex = 1; + // + // labelSpeed + // + this.labelSpeed.AutoSize = true; + this.labelSpeed.Location = new System.Drawing.Point(19, 40); + this.labelSpeed.Name = "labelSpeed"; + this.labelSpeed.Size = new System.Drawing.Size(76, 20); + this.labelSpeed.TabIndex = 0; + this.labelSpeed.Text = "Скорость:"; + // + // pictureBoxObject + // + this.pictureBoxObject.Location = new System.Drawing.Point(18, 69); + this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(250, 117); + this.pictureBoxObject.TabIndex = 0; + this.pictureBoxObject.TabStop = false; + // + // panelObject + // + this.panelObject.AllowDrop = true; + this.panelObject.Controls.Add(this.labelBaseColor); + this.panelObject.Controls.Add(this.labelDopColor); + this.panelObject.Controls.Add(this.pictureBoxObject); + this.panelObject.Location = new System.Drawing.Point(597, 16); + this.panelObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelObject.Name = "panelObject"; + this.panelObject.Size = new System.Drawing.Size(287, 200); + this.panelObject.TabIndex = 1; + this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); + this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); + // + // labelBaseColor + // + this.labelBaseColor.AllowDrop = true; + this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelBaseColor.Location = new System.Drawing.Point(18, 13); + this.labelBaseColor.Name = "labelBaseColor"; + this.labelBaseColor.Size = new System.Drawing.Size(109, 46); + this.labelBaseColor.TabIndex = 9; + this.labelBaseColor.Text = "Цвет"; + this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop); + this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter); + // + // labelDopColor + // + this.labelDopColor.AllowDrop = true; + this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelDopColor.Location = new System.Drawing.Point(159, 13); + this.labelDopColor.Name = "labelDopColor"; + this.labelDopColor.Size = new System.Drawing.Size(109, 46); + this.labelDopColor.TabIndex = 8; + this.labelDopColor.Text = "Доп. цвет"; + this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop); + this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter); + // + // buttonOk + // + this.buttonOk.Location = new System.Drawing.Point(597, 224); + this.buttonOk.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(114, 31); + this.buttonOk.TabIndex = 2; + this.buttonOk.Text = "Добавить"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(774, 224); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(110, 31); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FormPlaneConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(897, 257); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.panelObject); + this.Controls.Add(this.groupBoxConfig); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Name = "FormPlaneConfig"; + this.Text = "Создание объекта"; + this.groupBoxConfig.ResumeLayout(false); + this.groupBoxConfig.PerformLayout(); + this.groupBoxColor.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.panelObject.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBoxConfig; + private CheckBox checkBoxSportLine; + private CheckBox checkBoxWing; + private CheckBox checkBoxBodyKit; + private NumericUpDown numericUpDownWeight; + private Label labelWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelSpeed; + private Label labelModifiedObject; + private Label labelSimpleObject; + private GroupBox groupBoxColor; + private Panel panelBlack; + private Panel panelPink; + private Panel panelGol; + private Panel panelBlue; + private Panel panelOrange; + private Panel panelYellow; + private Panel panelGreen; + private Panel panelRed; + private PictureBox pictureBoxObject; + private Panel panelObject; + private Label labelDopColor; + private Button buttonOk; + private Button buttonCancel; + private Label labelBaseColor; + } +} \ No newline at end of file diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs new file mode 100644 index 0000000..b8d2caa --- /dev/null +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -0,0 +1,177 @@ +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 Airbus +{ + public partial class FormPlaneConfig : Form + { + /// + /// Переменная-выбранная машина + /// + DrawningPlane _plane = null; + /// + /// Событие + /// + private event Action EventAddPlane; + /// + /// Конструктор + /// + public FormPlaneConfig() + { + InitializeComponent(); + panelBlack.MouseDown += PanelColor_MouseDown; + panelPink.MouseDown += PanelColor_MouseDown; + panelOrange.MouseDown += PanelColor_MouseDown; + panelGreen.MouseDown += PanelColor_MouseDown; + panelRed.MouseDown += PanelColor_MouseDown; + panelGol.MouseDown += PanelColor_MouseDown; + panelYellow.MouseDown += PanelColor_MouseDown; + panelBlue.MouseDown += PanelColor_MouseDown; + // TODO buttonCancel.Click with lambda + buttonCancel.Click += (s, e) => Close(); + } + /// + /// Отрисовать машину + /// + private void DrawPlane() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _plane?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height); + _plane?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + /// + /// Добавление события + /// + /// + public void AddEvent(Action ev) + { + if (EventAddPlane == null) + { + EventAddPlane = new Action(ev); + } + else + { + EventAddPlane += ev; + } + } + /// + /// Передаем информацию при нажатии на Label + /// + /// + /// + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); + } + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + /// + /// Действия при приеме перетаскиваемой информации + /// + /// + /// + private void PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "labelSimpleObject": + _plane = new DrawningPlane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Black, + checkBoxBodyKit.Checked, checkBoxWing.Checked, + checkBoxSportLine.Checked); + break; + } + DrawPlane(); + } + /// + /// Отправляем цвет с панели + /// + /// + /// + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + /// + /// Принимаем основной цвет + /// + /// + /// + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + // TODO Call method from object _car and set color + if (_plane == null) + { + return; + } + _plane.Plane.BodyColor = (Color)e.Data.GetData(typeof(Color)); + DrawPlane(); + } + /// + /// Принимаем дополнительный цвет + /// + /// + /// + private void LabelDopColor_DragDrop(object sender, DragEventArgs e) + { + if (_plane == null || _plane.Plane is not EntityAirbus airbus) + { + return; + } + airbus.DopColor = (Color)e.Data.GetData(typeof(Color)); + DrawPlane(); + } + /// + /// Добавление машины + /// + /// + /// + private void buttonOk_Click(object sender, EventArgs e) + { + EventAddPlane?.Invoke(_plane); + Close(); + } + } +} diff --git a/Airbus/Airbus/FormPlaneConfig.resx b/Airbus/Airbus/FormPlaneConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Airbus/Airbus/FormPlaneConfig.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file