From b82e72038d369f07fb78f15f96b0a5fd632d2cbb Mon Sep 17 00:00:00 2001 From: foxkerik6 Date: Tue, 29 Nov 2022 01:40:38 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Stormtrooper/EntityMilitaryAirplane.cs | 2 +- .../Stormtrooper/EntityStormtrooper.cs | 8 +- .../Stormtrooper/FormAirConfig.Designer.cs | 397 ++++++++++++++++++ Stormtrooper/Stormtrooper/FormAirConfig.cs | 122 ++++++ Stormtrooper/Stormtrooper/FormAirConfig.resx | 60 +++ Stormtrooper/Stormtrooper/Program.cs | 2 +- 6 files changed, 585 insertions(+), 6 deletions(-) create mode 100644 Stormtrooper/Stormtrooper/FormAirConfig.Designer.cs create mode 100644 Stormtrooper/Stormtrooper/FormAirConfig.cs create mode 100644 Stormtrooper/Stormtrooper/FormAirConfig.resx diff --git a/Stormtrooper/Stormtrooper/EntityMilitaryAirplane.cs b/Stormtrooper/Stormtrooper/EntityMilitaryAirplane.cs index e406587..f70a361 100644 --- a/Stormtrooper/Stormtrooper/EntityMilitaryAirplane.cs +++ b/Stormtrooper/Stormtrooper/EntityMilitaryAirplane.cs @@ -10,7 +10,7 @@ namespace Stormtrooper { public int Speed { get; private set; } public int Weight { get; private set; } - public Color Color { get; private set; } + public Color Color { get; set; } public float Step => Speed * 25 / Weight; diff --git a/Stormtrooper/Stormtrooper/EntityStormtrooper.cs b/Stormtrooper/Stormtrooper/EntityStormtrooper.cs index 44c6b41..4018e35 100644 --- a/Stormtrooper/Stormtrooper/EntityStormtrooper.cs +++ b/Stormtrooper/Stormtrooper/EntityStormtrooper.cs @@ -11,19 +11,19 @@ namespace Stormtrooper /// /// Доп цвет /// - public Color AdvColor { get;private set; } + public Color AdvColor { get; set; } /// /// Наличие рокет /// - public bool Rockets { get; private set; } + public bool Rockets { get; set; } /// /// Наличие ускорителей /// - public bool Booster { get; private set; } + public bool Booster { get; set; } /// /// Наличие радара /// - public bool Radar { get; private set; } + public bool Radar { get; set; } public EntityStormtrooper(int speed, int weight, Color color, Color advColor, bool rockets, bool boosters, bool radar) : base(speed, weight, color) diff --git a/Stormtrooper/Stormtrooper/FormAirConfig.Designer.cs b/Stormtrooper/Stormtrooper/FormAirConfig.Designer.cs new file mode 100644 index 0000000..a825a9b --- /dev/null +++ b/Stormtrooper/Stormtrooper/FormAirConfig.Designer.cs @@ -0,0 +1,397 @@ +namespace Stormtrooper +{ + partial class FormAirConfig + { + /// + /// 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.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.labelAdvanced = new System.Windows.Forms.Label(); + this.labelSimple = new System.Windows.Forms.Label(); + this.groupBoxColor = new System.Windows.Forms.GroupBox(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelCyan = new System.Windows.Forms.Panel(); + this.panelPink = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.checkBoxBoosters = new System.Windows.Forms.CheckBox(); + this.checkBoxRocket = new System.Windows.Forms.CheckBox(); + this.checkBoxRadar = new System.Windows.Forms.CheckBox(); + this.labelWeight = new System.Windows.Forms.Label(); + this.labelSpeed = new System.Windows.Forms.Label(); + this.pictureBoxShow = new System.Windows.Forms.PictureBox(); + this.panelShow = new System.Windows.Forms.Panel(); + this.labelAdvancedColor = new System.Windows.Forms.Label(); + this.labelColor = new System.Windows.Forms.Label(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxConfig.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + this.groupBoxColor.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxShow)).BeginInit(); + this.panelShow.SuspendLayout(); + this.SuspendLayout(); + // + // groupBoxConfig + // + this.groupBoxConfig.Controls.Add(this.numericUpDownWeight); + this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed); + this.groupBoxConfig.Controls.Add(this.labelAdvanced); + this.groupBoxConfig.Controls.Add(this.labelSimple); + this.groupBoxConfig.Controls.Add(this.groupBoxColor); + this.groupBoxConfig.Controls.Add(this.checkBoxBoosters); + this.groupBoxConfig.Controls.Add(this.checkBoxRocket); + this.groupBoxConfig.Controls.Add(this.checkBoxRadar); + this.groupBoxConfig.Controls.Add(this.labelWeight); + this.groupBoxConfig.Controls.Add(this.labelSpeed); + this.groupBoxConfig.Location = new System.Drawing.Point(12, 12); + this.groupBoxConfig.Name = "groupBoxConfig"; + this.groupBoxConfig.Size = new System.Drawing.Size(590, 357); + this.groupBoxConfig.TabIndex = 0; + this.groupBoxConfig.TabStop = false; + this.groupBoxConfig.Text = "Параметры"; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(95, 78); + this.numericUpDownWeight.Maximum = new decimal(new int[] { + 250, + 0, + 0, + 0}); + this.numericUpDownWeight.Minimum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(62, 23); + this.numericUpDownWeight.TabIndex = 11; + this.numericUpDownWeight.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(95, 42); + this.numericUpDownSpeed.Maximum = new decimal(new int[] { + 2500, + 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(62, 23); + this.numericUpDownSpeed.TabIndex = 10; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelAdvanced + // + this.labelAdvanced.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelAdvanced.Location = new System.Drawing.Point(410, 192); + this.labelAdvanced.Name = "labelAdvanced"; + this.labelAdvanced.Size = new System.Drawing.Size(115, 32); + this.labelAdvanced.TabIndex = 9; + this.labelAdvanced.Text = "Продвинутый"; + this.labelAdvanced.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelAdvanced.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown); + // + // labelSimple + // + this.labelSimple.AllowDrop = true; + this.labelSimple.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelSimple.Location = new System.Drawing.Point(289, 192); + this.labelSimple.Name = "labelSimple"; + this.labelSimple.Size = new System.Drawing.Size(115, 32); + this.labelSimple.TabIndex = 8; + this.labelSimple.Text = "Простой"; + this.labelSimple.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelSimple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_MouseDown); + // + // groupBoxColor + // + this.groupBoxColor.Controls.Add(this.panelGreen); + this.groupBoxColor.Controls.Add(this.panelCyan); + this.groupBoxColor.Controls.Add(this.panelPink); + this.groupBoxColor.Controls.Add(this.panelBlack); + this.groupBoxColor.Controls.Add(this.panelPurple); + this.groupBoxColor.Controls.Add(this.panelBlue); + this.groupBoxColor.Controls.Add(this.panelYellow); + this.groupBoxColor.Controls.Add(this.panelRed); + this.groupBoxColor.Location = new System.Drawing.Point(289, 26); + this.groupBoxColor.Name = "groupBoxColor"; + this.groupBoxColor.Size = new System.Drawing.Size(234, 150); + this.groupBoxColor.TabIndex = 7; + this.groupBoxColor.TabStop = false; + this.groupBoxColor.Text = "Цвета"; + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.Lime; + this.panelGreen.Location = new System.Drawing.Point(65, 26); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(50, 41); + this.panelGreen.TabIndex = 1; + // + // panelCyan + // + this.panelCyan.BackColor = System.Drawing.Color.Cyan; + this.panelCyan.Location = new System.Drawing.Point(9, 89); + this.panelCyan.Name = "panelCyan"; + this.panelCyan.Size = new System.Drawing.Size(50, 41); + this.panelCyan.TabIndex = 1; + // + // panelPink + // + this.panelPink.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); + this.panelPink.Location = new System.Drawing.Point(65, 89); + this.panelPink.Name = "panelPink"; + this.panelPink.Size = new System.Drawing.Size(50, 41); + this.panelPink.TabIndex = 1; + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(121, 89); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(50, 41); + this.panelBlack.TabIndex = 1; + // + // panelPurple + // + this.panelPurple.BackColor = System.Drawing.Color.Purple; + this.panelPurple.Location = new System.Drawing.Point(178, 89); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(50, 41); + this.panelPurple.TabIndex = 1; + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(121, 26); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(50, 41); + this.panelBlue.TabIndex = 1; + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(178, 26); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(50, 41); + this.panelYellow.TabIndex = 1; + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(9, 26); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(50, 41); + this.panelRed.TabIndex = 0; + // + // checkBoxBoosters + // + this.checkBoxBoosters.AutoSize = true; + this.checkBoxBoosters.Location = new System.Drawing.Point(21, 132); + this.checkBoxBoosters.Name = "checkBoxBoosters"; + this.checkBoxBoosters.Size = new System.Drawing.Size(148, 19); + this.checkBoxBoosters.TabIndex = 6; + this.checkBoxBoosters.Text = "Наличие ускорителей"; + this.checkBoxBoosters.UseVisualStyleBackColor = true; + this.checkBoxBoosters.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // checkBoxRocket + // + this.checkBoxRocket.AutoSize = true; + this.checkBoxRocket.Location = new System.Drawing.Point(21, 157); + this.checkBoxRocket.Name = "checkBoxRocket"; + this.checkBoxRocket.Size = new System.Drawing.Size(108, 19); + this.checkBoxRocket.TabIndex = 5; + this.checkBoxRocket.Text = "Наличие ракет"; + this.checkBoxRocket.UseVisualStyleBackColor = true; + this.checkBoxRocket.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // checkBoxRadar + // + this.checkBoxRadar.AutoSize = true; + this.checkBoxRadar.Location = new System.Drawing.Point(21, 107); + this.checkBoxRadar.Name = "checkBoxRadar"; + this.checkBoxRadar.Size = new System.Drawing.Size(116, 19); + this.checkBoxRadar.TabIndex = 4; + this.checkBoxRadar.Text = "Наличие радара"; + this.checkBoxRadar.UseVisualStyleBackColor = true; + this.checkBoxRadar.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); + // + // labelWeight + // + this.labelWeight.AutoSize = true; + this.labelWeight.Location = new System.Drawing.Point(21, 78); + this.labelWeight.Name = "labelWeight"; + this.labelWeight.Size = new System.Drawing.Size(26, 15); + this.labelWeight.TabIndex = 1; + this.labelWeight.Text = "Вес"; + // + // labelSpeed + // + this.labelSpeed.AutoSize = true; + this.labelSpeed.Location = new System.Drawing.Point(21, 44); + this.labelSpeed.Name = "labelSpeed"; + this.labelSpeed.Size = new System.Drawing.Size(59, 15); + this.labelSpeed.TabIndex = 0; + this.labelSpeed.Text = "Скорость"; + // + // pictureBoxShow + // + this.pictureBoxShow.Location = new System.Drawing.Point(38, 68); + this.pictureBoxShow.Name = "pictureBoxShow"; + this.pictureBoxShow.Size = new System.Drawing.Size(481, 221); + this.pictureBoxShow.TabIndex = 1; + this.pictureBoxShow.TabStop = false; + // + // panelShow + // + this.panelShow.AllowDrop = true; + this.panelShow.Controls.Add(this.labelAdvancedColor); + this.panelShow.Controls.Add(this.labelColor); + this.panelShow.Controls.Add(this.pictureBoxShow); + this.panelShow.Location = new System.Drawing.Point(658, 22); + this.panelShow.Name = "panelShow"; + this.panelShow.Size = new System.Drawing.Size(558, 292); + this.panelShow.TabIndex = 2; + this.panelShow.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelShow_DragDrop); + this.panelShow.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelShow_DragEnter); + // + // labelAdvancedColor + // + this.labelAdvancedColor.AllowDrop = true; + this.labelAdvancedColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelAdvancedColor.Location = new System.Drawing.Point(320, 16); + this.labelAdvancedColor.Name = "labelAdvancedColor"; + this.labelAdvancedColor.Size = new System.Drawing.Size(164, 39); + this.labelAdvancedColor.TabIndex = 3; + this.labelAdvancedColor.Text = "Дополнительный цвет"; + this.labelAdvancedColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelAdvancedColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelDopColor_DragDrop); + this.labelAdvancedColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter); + // + // labelColor + // + this.labelColor.AllowDrop = true; + this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelColor.Location = new System.Drawing.Point(82, 16); + this.labelColor.Name = "labelColor"; + this.labelColor.Size = new System.Drawing.Size(164, 39); + this.labelColor.TabIndex = 2; + this.labelColor.Text = "Основной цвет"; + this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelBaseColor_DragDrop); + this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter); + // + // buttonAdd + // + this.buttonAdd.Location = new System.Drawing.Point(677, 333); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(227, 45); + this.buttonAdd.TabIndex = 3; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(978, 333); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(227, 45); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "Отменить"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FormAirConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1244, 390); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.panelShow); + this.Controls.Add(this.groupBoxConfig); + this.Name = "FormAirConfig"; + this.Text = "FormAirConfig"; + this.groupBoxConfig.ResumeLayout(false); + this.groupBoxConfig.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + this.groupBoxColor.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxShow)).EndInit(); + this.panelShow.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBoxConfig; + private Label labelWeight; + private Label labelSpeed; + private Label labelAdvanced; + private Label labelSimple; + private GroupBox groupBoxColor; + private Panel panelGreen; + private Panel panelCyan; + private Panel panelPink; + private Panel panelBlack; + private Panel panelPurple; + private Panel panelBlue; + private Panel panelYellow; + private Panel panelRed; + private CheckBox checkBoxBoosters; + private CheckBox checkBoxRocket; + private CheckBox checkBoxRadar; + private PictureBox pictureBoxShow; + private Panel panelShow; + private Label labelAdvancedColor; + private Label labelColor; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Button buttonAdd; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/Stormtrooper/Stormtrooper/FormAirConfig.cs b/Stormtrooper/Stormtrooper/FormAirConfig.cs new file mode 100644 index 0000000..0ee2496 --- /dev/null +++ b/Stormtrooper/Stormtrooper/FormAirConfig.cs @@ -0,0 +1,122 @@ +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 Stormtrooper +{ + public partial class FormAirConfig : Form + { + DrawningMilitaryAirplane _airplane = null; + public FormAirConfig() + { + InitializeComponent(); + panelBlack.MouseDown += PanelColor_MouseDown; + panelPurple.MouseDown += PanelColor_MouseDown; + panelPink.MouseDown += PanelColor_MouseDown; + panelGreen.MouseDown += PanelColor_MouseDown; + panelRed.MouseDown += PanelColor_MouseDown; + panelCyan.MouseDown += PanelColor_MouseDown; + panelYellow.MouseDown += PanelColor_MouseDown; + panelBlue.MouseDown += PanelColor_MouseDown; + } + + private void DrawAirplane() + { + Bitmap bmp = new(pictureBoxShow.Width, pictureBoxShow.Height); + Graphics gr = Graphics.FromImage(bmp); + _airplane?.SetPosition(200, 70, pictureBoxShow.Width, pictureBoxShow.Height); + _airplane?.DrawAirplane(gr); + pictureBoxShow.Image = bmp; + } + + private void label_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); + } + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void labelColor_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) + { + if (_airplane != null) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + _airplane.Airplane.Color = (Color)e.Data.GetData(typeof(Color)); + } + DrawAirplane(); + } + } + private void labelDopColor_DragDrop(object sender, DragEventArgs e) + { + if (_airplane != null && _airplane is DrawningStormtrooper stormtrooper) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + if(stormtrooper.Airplane is EntityStormtrooper entityStormtrooper) + { + entityStormtrooper.AdvColor = (Color)e.Data.GetData(typeof(Color)); + } + } + DrawAirplane(); + } + } + + private void panelShow_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void panelShow_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "labelSimple": + _airplane = new DrawningMilitaryAirplane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + break; + case "labelAdvanced": + _airplane = new DrawningStormtrooper((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, + checkBoxRocket.Checked, checkBoxBoosters.Checked, checkBoxRadar.Checked); + break; + } + DrawAirplane(); + } + + private void checkBox_CheckedChanged(object sender, EventArgs e) + { + if(_airplane is DrawningStormtrooper) + { + _airplane = new DrawningStormtrooper((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, _airplane.Airplane.Color, (_airplane.Airplane as EntityStormtrooper).AdvColor, + checkBoxRocket.Checked, checkBoxBoosters.Checked, checkBoxRadar.Checked); + DrawAirplane(); + } + + } + } +} diff --git a/Stormtrooper/Stormtrooper/FormAirConfig.resx b/Stormtrooper/Stormtrooper/FormAirConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Stormtrooper/Stormtrooper/FormAirConfig.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 diff --git a/Stormtrooper/Stormtrooper/Program.cs b/Stormtrooper/Stormtrooper/Program.cs index 65b5334..f6676cc 100644 --- a/Stormtrooper/Stormtrooper/Program.cs +++ b/Stormtrooper/Stormtrooper/Program.cs @@ -16,7 +16,7 @@ namespace Stormtrooper { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new FormMapWithSetAirplane()); + Application.Run(new FormAirConfig()); } } } -- 2.25.1 From f3d2973c847696ef3fd444d1c79e9c4591958ecf Mon Sep 17 00:00:00 2001 From: foxkerik6 Date: Tue, 29 Nov 2022 01:56:58 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=B2=D1=81=D1=91=20=D0=B3=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Stormtrooper/Stormtrooper/AirDelegate.cs | 10 ++++++ .../Stormtrooper/FormAirConfig.Designer.cs | 1 + Stormtrooper/Stormtrooper/FormAirConfig.cs | 19 +++++++++++ .../Stormtrooper/FormMapWithSetAirplane.cs | 34 ++++++++----------- Stormtrooper/Stormtrooper/Program.cs | 2 +- 5 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 Stormtrooper/Stormtrooper/AirDelegate.cs diff --git a/Stormtrooper/Stormtrooper/AirDelegate.cs b/Stormtrooper/Stormtrooper/AirDelegate.cs new file mode 100644 index 0000000..70d2a59 --- /dev/null +++ b/Stormtrooper/Stormtrooper/AirDelegate.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Stormtrooper +{ + public delegate void AirDelegate(DrawningMilitaryAirplane airplane); +} diff --git a/Stormtrooper/Stormtrooper/FormAirConfig.Designer.cs b/Stormtrooper/Stormtrooper/FormAirConfig.Designer.cs index a825a9b..d412a15 100644 --- a/Stormtrooper/Stormtrooper/FormAirConfig.Designer.cs +++ b/Stormtrooper/Stormtrooper/FormAirConfig.Designer.cs @@ -334,6 +334,7 @@ this.buttonAdd.TabIndex = 3; this.buttonAdd.Text = "Добавить"; this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); // // buttonCancel // diff --git a/Stormtrooper/Stormtrooper/FormAirConfig.cs b/Stormtrooper/Stormtrooper/FormAirConfig.cs index 0ee2496..1ae0ff9 100644 --- a/Stormtrooper/Stormtrooper/FormAirConfig.cs +++ b/Stormtrooper/Stormtrooper/FormAirConfig.cs @@ -13,6 +13,7 @@ namespace Stormtrooper public partial class FormAirConfig : Form { DrawningMilitaryAirplane _airplane = null; + private event AirDelegate EventAddAirplane; public FormAirConfig() { InitializeComponent(); @@ -24,6 +25,7 @@ namespace Stormtrooper panelCyan.MouseDown += PanelColor_MouseDown; panelYellow.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown; + buttonCancel.Click += (object sender, EventArgs e) => Close(); } private void DrawAirplane() @@ -34,6 +36,17 @@ namespace Stormtrooper _airplane?.DrawAirplane(gr); pictureBoxShow.Image = bmp; } + public void AddEvent(AirDelegate ev) + { + if (EventAddAirplane == null) + { + EventAddAirplane = new AirDelegate(ev); + } + else + { + EventAddAirplane += ev; + } + } private void label_MouseDown(object sender, MouseEventArgs e) { @@ -118,5 +131,11 @@ namespace Stormtrooper } } + + private void buttonAdd_Click(object sender, EventArgs e) + { + EventAddAirplane?.Invoke(_airplane); + Close(); + } } } diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs index e19fd65..8dc221b 100644 --- a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs +++ b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs @@ -78,32 +78,26 @@ namespace Stormtrooper /// /// private void ButtonAdd_Click(object sender, EventArgs e) + { + var formLocomotiveConfig = new FormAirConfig(); + formLocomotiveConfig.AddEvent(AddLocomotive); + formLocomotiveConfig.Show(); + } + private void AddLocomotive(DrawningMilitaryAirplane drawningMilitaryAirplane) { if (listBoxMap.SelectedIndex == -1) { return; } - MainForm form = new(); - if (form.ShowDialog() == DialogResult.OK) + DrawningObject airplane = new(drawningMilitaryAirplane); + if (_mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] + airplane != -1) { - if(form.SelectedAirplane != null) - { - DrawningObject airplane = new (form.SelectedAirplane); - if (_mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty] + airplane != -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } - else - { - MessageBox.Show("Объект не создан"); - } - + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapCollection[listBoxMap.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); } } /// diff --git a/Stormtrooper/Stormtrooper/Program.cs b/Stormtrooper/Stormtrooper/Program.cs index f6676cc..65b5334 100644 --- a/Stormtrooper/Stormtrooper/Program.cs +++ b/Stormtrooper/Stormtrooper/Program.cs @@ -16,7 +16,7 @@ namespace Stormtrooper { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new FormAirConfig()); + Application.Run(new FormMapWithSetAirplane()); } } } -- 2.25.1 From 577de84cd5262b46dc3349224a8fc0ca06a92e90 Mon Sep 17 00:00:00 2001 From: foxkerik6 Date: Tue, 29 Nov 2022 02:11:15 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5=D1=82=D0=BE=D1=87=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Stormtrooper/Stormtrooper/AirDelegate.cs | 10 ---------- Stormtrooper/Stormtrooper/FormAirConfig.cs | 6 +++--- Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs | 8 ++++---- 3 files changed, 7 insertions(+), 17 deletions(-) delete mode 100644 Stormtrooper/Stormtrooper/AirDelegate.cs diff --git a/Stormtrooper/Stormtrooper/AirDelegate.cs b/Stormtrooper/Stormtrooper/AirDelegate.cs deleted file mode 100644 index 70d2a59..0000000 --- a/Stormtrooper/Stormtrooper/AirDelegate.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Stormtrooper -{ - public delegate void AirDelegate(DrawningMilitaryAirplane airplane); -} diff --git a/Stormtrooper/Stormtrooper/FormAirConfig.cs b/Stormtrooper/Stormtrooper/FormAirConfig.cs index 1ae0ff9..848478e 100644 --- a/Stormtrooper/Stormtrooper/FormAirConfig.cs +++ b/Stormtrooper/Stormtrooper/FormAirConfig.cs @@ -13,7 +13,7 @@ namespace Stormtrooper public partial class FormAirConfig : Form { DrawningMilitaryAirplane _airplane = null; - private event AirDelegate EventAddAirplane; + private event Action EventAddAirplane; public FormAirConfig() { InitializeComponent(); @@ -36,11 +36,11 @@ namespace Stormtrooper _airplane?.DrawAirplane(gr); pictureBoxShow.Image = bmp; } - public void AddEvent(AirDelegate ev) + public void AddEvent(Action ev) { if (EventAddAirplane == null) { - EventAddAirplane = new AirDelegate(ev); + EventAddAirplane = new Action(ev); } else { diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs index 8dc221b..3fdccf9 100644 --- a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs +++ b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs @@ -79,11 +79,11 @@ namespace Stormtrooper /// private void ButtonAdd_Click(object sender, EventArgs e) { - var formLocomotiveConfig = new FormAirConfig(); - formLocomotiveConfig.AddEvent(AddLocomotive); - formLocomotiveConfig.Show(); + var formAirConfig = new FormAirConfig(); + formAirConfig.AddEvent(AddAirplane); + formAirConfig.Show(); } - private void AddLocomotive(DrawningMilitaryAirplane drawningMilitaryAirplane) + private void AddAirplane(DrawningMilitaryAirplane drawningMilitaryAirplane) { if (listBoxMap.SelectedIndex == -1) { -- 2.25.1 From ee654db0fee8b60f3ec228c3233c2ce9743bbb3c Mon Sep 17 00:00:00 2001 From: ker73rus Date: Tue, 29 Nov 2022 08:55:47 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs | 2 +- Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs index 3fdccf9..723be9e 100644 --- a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs +++ b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs @@ -24,7 +24,7 @@ namespace Stormtrooper /// Объект от коллекции карт /// private readonly MapCollection _mapCollection; - private MapWithSetAirplaneGeneric _mapAirsCollectionGeneric; + public FormMapWithSetAirplane() { InitializeComponent(); diff --git a/Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs b/Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs index 12424a2..ab561ef 100644 --- a/Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs +++ b/Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs @@ -167,7 +167,6 @@ namespace Stormtrooper int currentWidth = width - 1; int currentHeight = 0; - int i = 0; foreach (var air in _setAirs.GetAirs()) { -- 2.25.1 From 601c59bb04c8dbb41132d248a2026e76f533efbc Mon Sep 17 00:00:00 2001 From: foxkerik6 Date: Wed, 30 Nov 2022 23:49:51 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=B5=D1=89=D1=91=20=D0=BF=D0=BE=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs index 723be9e..9442658 100644 --- a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs +++ b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs @@ -24,7 +24,6 @@ namespace Stormtrooper /// Объект от коллекции карт /// private readonly MapCollection _mapCollection; - public FormMapWithSetAirplane() { InitializeComponent(); -- 2.25.1