From a0aee749e1d623245d22cf532252a4b717d10310 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 21:54:03 +0400 Subject: [PATCH] changes forms --- AirBomber/AirBomber/Direction.cs | 2 +- AirBomber/AirBomber/DrawningJet.cs | 2 +- AirBomber/AirBomber/EntityJet.cs | 2 +- AirBomber/AirBomber/FormMap.Designer.cs | 21 +- AirBomber/AirBomber/FormMap.cs | 5 +- .../AirBomber/FormMapWithSetJets.Designer.cs | 215 ++++++++++++++++++ AirBomber/AirBomber/FormMapWithSetJets.cs | 163 +++++++++++++ AirBomber/AirBomber/FormMapWithSetJets.resx | 60 +++++ AirBomber/AirBomber/Program.cs | 2 +- AirBomber/AirBomber/WarJet.Designer.cs | 25 +- AirBomber/AirBomber/WarJet.cs | 66 ++++-- 11 files changed, 530 insertions(+), 33 deletions(-) create mode 100644 AirBomber/AirBomber/FormMapWithSetJets.Designer.cs create mode 100644 AirBomber/AirBomber/FormMapWithSetJets.cs create mode 100644 AirBomber/AirBomber/FormMapWithSetJets.resx diff --git a/AirBomber/AirBomber/Direction.cs b/AirBomber/AirBomber/Direction.cs index 5f01285..9731062 100644 --- a/AirBomber/AirBomber/Direction.cs +++ b/AirBomber/AirBomber/Direction.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace AirBomber { - internal enum Direction + public enum Direction { None = 0, Up = 1, diff --git a/AirBomber/AirBomber/DrawningJet.cs b/AirBomber/AirBomber/DrawningJet.cs index f96ccb1..5e5bcb5 100644 --- a/AirBomber/AirBomber/DrawningJet.cs +++ b/AirBomber/AirBomber/DrawningJet.cs @@ -9,7 +9,7 @@ namespace AirBomber /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности /// - internal class DrawningJet + public class DrawningJet { /// /// Класс-сущность diff --git a/AirBomber/AirBomber/EntityJet.cs b/AirBomber/AirBomber/EntityJet.cs index f713d10..ebbac82 100644 --- a/AirBomber/AirBomber/EntityJet.cs +++ b/AirBomber/AirBomber/EntityJet.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace AirBomber { - internal class EntityJet + public class EntityJet { /// /// Скорость diff --git a/AirBomber/AirBomber/FormMap.Designer.cs b/AirBomber/AirBomber/FormMap.Designer.cs index f0fab3b..fd3c104 100644 --- a/AirBomber/AirBomber/FormMap.Designer.cs +++ b/AirBomber/AirBomber/FormMap.Designer.cs @@ -40,6 +40,7 @@ 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(); @@ -105,7 +106,7 @@ 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); + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonLeft // @@ -117,7 +118,7 @@ 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); + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonRight // @@ -129,7 +130,7 @@ 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); + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonDown // @@ -141,7 +142,7 @@ 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); + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonCreateModif // @@ -166,11 +167,22 @@ 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); @@ -204,5 +216,6 @@ 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 index 23fa207..f038f44 100644 --- a/AirBomber/AirBomber/FormMap.cs +++ b/AirBomber/AirBomber/FormMap.cs @@ -35,11 +35,11 @@ namespace AirBomber /// private void buttonCreate_Click(object sender, EventArgs e) { - Random rnd = new Random(); + 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) + private void ButtonMove_Click(object sender, EventArgs e) { //получаем имя кнопки string name = ((Button)sender)?.Name ?? string.Empty; @@ -61,7 +61,6 @@ namespace AirBomber } pictureBoxJet.Image = _abstractMap?.MoveObject(dir); } - private void buttonCreateModif_Click(object sender, EventArgs e) { Random rnd = new Random(); diff --git a/AirBomber/AirBomber/FormMapWithSetJets.Designer.cs b/AirBomber/AirBomber/FormMapWithSetJets.Designer.cs new file mode 100644 index 0000000..8f59397 --- /dev/null +++ b/AirBomber/AirBomber/FormMapWithSetJets.Designer.cs @@ -0,0 +1,215 @@ +namespace AirBomber +{ + partial class FormMapWithSetJets + { + /// + /// 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.ButtonShowOnMap = new System.Windows.Forms.Button(); + this.ButtonShowStorage = new System.Windows.Forms.Button(); + this.ButtonRemoveJet = new System.Windows.Forms.Button(); + this.maskedTextBoxPosition = new System.Windows.Forms.TextBox(); + this.ButtonAddJet = new System.Windows.Forms.Button(); + this.comboBoxCelectorMap1 = new System.Windows.Forms.ComboBox(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.buttonDown = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.pictureBoxJet = new System.Windows.Forms.PictureBox(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.ButtonShowOnMap); + this.groupBox1.Controls.Add(this.ButtonShowStorage); + this.groupBox1.Controls.Add(this.ButtonRemoveJet); + this.groupBox1.Controls.Add(this.maskedTextBoxPosition); + this.groupBox1.Controls.Add(this.ButtonAddJet); + this.groupBox1.Controls.Add(this.comboBoxCelectorMap1); + this.groupBox1.Controls.Add(this.buttonLeft); + this.groupBox1.Controls.Add(this.buttonRight); + this.groupBox1.Controls.Add(this.buttonDown); + this.groupBox1.Controls.Add(this.buttonUp); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right; + this.groupBox1.Location = new System.Drawing.Point(680, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(200, 524); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Инструменты"; + // + // ButtonShowOnMap + // + this.ButtonShowOnMap.Location = new System.Drawing.Point(6, 276); + this.ButtonShowOnMap.Name = "ButtonShowOnMap"; + this.ButtonShowOnMap.Size = new System.Drawing.Size(182, 23); + this.ButtonShowOnMap.TabIndex = 15; + this.ButtonShowOnMap.Text = "Посмотреть карту"; + this.ButtonShowOnMap.UseVisualStyleBackColor = true; + this.ButtonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click); + // + // ButtonShowStorage + // + this.ButtonShowStorage.Location = new System.Drawing.Point(6, 223); + this.ButtonShowStorage.Name = "ButtonShowStorage"; + this.ButtonShowStorage.Size = new System.Drawing.Size(182, 23); + this.ButtonShowStorage.TabIndex = 14; + this.ButtonShowStorage.Text = "Посмотреть хранилище"; + this.ButtonShowStorage.UseVisualStyleBackColor = true; + this.ButtonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click); + // + // ButtonRemoveJet + // + this.ButtonRemoveJet.Location = new System.Drawing.Point(6, 144); + this.ButtonRemoveJet.Name = "ButtonRemoveJet"; + this.ButtonRemoveJet.Size = new System.Drawing.Size(182, 23); + this.ButtonRemoveJet.TabIndex = 13; + this.ButtonRemoveJet.Text = "Удалить самолет"; + this.ButtonRemoveJet.UseVisualStyleBackColor = true; + this.ButtonRemoveJet.Click += new System.EventHandler(this.ButtonRemoveJet_Click); + // + // maskedTextBoxPosition + // + this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 115); + this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + this.maskedTextBoxPosition.Size = new System.Drawing.Size(182, 23); + this.maskedTextBoxPosition.TabIndex = 12; + // + // ButtonAddJet + // + this.ButtonAddJet.Location = new System.Drawing.Point(6, 68); + this.ButtonAddJet.Name = "ButtonAddJet"; + this.ButtonAddJet.Size = new System.Drawing.Size(182, 23); + this.ButtonAddJet.TabIndex = 11; + this.ButtonAddJet.Text = "Добавить самолет"; + this.ButtonAddJet.UseVisualStyleBackColor = true; + this.ButtonAddJet.Click += new System.EventHandler(this.ButtonAddJet_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(6, 22); + this.comboBoxCelectorMap1.Name = "comboBoxCelectorMap1"; + this.comboBoxCelectorMap1.Size = new System.Drawing.Size(182, 23); + this.comboBoxCelectorMap1.TabIndex = 10; + this.comboBoxCelectorMap1.SelectedIndexChanged += new System.EventHandler(this.comboBoxCelectorMap1_SelectedIndexChanged); + // + // 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(51, 467); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(35, 30); + this.buttonLeft.TabIndex = 9; + 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(133, 467); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(35, 30); + this.buttonRight.TabIndex = 8; + 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(92, 467); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(35, 30); + this.buttonDown.TabIndex = 7; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_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(92, 431); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(35, 30); + this.buttonUp.TabIndex = 4; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // 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(680, 524); + this.pictureBoxJet.TabIndex = 1; + this.pictureBoxJet.TabStop = false; + // + // FormMapWithSetJets + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(880, 524); + this.Controls.Add(this.pictureBoxJet); + this.Controls.Add(this.groupBox1); + this.Name = "FormMapWithSetJets"; + this.Text = "Карта с набором объектов"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBox1; + private PictureBox pictureBoxJet; + private Button buttonUp; + private Button buttonDown; + private Button buttonRight; + private Button buttonLeft; + private Button ButtonShowOnMap; + private Button ButtonShowStorage; + private Button ButtonRemoveJet; + private TextBox maskedTextBoxPosition; + private Button ButtonAddJet; + private ComboBox comboBoxCelectorMap1; + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormMapWithSetJets.cs b/AirBomber/AirBomber/FormMapWithSetJets.cs new file mode 100644 index 0000000..d6d27ce --- /dev/null +++ b/AirBomber/AirBomber/FormMapWithSetJets.cs @@ -0,0 +1,163 @@ +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 static System.Windows.Forms.DataFormats; + +namespace AirBomber +{ + public partial class FormMapWithSetJets : Form + { + /// + /// Объект от класса карты с набором объектов + /// + private MapWithSetJetsGeneric _mapJetsCollectionGeneric; + /// + /// Конструктор + /// + public FormMapWithSetJets() + { + InitializeComponent(); + } + /// + /// Выбор карты + /// + /// + /// + private void comboBoxCelectorMap1_SelectedIndexChanged(object sender, EventArgs e) + { + AbstractMap map = null; + switch (comboBoxCelectorMap1.Text) + { + case "Простая карта": + map = new SimpleMap(); + break; + case "Небо": + map = new SkyMap(); + break; + } + if (map != null) + { + _mapJetsCollectionGeneric = new MapWithSetJetsGeneric(pictureBoxJet.Width, pictureBoxJet.Height, map); + } + else + { + _mapJetsCollectionGeneric = null; + } + } + /// + /// Добавление объекта + /// + /// + /// + private void ButtonAddJet_Click(object sender, EventArgs e) + { + if (_mapJetsCollectionGeneric == null) + { + return; + } + WarJet form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + if (form.SelectedJet == null) + { + MessageBox.Show("Сначала создайте объект"); + return; + } + DrawningObjectJet bus = new(form.SelectedJet); + if (_mapJetsCollectionGeneric + bus != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBoxJet.Image = _mapJetsCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + /// + /// Удаление объекта + /// + /// + /// + private void ButtonRemoveJet_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) + { + return; + } + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxPosition.Text); + if (_mapJetsCollectionGeneric - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBoxJet.Image = _mapJetsCollectionGeneric.ShowSet(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + /// + /// Вывод набора + /// + /// + /// + private void ButtonShowStorage_Click(object sender, EventArgs e) + { + if (_mapJetsCollectionGeneric == null) + { + return; + } + pictureBoxJet.Image = _mapJetsCollectionGeneric.ShowSet(); + } + /// + /// Вывод карты + /// + /// + /// + private void ButtonShowOnMap_Click(object sender, EventArgs e) + { + if (_mapJetsCollectionGeneric == null) + { + return; + } + pictureBoxJet.Image = _mapJetsCollectionGeneric.ShowOnMap(); + } + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_mapJetsCollectionGeneric == null) + { + return; + } + //получаем имя кнопки + 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 = _mapJetsCollectionGeneric.MoveObject(dir); + } + } +} diff --git a/AirBomber/AirBomber/FormMapWithSetJets.resx b/AirBomber/AirBomber/FormMapWithSetJets.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AirBomber/AirBomber/FormMapWithSetJets.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/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index e462fb5..19f609b 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -11,7 +11,7 @@ namespace AirBomber // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormMap()); + Application.Run(new FormMapWithSetJets()); } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/WarJet.Designer.cs b/AirBomber/AirBomber/WarJet.Designer.cs index d476ade..e4f716a 100644 --- a/AirBomber/AirBomber/WarJet.Designer.cs +++ b/AirBomber/AirBomber/WarJet.Designer.cs @@ -39,6 +39,7 @@ this.buttonRight = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonCreateModif = new System.Windows.Forms.Button(); + this.ButtonSelectJet = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); @@ -52,7 +53,7 @@ this.pictureBoxJet.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxJet.TabIndex = 0; this.pictureBoxJet.TabStop = false; - this.pictureBoxJet.Click += new System.EventHandler(this.PictureBoxCar_Resize); + this.pictureBoxJet.Click += new System.EventHandler(this.PictureBoxJet_Resize); // // statusStrip1 // @@ -105,7 +106,7 @@ 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); + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonLeft // @@ -117,7 +118,7 @@ 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); + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonRight // @@ -129,7 +130,7 @@ 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); + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonDown // @@ -141,7 +142,7 @@ 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); + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonCreateModif // @@ -151,13 +152,24 @@ this.buttonCreateModif.TabIndex = 7; this.buttonCreateModif.Text = "Модификация"; this.buttonCreateModif.UseVisualStyleBackColor = true; - this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click); + this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); + // + // ButtonSelectJet + // + this.ButtonSelectJet.Location = new System.Drawing.Point(554, 394); + this.ButtonSelectJet.Name = "ButtonSelectJet"; + this.ButtonSelectJet.Size = new System.Drawing.Size(75, 23); + this.ButtonSelectJet.TabIndex = 8; + this.ButtonSelectJet.Text = "Выбрать"; + this.ButtonSelectJet.UseVisualStyleBackColor = true; + this.ButtonSelectJet.Click += new System.EventHandler(this.ButtonSelectJet_Click); // // WarJet // 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.buttonCreateModif); this.Controls.Add(this.buttonDown); this.Controls.Add(this.buttonRight); @@ -189,5 +201,6 @@ private Button buttonRight; private Button buttonDown; private Button buttonCreateModif; + private Button ButtonSelectJet; } } \ No newline at end of file diff --git a/AirBomber/AirBomber/WarJet.cs b/AirBomber/AirBomber/WarJet.cs index a0d81b4..ebdd2ab 100644 --- a/AirBomber/AirBomber/WarJet.cs +++ b/AirBomber/AirBomber/WarJet.cs @@ -3,6 +3,7 @@ namespace AirBomber public partial class WarJet : Form { private DrawningJet _jet; + public DrawningJet SelectedJet { get; private set; } public WarJet() { InitializeComponent(); @@ -28,7 +29,26 @@ namespace AirBomber toolStripStatusLabelWeight.Text = $": {_jet.Jet.Weight}"; toolStripStatusLabelBodyColor.Text = $": {_jet.Jet.BodyColor.Name}"; } - private void buttonMove_Click(object sender, EventArgs e) + /// + /// "" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + Random rnd = new Random(); + Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + _jet = new DrawningJet(rnd.Next(100, 300), rnd.Next(1000, 2000), color); + //_jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxJet.Width, pictureBoxJet.Height); + SetData(); + Draw(); + } + private void ButtonMove_Click(object sender, EventArgs e) { // string name = ((Button)sender)?.Name ?? string.Empty; @@ -54,34 +74,48 @@ namespace AirBomber /// /// /// - private void PictureBoxCar_Resize(object sender, EventArgs e) + private void PictureBoxJet_Resize(object sender, EventArgs e) { _jet?.ChangeBorders(pictureBoxJet.Width, pictureBoxJet.Height); Draw(); } /// - /// "" + /// "" /// /// /// - private void buttonCreate_Click(object sender, EventArgs e) + private void ButtonCreateModif_Click(object sender, EventArgs e) { Random rnd = new Random(); - _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))); - _jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxJet.Width, pictureBoxJet.Height); - SetData(); - Draw(); - } - - 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)), + Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)); + ColorDialog dialogDop = new(); + if (dialogDop.ShowDialog() == DialogResult.OK) + { + dopColor = dialogDop.Color; + } + _jet = new DrawningSportJet(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor, + //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(); Draw(); } + /// + /// "" + /// + /// + /// + private void ButtonSelectJet_Click(object sender, EventArgs e) + { + SelectedJet = _jet; + DialogResult = DialogResult.OK; + } } } \ No newline at end of file