From 6aa194ce4a7395a7213e32417952de8a9aeec3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D1=80=D1=8C=D1=8F=20=D0=90=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0?= Date: Fri, 16 Dec 2022 23:34:48 +0400 Subject: [PATCH] Add config form --- AirBomber/AirBomber/DrawningJet.cs | 2 +- AirBomber/AirBomber/DrawningSportJet.cs | 4 +- AirBomber/AirBomber/EntityJet.cs | 2 +- AirBomber/AirBomber/EntitySportJet.cs | 14 +- AirBomber/AirBomber/FormJetConfig.Designer.cs | 373 ++++++++++++++++++ AirBomber/AirBomber/FormJetConfig.cs | 189 +++++++++ .../{FormMap.resx => FormJetConfig.resx} | 3 - AirBomber/AirBomber/FormMap.Designer.cs | 221 ----------- AirBomber/AirBomber/FormMap.cs | 91 ----- 9 files changed, 572 insertions(+), 327 deletions(-) create mode 100644 AirBomber/AirBomber/FormJetConfig.Designer.cs create mode 100644 AirBomber/AirBomber/FormJetConfig.cs rename AirBomber/AirBomber/{FormMap.resx => FormJetConfig.resx} (93%) delete mode 100644 AirBomber/AirBomber/FormMap.Designer.cs delete mode 100644 AirBomber/AirBomber/FormMap.cs diff --git a/AirBomber/AirBomber/DrawningJet.cs b/AirBomber/AirBomber/DrawningJet.cs index 5e5bcb5..0ab7533 100644 --- a/AirBomber/AirBomber/DrawningJet.cs +++ b/AirBomber/AirBomber/DrawningJet.cs @@ -14,7 +14,7 @@ namespace AirBomber /// /// Класс-сущность /// - public EntityJet Jet { get; protected set; } + public EntityJet Jet { get; set; } /// /// Левая координата отрисовки самолета /// diff --git a/AirBomber/AirBomber/DrawningSportJet.cs b/AirBomber/AirBomber/DrawningSportJet.cs index 840e102..cbfac38 100644 --- a/AirBomber/AirBomber/DrawningSportJet.cs +++ b/AirBomber/AirBomber/DrawningSportJet.cs @@ -19,10 +19,10 @@ namespace AirBomber /// Признак наличия обвеса /// Признак наличия антикрыла /// - public DrawningSportJet(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) : + public DrawningSportJet(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing) : base(speed, weight, bodyColor, 110, 60) { - Jet = new EntitySportJet(speed, weight, bodyColor, dopColor, bodyKit, wing, sportLine); + Jet = new EntitySportJet(speed, weight, bodyColor, dopColor, bodyKit, wing); } public override void DrawTransport(Graphics g) diff --git a/AirBomber/AirBomber/EntityJet.cs b/AirBomber/AirBomber/EntityJet.cs index ebbac82..737405d 100644 --- a/AirBomber/AirBomber/EntityJet.cs +++ b/AirBomber/AirBomber/EntityJet.cs @@ -19,7 +19,7 @@ namespace AirBomber /// /// Цвет /// - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } /// /// Шаг перемещения самолета /// diff --git a/AirBomber/AirBomber/EntitySportJet.cs b/AirBomber/AirBomber/EntitySportJet.cs index 6127a16..bccba1f 100644 --- a/AirBomber/AirBomber/EntitySportJet.cs +++ b/AirBomber/AirBomber/EntitySportJet.cs @@ -11,7 +11,7 @@ namespace AirBomber /// ///Класс-сущность "Спортивный автомобиль" /// - public Color DopColor { get; private set; } + public Color DopColor { get; set; } /// /// Признак наличия обвеса /// @@ -28,19 +28,17 @@ namespace AirBomber /// Инициализация свойств /// /// Скорость - /// Вес автомобиля - /// Цвет кузова + /// Вес + /// Цвет /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы - public EntitySportJet(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) : + /// Признак наличия топливных баков + /// Признак наличия бомб + public EntitySportJet(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing) : base(speed, weight, bodyColor) { DopColor = dopColor; BodyKit = bodyKit; Wing = wing; - SportLine = sportLine; } } } diff --git a/AirBomber/AirBomber/FormJetConfig.Designer.cs b/AirBomber/AirBomber/FormJetConfig.Designer.cs new file mode 100644 index 0000000..48f60cf --- /dev/null +++ b/AirBomber/AirBomber/FormJetConfig.Designer.cs @@ -0,0 +1,373 @@ +namespace AirBomber +{ + partial class FormJetConfig + { + /// + /// 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.groupBox1 = new System.Windows.Forms.GroupBox(); + this.labelModifiedObject = new System.Windows.Forms.Label(); + this.labelSimpleObject = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelGray = new System.Windows.Forms.Panel(); + this.panelWhite = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.checkBoxWing = new System.Windows.Forms.CheckBox(); + this.checkBoxBodyKit = new System.Windows.Forms.CheckBox(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.LabelDopColor = new System.Windows.Forms.Label(); + this.LabelBaseColor = new System.Windows.Forms.Label(); + this.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.labelModifiedObject); + this.groupBox1.Controls.Add(this.labelSimpleObject); + this.groupBox1.Controls.Add(this.groupBox2); + this.groupBox1.Controls.Add(this.checkBoxWing); + this.groupBox1.Controls.Add(this.checkBoxBodyKit); + this.groupBox1.Controls.Add(this.numericUpDownWeight); + this.groupBox1.Controls.Add(this.numericUpDownSpeed); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(454, 197); + this.groupBox1.TabIndex = 1; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "groupBox1"; + // + // labelModifiedObject + // + this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelModifiedObject.Location = new System.Drawing.Point(353, 156); + this.labelModifiedObject.Name = "labelModifiedObject"; + this.labelModifiedObject.Size = new System.Drawing.Size(88, 27); + this.labelModifiedObject.TabIndex = 9; + this.labelModifiedObject.Text = "Продвинутый"; + this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // labelSimpleObject + // + this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelSimpleObject.Location = new System.Drawing.Point(244, 156); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(92, 27); + this.labelSimpleObject.TabIndex = 8; + this.labelSimpleObject.Text = "Простой"; + this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.panelPurple); + this.groupBox2.Controls.Add(this.panelBlack); + this.groupBox2.Controls.Add(this.panelGray); + this.groupBox2.Controls.Add(this.panelWhite); + this.groupBox2.Controls.Add(this.panelYellow); + this.groupBox2.Controls.Add(this.panelBlue); + this.groupBox2.Controls.Add(this.panelGreen); + this.groupBox2.Controls.Add(this.panelRed); + this.groupBox2.Location = new System.Drawing.Point(244, 22); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(197, 115); + this.groupBox2.TabIndex = 7; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Цвета"; + // + // panelPurple + // + this.panelPurple.BackColor = System.Drawing.Color.Purple; + this.panelPurple.Location = new System.Drawing.Point(144, 66); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(40, 40); + this.panelPurple.TabIndex = 7; + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(98, 66); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(40, 40); + this.panelBlack.TabIndex = 6; + // + // panelGray + // + this.panelGray.BackColor = System.Drawing.Color.Silver; + this.panelGray.Location = new System.Drawing.Point(52, 66); + this.panelGray.Name = "panelGray"; + this.panelGray.Size = new System.Drawing.Size(40, 40); + this.panelGray.TabIndex = 5; + // + // panelWhite + // + this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.Location = new System.Drawing.Point(6, 66); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(40, 40); + this.panelWhite.TabIndex = 4; + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(144, 20); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(40, 40); + this.panelYellow.TabIndex = 3; + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(98, 20); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(40, 40); + this.panelBlue.TabIndex = 2; + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.Green; + this.panelGreen.Location = new System.Drawing.Point(52, 20); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(40, 40); + this.panelGreen.TabIndex = 1; + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(6, 20); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(40, 40); + this.panelRed.TabIndex = 0; + // + // checkBoxWing + // + this.checkBoxWing.AutoSize = true; + this.checkBoxWing.Location = new System.Drawing.Point(12, 125); + this.checkBoxWing.Name = "checkBoxWing"; + this.checkBoxWing.Size = new System.Drawing.Size(156, 19); + this.checkBoxWing.TabIndex = 5; + this.checkBoxWing.Text = "Признак наличия бомб"; + this.checkBoxWing.UseVisualStyleBackColor = true; + // + // checkBoxBodyKit + // + this.checkBoxBodyKit.AutoSize = true; + this.checkBoxBodyKit.Location = new System.Drawing.Point(12, 97); + this.checkBoxBodyKit.Name = "checkBoxBodyKit"; + this.checkBoxBodyKit.Size = new System.Drawing.Size(222, 19); + this.checkBoxBodyKit.TabIndex = 4; + this.checkBoxBodyKit.Text = "Признак наличия топливных баков"; + this.checkBoxBodyKit.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(81, 59); + this.numericUpDownWeight.Maximum = new decimal(new int[] { + 2000, + 0, + 0, + 0}); + this.numericUpDownWeight.Minimum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(74, 23); + this.numericUpDownWeight.TabIndex = 3; + this.numericUpDownWeight.Value = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(81, 30); + this.numericUpDownSpeed.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownSpeed.Minimum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; + this.numericUpDownSpeed.Size = new System.Drawing.Size(74, 23); + this.numericUpDownSpeed.TabIndex = 2; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(49, 61); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(26, 15); + this.label2.TabIndex = 1; + this.label2.Text = "Вес"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(16, 32); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(59, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Скорость"; + // + // panel1 + // + this.panel1.AllowDrop = true; + this.panel1.Controls.Add(this.LabelDopColor); + this.panel1.Controls.Add(this.LabelBaseColor); + this.panel1.Controls.Add(this.pictureBoxObject); + this.panel1.Location = new System.Drawing.Point(472, 12); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(296, 242); + this.panel1.TabIndex = 2; + // + // LabelDopColor + // + this.LabelDopColor.AllowDrop = true; + this.LabelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.LabelDopColor.Location = new System.Drawing.Point(168, 15); + this.LabelDopColor.Name = "LabelDopColor"; + this.LabelDopColor.Size = new System.Drawing.Size(100, 23); + this.LabelDopColor.TabIndex = 2; + this.LabelDopColor.Text = "Доп. цвет"; + this.LabelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // LabelBaseColor + // + this.LabelBaseColor.AllowDrop = true; + this.LabelBaseColor.BackColor = System.Drawing.SystemColors.Control; + this.LabelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.LabelBaseColor.Location = new System.Drawing.Point(24, 15); + this.LabelBaseColor.Name = "LabelBaseColor"; + this.LabelBaseColor.Size = new System.Drawing.Size(100, 23); + this.LabelBaseColor.TabIndex = 1; + this.LabelBaseColor.Text = "Цвет"; + this.LabelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // pictureBoxObject + // + this.pictureBoxObject.Location = new System.Drawing.Point(3, 47); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(290, 192); + this.pictureBoxObject.TabIndex = 0; + this.pictureBoxObject.TabStop = false; + // + // buttonOk + // + this.buttonOk.Location = new System.Drawing.Point(256, 231); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 3; + this.buttonOk.Text = "Добавить"; + this.buttonOk.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(365, 231); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FormJetConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 269); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.panel1); + this.Controls.Add(this.groupBox1); + this.Name = "FormJetConfig"; + this.Text = "Создание объекта"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBox1; + private Label labelModifiedObject; + private Label labelSimpleObject; + private GroupBox groupBox2; + private Panel panelPurple; + private Panel panelBlack; + private Panel panelGray; + private Panel panelWhite; + private Panel panelYellow; + private Panel panelBlue; + private Panel panelGreen; + private Panel panelRed; + private CheckBox checkBoxWing; + private CheckBox checkBoxBodyKit; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label label2; + private Label label1; + private Panel panel1; + private Label LabelDopColor; + private Label LabelBaseColor; + private PictureBox pictureBoxObject; + private Button buttonOk; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormJetConfig.cs b/AirBomber/AirBomber/FormJetConfig.cs new file mode 100644 index 0000000..1b393df --- /dev/null +++ b/AirBomber/AirBomber/FormJetConfig.cs @@ -0,0 +1,189 @@ +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 AirBomber +{ + public partial class FormJetConfig : Form + { + /// + /// Делегат для передачи объекта-самолета + /// + /// + public delegate void JetDelegate(DrawningJet jet); + + // Создаем событие и оно должно быть публичным, чтобы его можно было использовать в разных классах + // например в главной форме, которая вызывает форму добавления самолета + public event JetDelegate EventAddJet; + + + /// + /// Переменная - выбранный самолет + /// + private DrawningJet _jet = null; + /// + /// Конструктор + /// + public FormJetConfig() + { + 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; + // Используем лямбда функцию для закрытия окна при нажатии на кнопку Отмена + // при этом используем встроенные делегат EventHandler + buttonCancel.Click += (object sender, EventArgs e) => this.Close(); + } + /// + /// Добавление самолета + /// + /// + /// + private void ButtonOk_Click(object sender, EventArgs e) + { + // Генерируем событие + EventAddJet?.Invoke(_jet); + Close(); + } + + /// + /// Отрисовка самолета + /// + private void DrawJet() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _jet?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height); + _jet?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + /// + /// Передаем информацию при нажатии на 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": + _jet = new DrawningJet((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _jet = new DrawningSportJet((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, + checkBoxBodyKit.Checked, checkBoxWing.Checked); + break; + } + DrawJet(); + } + + /// + /// Отправляем цвет с панели + /// + /// + /// + 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)) && _jet != null) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + /// + /// Проверка получаемой информации (ее типа на соответствие требуемому) + /// + /// + /// + private void LabelDopColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color)) && _jet?.ToString() == "JetsProject.DrawningSportJet") + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + /// + /// Принимаем основной цвет + /// + /// + /// + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + var color = e.Data.GetData(typeof(Color)); + if (color != null && _jet != null) + { + _jet.Jet.BodyColor = (Color)color; + DrawJet(); + } + } + /// + /// Принимаем дополнительный цвет + /// + /// + /// + private void LabelDopColor_DragDrop(object sender, DragEventArgs e) + { + if (_jet != null && _jet.Jet is EntitySportJet entityJet) + { + entityJet.DopColor = (Color)e.Data.GetData(typeof(Color)); + DrawJet(); + } + } + } +} diff --git a/AirBomber/AirBomber/FormMap.resx b/AirBomber/AirBomber/FormJetConfig.resx similarity index 93% rename from AirBomber/AirBomber/FormMap.resx rename to AirBomber/AirBomber/FormJetConfig.resx index 5cb320f..f298a7b 100644 --- a/AirBomber/AirBomber/FormMap.resx +++ b/AirBomber/AirBomber/FormJetConfig.resx @@ -57,7 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMap.Designer.cs b/AirBomber/AirBomber/FormMap.Designer.cs deleted file mode 100644 index fd3c104..0000000 --- a/AirBomber/AirBomber/FormMap.Designer.cs +++ /dev/null @@ -1,221 +0,0 @@ -namespace AirBomber -{ - partial class FormMap - { - /// - /// 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.pictureBoxJet = new System.Windows.Forms.PictureBox(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); - this.buttonCreate = new System.Windows.Forms.Button(); - this.buttonUp = new System.Windows.Forms.Button(); - this.buttonLeft = new System.Windows.Forms.Button(); - this.buttonRight = new System.Windows.Forms.Button(); - this.buttonDown = new System.Windows.Forms.Button(); - this.buttonCreateModif = new System.Windows.Forms.Button(); - this.comboBoxCelectorMap1 = new System.Windows.Forms.ComboBox(); - this.ButtonSelectJet = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit(); - this.statusStrip1.SuspendLayout(); - this.SuspendLayout(); - // - // pictureBoxJet - // - this.pictureBoxJet.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxJet.Location = new System.Drawing.Point(0, 0); - this.pictureBoxJet.Name = "pictureBoxJet"; - this.pictureBoxJet.Size = new System.Drawing.Size(800, 450); - this.pictureBoxJet.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxJet.TabIndex = 0; - this.pictureBoxJet.TabStop = false; - // - // statusStrip1 - // - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabelSpeed, - this.toolStripStatusLabelWeight, - this.toolStripStatusLabelBodyColor}); - this.statusStrip1.Location = new System.Drawing.Point(0, 428); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(800, 22); - this.statusStrip1.TabIndex = 1; - this.statusStrip1.Text = "statusStrip1"; - // - // toolStripStatusLabelSpeed - // - this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; - this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17); - this.toolStripStatusLabelSpeed.Text = "Скорость:"; - // - // toolStripStatusLabelWeight - // - this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; - this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17); - this.toolStripStatusLabelWeight.Text = "Вес:"; - // - // toolStripStatusLabelBodyColor - // - this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; - this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17); - this.toolStripStatusLabelBodyColor.Text = "Цвет:"; - // - // buttonCreate - // - this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreate.Location = new System.Drawing.Point(12, 402); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(75, 23); - this.buttonCreate.TabIndex = 2; - this.buttonCreate.Text = "Создать"; - this.buttonCreate.UseVisualStyleBackColor = true; - this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click); - // - // buttonUp - // - this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUp.BackgroundImage = global::AirBomber.Properties.Resources.arrowUp; - this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(702, 331); - this.buttonUp.Name = "buttonUp"; - this.buttonUp.Size = new System.Drawing.Size(40, 40); - this.buttonUp.TabIndex = 3; - this.buttonUp.UseVisualStyleBackColor = true; - this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonLeft - // - this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonLeft.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft; - this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(656, 377); - this.buttonLeft.Name = "buttonLeft"; - this.buttonLeft.Size = new System.Drawing.Size(40, 40); - this.buttonLeft.TabIndex = 4; - this.buttonLeft.UseVisualStyleBackColor = true; - this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonRight - // - this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRight.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight; - this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(748, 377); - this.buttonRight.Name = "buttonRight"; - this.buttonRight.Size = new System.Drawing.Size(40, 40); - this.buttonRight.TabIndex = 5; - this.buttonRight.UseVisualStyleBackColor = true; - this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonDown - // - this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::AirBomber.Properties.Resources.arrowDown; - this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(702, 377); - this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(40, 40); - this.buttonDown.TabIndex = 6; - this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonCreateModif - // - this.buttonCreateModif.Location = new System.Drawing.Point(93, 402); - this.buttonCreateModif.Name = "buttonCreateModif"; - this.buttonCreateModif.Size = new System.Drawing.Size(107, 23); - this.buttonCreateModif.TabIndex = 7; - this.buttonCreateModif.Text = "Модификация"; - this.buttonCreateModif.UseVisualStyleBackColor = true; - this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click); - // - // comboBoxCelectorMap1 - // - this.comboBoxCelectorMap1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxCelectorMap1.FormattingEnabled = true; - this.comboBoxCelectorMap1.Items.AddRange(new object[] { - "Простоя карта", - "Небо"}); - this.comboBoxCelectorMap1.Location = new System.Drawing.Point(12, 12); - this.comboBoxCelectorMap1.Name = "comboBoxCelectorMap1"; - this.comboBoxCelectorMap1.Size = new System.Drawing.Size(121, 23); - this.comboBoxCelectorMap1.TabIndex = 8; - this.comboBoxCelectorMap1.SelectedIndexChanged += new System.EventHandler(this.comboBoxCelectorMap1_SelectedIndexChanged); - // - // ButtonSelectJet - // - this.ButtonSelectJet.Location = new System.Drawing.Point(559, 394); - this.ButtonSelectJet.Name = "ButtonSelectJet"; - this.ButtonSelectJet.Size = new System.Drawing.Size(75, 23); - this.ButtonSelectJet.TabIndex = 9; - this.ButtonSelectJet.Text = "Выбрать"; - this.ButtonSelectJet.UseVisualStyleBackColor = true; - //this.ButtonSelectJet.Click += new System.EventHandler(this.ButtonSelectJet_Click); - // - // FormMap - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.ButtonSelectJet); - this.Controls.Add(this.comboBoxCelectorMap1); - this.Controls.Add(this.buttonCreateModif); - this.Controls.Add(this.buttonDown); - this.Controls.Add(this.buttonRight); - this.Controls.Add(this.buttonLeft); - this.Controls.Add(this.buttonUp); - this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.pictureBoxJet); - this.Name = "FormMap"; - this.Text = "FormMap"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).EndInit(); - this.statusStrip1.ResumeLayout(false); - this.statusStrip1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private PictureBox pictureBoxJet; - private StatusStrip statusStrip1; - private ToolStripStatusLabel toolStripStatusLabelSpeed; - private ToolStripStatusLabel toolStripStatusLabelWeight; - private ToolStripStatusLabel toolStripStatusLabelBodyColor; - private Button buttonCreate; - private Button buttonUp; - private Button buttonLeft; - private Button buttonRight; - private Button buttonDown; - private Button buttonCreateModif; - private ComboBox comboBoxCelectorMap1; - private Button ButtonSelectJet; - } -} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMap.cs b/AirBomber/AirBomber/FormMap.cs deleted file mode 100644 index f038f44..0000000 --- a/AirBomber/AirBomber/FormMap.cs +++ /dev/null @@ -1,91 +0,0 @@ -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 AirBomber -{ - public partial class FormMap : Form - { - private AbstractMap _abstractMap; - public FormMap() - { - InitializeComponent(); - _abstractMap = new SimpleMap(); - } - /// - /// Заполнение информации по объекту - /// - private void SetData(DrawningJet jet) - { - toolStripStatusLabelSpeed.Text = $"Скорость: {jet.Jet.Speed}"; - toolStripStatusLabelWeight.Text = $"Вес: {jet.Jet.Weight}"; - toolStripStatusLabelBodyColor.Text = $"Цвет: {jet.Jet.BodyColor.Name}"; - pictureBoxJet.Image = _abstractMap.CreateMap(pictureBoxJet.Width, pictureBoxJet.Height, new DrawningObjectJet(jet)); - } - /// - /// Обработка нажатия кнопки "Создать" - /// - /// - /// - private void buttonCreate_Click(object sender, EventArgs e) - { - Random rnd = new Random(); - var jet = new DrawningJet(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - SetData(jet); - } - private void ButtonMove_Click(object sender, EventArgs e) - { - //получаем имя кнопки - string name = ((Button)sender)?.Name ?? string.Empty; - Direction dir = Direction.None; - switch (name) - { - case "buttonUp": - dir = Direction.Up; - break; - case "buttonDown": - dir = Direction.Down; - break; - case "buttonLeft": - dir = Direction.Left; - break; - case "buttonRight": - dir = Direction.Right; - break; - } - pictureBoxJet.Image = _abstractMap?.MoveObject(dir); - } - private void buttonCreateModif_Click(object sender, EventArgs e) - { - Random rnd = new Random(); - var jet = new DrawningSportJet(rnd.Next(100, 300), rnd.Next(1000, 2000), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); - SetData(jet); - } - /// - /// Смена карты - /// - /// - /// - private void comboBoxCelectorMap1_SelectedIndexChanged(object sender, EventArgs e) - { - switch (comboBoxCelectorMap1.Text) - { - case "Простая карта": - _abstractMap = new SimpleMap(); - break; - case "Небо": - _abstractMap = new SkyMap(); - break; - } - } - } -}