diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index c778c91..0ff99f2 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -10,7 +10,7 @@ namespace AirBomber { public int Speed { get; private set; } public float Weight { get; private set; } - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } public float Step => Speed * 100 / Weight; public EntityAirBomber(int speed, float weight, Color bodyColor) diff --git a/AirBomber/AirBomber/EntityWarplane.cs b/AirBomber/AirBomber/EntityWarplane.cs index f66ecac..cebe323 100644 --- a/AirBomber/AirBomber/EntityWarplane.cs +++ b/AirBomber/AirBomber/EntityWarplane.cs @@ -8,7 +8,7 @@ namespace AirBomber { internal class EntityWarplane : EntityAirBomber { - public Color DopColor { get; private set; } + public Color DopColor { get; set; } public bool Engines { get; private set; } diff --git a/AirBomber/AirBomber/FormAirBomberConfig.Designer.cs b/AirBomber/AirBomber/FormAirBomberConfig.Designer.cs index 07d65f7..d63c109 100644 --- a/AirBomber/AirBomber/FormAirBomberConfig.Designer.cs +++ b/AirBomber/AirBomber/FormAirBomberConfig.Designer.cs @@ -51,7 +51,7 @@ this.labelDopColor = new System.Windows.Forms.Label(); this.labelBaseColor = new System.Windows.Forms.Label(); this.buttonOk = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); this.groupBoxConfig.SuspendLayout(); this.groupBoxColors.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); @@ -274,6 +274,8 @@ this.labelDopColor.TabIndex = 10; 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); // // labelBaseColor // @@ -285,6 +287,8 @@ 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); // // buttonOk // @@ -296,21 +300,21 @@ this.buttonOk.UseVisualStyleBackColor = true; this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click); // - // button2 + // buttonCancel // - this.button2.Location = new System.Drawing.Point(908, 226); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(105, 38); - this.button2.TabIndex = 4; - this.button2.Text = "Отмена"; - this.button2.UseVisualStyleBackColor = true; + this.buttonCancel.Location = new System.Drawing.Point(908, 226); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(105, 38); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; // // FormAirBomberConfig // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1055, 279); - this.Controls.Add(this.button2); + this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOk); this.Controls.Add(this.panelObject); this.Controls.Add(this.groupBoxConfig); @@ -352,6 +356,6 @@ private Label labelDopColor; private Label labelBaseColor; private Button buttonOk; - private Button button2; + private Button buttonCancel; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/FormAirBomberConfig.cs b/AirBomber/AirBomber/FormAirBomberConfig.cs index eea585a..754d5b8 100644 --- a/AirBomber/AirBomber/FormAirBomberConfig.cs +++ b/AirBomber/AirBomber/FormAirBomberConfig.cs @@ -27,7 +27,7 @@ namespace AirBomber panelPurple.MouseDown += PanelColor_MouseDown; panelGreen.MouseDown += PanelColor_MouseDown; - // TODO buttonCancel.Click with lambda + buttonCancel.Click += (object sender, EventArgs e) => { Close(); }; } private void DrawAirBomber() @@ -70,12 +70,16 @@ namespace AirBomber private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - // TODO Call method from object _car and set color + if (_airBomber == null) return; + _airBomber.AirBomber.BodyColor = (Color)e.Data.GetData(typeof(Color)); + DrawAirBomber(); } private void LabelDopColor_DragDrop(object sender, DragEventArgs e) { - // TODO Call method from object _car if _car is DrawningSportCar and set dop color + if (_airBomber == null || !(_airBomber.AirBomber is EntityWarplane airBomber)) return; + airBomber.DopColor = (Color)e.Data.GetData(typeof(Color)); + DrawAirBomber(); } private void PanelObject_DragEnter(object sender, DragEventArgs e) diff --git a/AirBomber/AirBomber/FormMapWithSetAirBomber.cs b/AirBomber/AirBomber/FormMapWithSetAirBomber.cs index 82af5df..9549b8f 100644 --- a/AirBomber/AirBomber/FormMapWithSetAirBomber.cs +++ b/AirBomber/AirBomber/FormMapWithSetAirBomber.cs @@ -57,10 +57,27 @@ namespace AirBomber private void ButtonAddAirBomber_Click(object sender, EventArgs e) { var formAirBomberConfig = new FormAirBomberConfig(); - // TODO Call method AddEvent form formCarConfig + formAirBomberConfig.AddEvent(AddAirBomber); formAirBomberConfig.Show(); } + private void AddAirBomber(DrawningBomber airBomber) + { + if (listBoxMaps.SelectedIndex == -1) + { + return; + } + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectBomber(airBomber) > -1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + private void ButtonRemoveAirBomber_Click(object sender, EventArgs e) { if (listBoxMaps.SelectedIndex == -1)