From 34e4d490c0062b9e971b8c5ec2020b20313d5b50 Mon Sep 17 00:00:00 2001 From: Whoisthatjulia Date: Wed, 13 Dec 2023 03:10:36 +0400 Subject: [PATCH] lab_5 --- AirFighter/AirFighter/DrawningAirFighter.cs | 12 +- AirFighter/AirFighter/EntityAirFighter.cs | 2 +- .../AirFighter/EntityAirFighterMilitary.cs | 2 +- .../AirFighter/FormAirFighterCollection.cs | 77 ++-- .../FormAirFighterConfig.Designer.cs | 362 ++++++++++++++++++ AirFighter/AirFighter/FormAirFighterConfig.cs | 180 +++++++++ .../AirFighter/FormAirFighterConfig.resx | 120 ++++++ AirFighter/AirFighter/IMoveableObject.cs | 3 +- .../AirFighter/IMoveableObject_Realise.cs | 14 - AirFighter/AirFighter/SetGeneric.cs | 8 +- 10 files changed, 717 insertions(+), 63 deletions(-) create mode 100644 AirFighter/AirFighter/FormAirFighterConfig.Designer.cs create mode 100644 AirFighter/AirFighter/FormAirFighterConfig.cs create mode 100644 AirFighter/AirFighter/FormAirFighterConfig.resx diff --git a/AirFighter/AirFighter/DrawningAirFighter.cs b/AirFighter/AirFighter/DrawningAirFighter.cs index 0e08b76..eb96955 100644 --- a/AirFighter/AirFighter/DrawningAirFighter.cs +++ b/AirFighter/AirFighter/DrawningAirFighter.cs @@ -17,9 +17,9 @@ namespace AirFighter.DrawningObjects { public EntityAirFighter? EntityAirFighter { get; protected set; } - private int _pictureWidth; - - private int _pictureHeight; + public int _pictureWidth; + + public int _pictureHeight; protected int _startPosX; @@ -30,7 +30,11 @@ namespace AirFighter.DrawningObjects protected readonly int _fighterHeight = 166; public DrawningAirFighter(int speed, double weight, Color bodyColor, int width, int height) - { + { + if (width < _fighterWidth || height < _fighterHeight) + { + return; + } _pictureWidth = width; _pictureHeight = height; EntityAirFighter = new EntityAirFighter(speed, weight, bodyColor); diff --git a/AirFighter/AirFighter/EntityAirFighter.cs b/AirFighter/AirFighter/EntityAirFighter.cs index 0390203..96fb9e7 100644 --- a/AirFighter/AirFighter/EntityAirFighter.cs +++ b/AirFighter/AirFighter/EntityAirFighter.cs @@ -11,7 +11,7 @@ namespace AirFighter.Entities { public int Speed { get; private set; } public double Weight { get; private set; } - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } public double Step => (double)Speed * 100 / Weight; public EntityAirFighter(int speed, double weight, Color bodyColor) { diff --git a/AirFighter/AirFighter/EntityAirFighterMilitary.cs b/AirFighter/AirFighter/EntityAirFighterMilitary.cs index 4f2fd97..1930b79 100644 --- a/AirFighter/AirFighter/EntityAirFighterMilitary.cs +++ b/AirFighter/AirFighter/EntityAirFighterMilitary.cs @@ -8,7 +8,7 @@ namespace AirFighter.Entities { public class EntityAirFighterMilitary : EntityAirFighter { - public Color AdditionalColor { get; private set; } + public Color AdditionalColor { get; set; } public bool Rocket { get; private set; } public bool Wing { get; private set; } public EntityAirFighterMilitary(int speed, double weight, Color bodyColor, Color additionalColor, bool rocket, bool wing) diff --git a/AirFighter/AirFighter/FormAirFighterCollection.cs b/AirFighter/AirFighter/FormAirFighterCollection.cs index 3380862..def6fe4 100644 --- a/AirFighter/AirFighter/FormAirFighterCollection.cs +++ b/AirFighter/AirFighter/FormAirFighterCollection.cs @@ -1,21 +1,15 @@ -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; + using AirFighter.DrawningObjects; using AirFighter.Drawnings; using AirFighter.Generics; using AirFighter.MovementStrategy; + + namespace AirFighter -{ +{ /// - /// Форма для работы с набором объектов класса DrawningCar + /// Форма для работы с набором объектов класса DrawningAirFighter /// public partial class FormAirFighterCollection : Form { @@ -29,7 +23,8 @@ namespace AirFighter public FormAirFighterCollection() { InitializeComponent(); - _storage = new AirFighterGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height); + _storage = new AirFighterGenericStorage(pictureBoxCollection.Width, + pictureBoxCollection.Height); } /// /// Заполнение listBoxObjects @@ -104,34 +99,44 @@ namespace AirFighter /// /// /// + private void addAirFighter(DrawningAirFighter fighter) + { + fighter._pictureHeight = pictureBoxCollection.Height; + fighter._pictureWidth = pictureBoxCollection.Width; + if (listBoxStorage.SelectedIndex == -1) + { + return; + } + + var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + + if (obj + fighter != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowAirFighter(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } private void ButtonAddAirFighter_Click(object sender, EventArgs e) { if (listBoxStorage.SelectedIndex == -1) { return; } - var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? - string.Empty]; - if (obj == null) - { - return; - } - FormAirFighter form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedAirFighter > -1) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowAirFighter(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } - + var formAirFighterConfig = new FormAirFighterConfig(); + formAirFighterConfig.AddEvent(addAirFighter); + formAirFighterConfig.Show(); } - /// + + + /// /// Удаление объекта из набора /// /// @@ -169,7 +174,8 @@ namespace AirFighter /// /// /// - private void ButtonRefreshCollection_Click(object sender, EventArgs e) + private void ButtonRefreshCollection_Click(object sender, EventArgs + e) { if (listBoxStorage.SelectedIndex == -1) { @@ -183,5 +189,8 @@ namespace AirFighter } pictureBoxCollection.Image = obj.ShowAirFighter(); } + + } } + diff --git a/AirFighter/AirFighter/FormAirFighterConfig.Designer.cs b/AirFighter/AirFighter/FormAirFighterConfig.Designer.cs new file mode 100644 index 0000000..8e92c71 --- /dev/null +++ b/AirFighter/AirFighter/FormAirFighterConfig.Designer.cs @@ -0,0 +1,362 @@ +namespace AirFighter +{ + partial class FormAirFighterConfig + { + /// + /// 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() + { + groupBox1 = new GroupBox(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + groupBox2 = new GroupBox(); + panelPurple = new Panel(); + panelYellow = new Panel(); + panelBlack = new Panel(); + panelBlue = new Panel(); + panelGray = new Panel(); + panelGreen = new Panel(); + panelWhite = new Panel(); + panelRed = new Panel(); + checkBoxWing = new CheckBox(); + checkBoxRocket = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + numericUpDownSpeed = new NumericUpDown(); + label2 = new Label(); + label1 = new Label(); + panelColor = new Panel(); + labelDopColor = new Label(); + labelBaseColor = new Label(); + pictureBoxObject = new PictureBox(); + ButtonOk = new Button(); + buttonCancel = new Button(); + groupBox1.SuspendLayout(); + groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + panelColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + SuspendLayout(); + // + // groupBox1 + // + groupBox1.Controls.Add(labelModifiedObject); + groupBox1.Controls.Add(labelSimpleObject); + groupBox1.Controls.Add(groupBox2); + groupBox1.Controls.Add(checkBoxWing); + groupBox1.Controls.Add(checkBoxRocket); + groupBox1.Controls.Add(numericUpDownWeight); + groupBox1.Controls.Add(numericUpDownSpeed); + groupBox1.Controls.Add(label2); + groupBox1.Controls.Add(label1); + groupBox1.Location = new Point(12, 12); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(454, 228); + groupBox1.TabIndex = 0; + groupBox1.TabStop = false; + groupBox1.Text = "Параметры"; + // + // labelModifiedObject + // + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(313, 146); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(87, 27); + labelModifiedObject.TabIndex = 8; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.MouseDown += LabelObject_MouseDown; + // + // labelSimpleObject + // + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(215, 146); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(87, 27); + labelSimpleObject.TabIndex = 7; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.MouseDown += LabelObject_MouseDown; + // + // groupBox2 + // + groupBox2.Controls.Add(panelPurple); + groupBox2.Controls.Add(panelYellow); + groupBox2.Controls.Add(panelBlack); + groupBox2.Controls.Add(panelBlue); + groupBox2.Controls.Add(panelGray); + groupBox2.Controls.Add(panelGreen); + groupBox2.Controls.Add(panelWhite); + groupBox2.Controls.Add(panelRed); + groupBox2.Location = new Point(215, 32); + groupBox2.Name = "groupBox2"; + groupBox2.Size = new Size(185, 106); + groupBox2.TabIndex = 6; + groupBox2.TabStop = false; + groupBox2.Text = "Цвета"; + // + // panelPurple + // + panelPurple.BackColor = Color.FromArgb(192, 0, 192); + panelPurple.Location = new Point(139, 63); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(35, 30); + panelPurple.TabIndex = 7; + panelPurple.MouseDown += panelColor_MouseDown; + // + // panelYellow + // + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(139, 22); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(35, 30); + panelYellow.TabIndex = 3; + panelYellow.MouseDown += panelColor_MouseDown; + // + // panelBlack + // + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(98, 63); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(35, 30); + panelBlack.TabIndex = 6; + panelBlack.MouseDown += panelColor_MouseDown; + // + // panelBlue + // + panelBlue.BackColor = Color.Blue; + panelBlue.Location = new Point(98, 22); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(35, 30); + panelBlue.TabIndex = 2; + panelBlue.MouseDown += panelColor_MouseDown; + // + // panelGray + // + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(57, 63); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(35, 30); + panelGray.TabIndex = 5; + panelGray.MouseDown += panelColor_MouseDown; + // + // panelGreen + // + panelGreen.BackColor = Color.FromArgb(0, 192, 0); + panelGreen.Location = new Point(57, 22); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(35, 30); + panelGreen.TabIndex = 1; + panelGreen.MouseDown += panelColor_MouseDown; + // + // panelWhite + // + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(16, 63); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(35, 30); + panelWhite.TabIndex = 4; + panelWhite.MouseDown += panelColor_MouseDown; + // + // panelRed + // + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(16, 22); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(35, 30); + panelRed.TabIndex = 0; + panelRed.MouseDown += panelColor_MouseDown; + // + // checkBoxWing + // + checkBoxWing.AutoSize = true; + checkBoxWing.Location = new Point(10, 154); + checkBoxWing.Name = "checkBoxWing"; + checkBoxWing.Size = new Size(199, 19); + checkBoxWing.TabIndex = 5; + checkBoxWing.Text = "Признак наличия доп. крыльев"; + checkBoxWing.UseVisualStyleBackColor = true; + // + // checkBoxRocket + // + checkBoxRocket.AutoSize = true; + checkBoxRocket.Location = new Point(10, 119); + checkBoxRocket.Name = "checkBoxRocket"; + checkBoxRocket.Size = new Size(156, 19); + checkBoxRocket.TabIndex = 4; + checkBoxRocket.Text = "Признак наличия ракет"; + checkBoxRocket.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(76, 60); + numericUpDownWeight.Name = "numericUpDownWeight"; + numericUpDownWeight.Size = new Size(73, 23); + numericUpDownWeight.TabIndex = 3; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(76, 31); + numericUpDownSpeed.Name = "numericUpDownSpeed"; + numericUpDownSpeed.Size = new Size(73, 23); + numericUpDownSpeed.TabIndex = 2; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(10, 62); + label2.Name = "label2"; + label2.Size = new Size(29, 15); + label2.TabIndex = 1; + label2.Text = "Вес:"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(10, 33); + label1.Name = "label1"; + label1.Size = new Size(62, 15); + label1.TabIndex = 0; + label1.Text = "Скорость:"; + // + // panelColor + // + panelColor.AllowDrop = true; + panelColor.Controls.Add(labelDopColor); + panelColor.Controls.Add(labelBaseColor); + panelColor.Controls.Add(pictureBoxObject); + panelColor.Location = new Point(472, 12); + panelColor.Name = "panelColor"; + panelColor.Size = new Size(276, 257); + panelColor.TabIndex = 1; + panelColor.DragDrop += PanelObject_DragDrop; + panelColor.DragEnter += PanelObject_DragEnter; + // + // labelDopColor + // + labelDopColor.AllowDrop = true; + labelDopColor.BorderStyle = BorderStyle.FixedSingle; + labelDopColor.Location = new Point(164, 10); + labelDopColor.Name = "labelDopColor"; + labelDopColor.Size = new Size(100, 29); + labelDopColor.TabIndex = 2; + labelDopColor.Text = "Доп. цвет"; + labelDopColor.TextAlign = ContentAlignment.MiddleCenter; + labelDopColor.DragDrop += LabelDopColor_DragDrop; + labelDopColor.DragEnter += LabelColor_DragEnter; + labelDopColor.MouseDown += LabelObject_MouseDown; + // + // labelBaseColor + // + labelBaseColor.AllowDrop = true; + labelBaseColor.BorderStyle = BorderStyle.FixedSingle; + labelBaseColor.Location = new Point(12, 10); + labelBaseColor.Name = "labelBaseColor"; + labelBaseColor.Size = new Size(100, 29); + labelBaseColor.TabIndex = 2; + labelBaseColor.Text = "Цвет"; + labelBaseColor.TextAlign = ContentAlignment.MiddleCenter; + labelBaseColor.DragDrop += LabelBaseColor_DragDrop; + labelBaseColor.DragEnter += LabelColor_DragEnter; + labelBaseColor.MouseDown += LabelObject_MouseDown; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(12, 46); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(252, 182); + pictureBoxObject.TabIndex = 0; + pictureBoxObject.TabStop = false; + // + // ButtonOk + // + ButtonOk.Location = new Point(484, 275); + ButtonOk.Name = "ButtonOk"; + ButtonOk.Size = new Size(100, 32); + ButtonOk.TabIndex = 2; + ButtonOk.Text = "Добавить"; + ButtonOk.UseVisualStyleBackColor = true; + ButtonOk.Click += ButtonOk_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(636, 275); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(100, 32); + buttonCancel.TabIndex = 3; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // FormFighterConfig + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 388); + Controls.Add(buttonCancel); + Controls.Add(ButtonOk); + Controls.Add(panelColor); + Controls.Add(groupBox1); + Name = "FormFighterConfig"; + Text = "FormFighterConfig"; + + groupBox1.ResumeLayout(false); + groupBox1.PerformLayout(); + groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + panelColor.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + ResumeLayout(false); + } + + #endregion + private GroupBox groupBox1; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label label2; + private Label label1; + private GroupBox groupBox2; + private CheckBox checkBoxWing; + private CheckBox checkBoxRocket; + private Panel panelPurple; + private Panel panelYellow; + private Panel panelBlack; + private Panel panelBlue; + private Panel panelGray; + private Panel panelGreen; + private Panel panelWhite; + private Panel panelRed; + private Label labelSimpleObject; + private Label labelModifiedObject; + private Panel panelColor; + private PictureBox pictureBoxObject; + private Label labelDopColor; + private Label labelBaseColor; + private Button ButtonOk; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/AirFighter/AirFighter/FormAirFighterConfig.cs b/AirFighter/AirFighter/FormAirFighterConfig.cs new file mode 100644 index 0000000..42271ab --- /dev/null +++ b/AirFighter/AirFighter/FormAirFighterConfig.cs @@ -0,0 +1,180 @@ + +using AirFighter.Drawnings; +using AirFighter.Entities; +using AirFighter; +using AirFighter.DrawningObjects; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar; + +namespace AirFighter +{ + /// + /// Форма создания объекта + /// + public partial class FormAirFighterConfig : Form + { + /// + /// Переменная-выбранная установка + /// + DrawningAirFighter? _fighter = null; + /// + /// Событие + /// + private event Action EventAddAirFighter; + /// + /// Конструктор + /// + public FormAirFighterConfig() + { + InitializeComponent(); + panelBlack.MouseDown += panelColor_MouseDown; + panelPurple.MouseDown += panelColor_MouseDown; + panelGray.MouseDown += panelColor_MouseDown; + panelGreen.MouseDown += panelColor_MouseDown; + panelRed.MouseDown += panelColor_MouseDown; + panelWhite.MouseDown += panelColor_MouseDown; + panelYellow.MouseDown += panelColor_MouseDown; + panelBlue.MouseDown += panelColor_MouseDown; + // TODO buttonCancel.Click with lambda + buttonCancel.Click += (sender, e) => Close(); + } + /// + /// Отрисовать установку + /// + private void DrawAirFighter() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _fighter?.SetPosition(5, 5); + _fighter?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + /// + /// Добавление события + /// + /// Привязанный метод + public void AddEvent(Action ev) + { + if (EventAddAirFighter == null) + { + EventAddAirFighter = new Action(ev); + } + else + { + EventAddAirFighter += 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) ?? false) + { + 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": + _fighter = new DrawningAirFighter((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, + pictureBoxObject.Height); + break; + case "labelModifiedObject": + _fighter = new DrawningAirFighterMilitary((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxWing.Checked, + checkBoxRocket.Checked, pictureBoxObject.Width, pictureBoxObject.Height); + break; + } + DrawAirFighter(); + } + + /// + /// Отправляем цвет с панели + /// + /// + /// + private void panelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + // TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта) + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + if (_fighter != null) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + _fighter.EntityAirFighter.BodyColor = (Color)e.Data.GetData(typeof(Color)); + + } + DrawAirFighter(); + } + } + + private void LabelColor_DragEnter(object sender, DragEventArgs e) + { + if (_fighter != null && _fighter.EntityAirFighter is EntityAirFighterMilitary entityustabat) + { + labelDopColor.AllowDrop = true; + } + else + labelDopColor.AllowDrop = false; + + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void LabelDopColor_DragDrop(object sender, DragEventArgs e) + { + if (_fighter != null && _fighter.EntityAirFighter is EntityAirFighterMilitary entityAirFighterMilitary) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + entityAirFighterMilitary.AdditionalColor = (Color)e.Data.GetData(typeof(Color)); + + } + DrawAirFighter(); + } + } + /// + /// Добавление установки + /// + /// + /// + private void ButtonOk_Click(object sender, EventArgs e) + { + EventAddAirFighter?.Invoke(_fighter); + Close(); + } + } + +} \ No newline at end of file diff --git a/AirFighter/AirFighter/FormAirFighterConfig.resx b/AirFighter/AirFighter/FormAirFighterConfig.resx new file mode 100644 index 0000000..a395bff --- /dev/null +++ b/AirFighter/AirFighter/FormAirFighterConfig.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 diff --git a/AirFighter/AirFighter/IMoveableObject.cs b/AirFighter/AirFighter/IMoveableObject.cs index 777a662..ff1522a 100644 --- a/AirFighter/AirFighter/IMoveableObject.cs +++ b/AirFighter/AirFighter/IMoveableObject.cs @@ -14,7 +14,6 @@ namespace AirFighter.MovementStrategy int GetStep { get; } bool CheckCanMove(DirectionAirFighter direction); void MoveObject(DirectionAirFighter direction); - void SetPosition(int x, int y); - void Draw(Graphics g); + } } diff --git a/AirFighter/AirFighter/IMoveableObject_Realise.cs b/AirFighter/AirFighter/IMoveableObject_Realise.cs index 3f5238c..d2e1ede 100644 --- a/AirFighter/AirFighter/IMoveableObject_Realise.cs +++ b/AirFighter/AirFighter/IMoveableObject_Realise.cs @@ -33,19 +33,5 @@ namespace AirFighter.MovementStrategy _drawningAirFighter?.CanMove(direction) ?? false; public void MoveObject(DirectionAirFighter direction) => _drawningAirFighter?.MoveTransport(direction); - public void SetPosition(int x, int y) - { - if (_drawningAirFighter != null) - { - _drawningAirFighter.SetPosition(x, y); - } - } - public void Draw(Graphics g) - { - if (_drawningAirFighter != null) - { - _drawningAirFighter.DrawTransport(g); - } - } } } diff --git a/AirFighter/AirFighter/SetGeneric.cs b/AirFighter/AirFighter/SetGeneric.cs index 318e7f5..d3b6d5e 100644 --- a/AirFighter/AirFighter/SetGeneric.cs +++ b/AirFighter/AirFighter/SetGeneric.cs @@ -16,16 +16,10 @@ return Insert(fighter, 0); } - private bool isCorrectPosition(int position) - { - return 0 <= position && position < _maxCount; - } public int Insert(T fighter, int position) { - if (!isCorrectPosition(position)) - { + if (position < 0 || position > Count || Count >= _maxCount) return -1; - } _places.Insert(position, fighter); return position; }