diff --git a/SelfPropelledArtilleryUnit/FormMap.cs b/SelfPropelledArtilleryUnit/FormMap.cs
deleted file mode 100644
index 016c4bc..0000000
--- a/SelfPropelledArtilleryUnit/FormMap.cs
+++ /dev/null
@@ -1,88 +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 Artilleries
-{
- public partial class FormMap : Form
- {
- private AbstractMap _abstractMap;
-
- public FormMap()
- {
- InitializeComponent();
- _abstractMap = new SimpleMap();
- }
-
- private void SetData(DrawingArtillery artillery)
- {
- Random rnd = new();
- artillery.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
- SpeedStatusLabel.Text = $"Скорость: {artillery.Artillery.Speed}";
- WeightStatusLabel.Text = $"Вес: {artillery.Artillery.Weight}";
- ColorStatusLabel.Text = $"Цвет: {artillery.Artillery.BodyColor.Name}";
- pictureBoxArtilleries.Image = _abstractMap.CreateMap(pictureBoxArtilleries.Width, pictureBoxArtilleries.Height, new DrawingObjectArtillery(artillery));
- }
-
- private void createAdvancedButton_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var artillery = new DrawingAdvancedArtillery(
- 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)),
- rnd.Next(0, 2) == 1, rnd.Next(0, 2) == 1
- );
- SetData(artillery);
- }
-
- private void buttonCreate_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var artillery = new DrawingArtillery(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- SetData(artillery);
- }
-
- 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;
- }
- pictureBoxArtilleries.Image = _abstractMap?.MoveObject(dir);
- }
-
- private void comboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (comboBoxSelectorMap.Text)
- {
- case "Простая карта":
- _abstractMap = new SimpleMap();
- break;
- case "Лесная карта":
- _abstractMap = new ForestMap();
- break;
- }
- }
- }
-}
diff --git a/SelfPropelledArtilleryUnit/FormMap.Designer.cs b/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.Designer.cs
similarity index 54%
rename from SelfPropelledArtilleryUnit/FormMap.Designer.cs
rename to SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.Designer.cs
index 61dcc5c..89100c3 100644
--- a/SelfPropelledArtilleryUnit/FormMap.Designer.cs
+++ b/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.Designer.cs
@@ -1,6 +1,6 @@
namespace Artilleries
{
- partial class FormMap
+ partial class FormMapWithSetArtilleries
{
///
/// Required designer variable.
@@ -28,130 +28,89 @@
///
private void InitializeComponent()
{
- this.createAdvancedButton = new System.Windows.Forms.Button();
+ this.toolsGroupBox = new System.Windows.Forms.GroupBox();
+ this.buttonShowOnMap = new System.Windows.Forms.Button();
+ this.buttonShowStorage = new System.Windows.Forms.Button();
+ this.buttonRemoveArtillery = new System.Windows.Forms.Button();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonAddArtillery = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
- this.buttonCreate = new System.Windows.Forms.Button();
this.pictureBoxArtilleries = new System.Windows.Forms.PictureBox();
- this.statusStrip1 = new System.Windows.Forms.StatusStrip();
- this.SpeedStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
- this.WeightStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
- this.ColorStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
- this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ this.toolsGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxArtilleries)).BeginInit();
- this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
- // createAdvancedButton
+ // toolsGroupBox
//
- this.createAdvancedButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.createAdvancedButton.Location = new System.Drawing.Point(105, 382);
- this.createAdvancedButton.Name = "createAdvancedButton";
- this.createAdvancedButton.Size = new System.Drawing.Size(95, 23);
- this.createAdvancedButton.TabIndex = 15;
- this.createAdvancedButton.Text = "Модификация";
- this.createAdvancedButton.UseVisualStyleBackColor = true;
- this.createAdvancedButton.Click += new System.EventHandler(this.createAdvancedButton_Click);
+ this.toolsGroupBox.Controls.Add(this.buttonShowOnMap);
+ this.toolsGroupBox.Controls.Add(this.buttonShowStorage);
+ this.toolsGroupBox.Controls.Add(this.buttonRemoveArtillery);
+ this.toolsGroupBox.Controls.Add(this.maskedTextBoxPosition);
+ this.toolsGroupBox.Controls.Add(this.buttonAddArtillery);
+ this.toolsGroupBox.Controls.Add(this.comboBoxSelectorMap);
+ this.toolsGroupBox.Controls.Add(this.buttonRight);
+ this.toolsGroupBox.Controls.Add(this.buttonDown);
+ this.toolsGroupBox.Controls.Add(this.buttonUp);
+ this.toolsGroupBox.Controls.Add(this.buttonLeft);
+ this.toolsGroupBox.Dock = System.Windows.Forms.DockStyle.Right;
+ this.toolsGroupBox.Location = new System.Drawing.Point(600, 0);
+ this.toolsGroupBox.Name = "toolsGroupBox";
+ this.toolsGroupBox.Size = new System.Drawing.Size(200, 450);
+ this.toolsGroupBox.TabIndex = 0;
+ this.toolsGroupBox.TabStop = false;
+ this.toolsGroupBox.Text = "Инструменты";
//
- // buttonRight
+ // buttonShowOnMap
//
- this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonRight.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowRight;
- this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.buttonRight.Location = new System.Drawing.Point(579, 375);
- this.buttonRight.Name = "buttonRight";
- this.buttonRight.Size = new System.Drawing.Size(30, 30);
- this.buttonRight.TabIndex = 14;
- this.buttonRight.UseVisualStyleBackColor = true;
- this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
+ this.buttonShowOnMap.Location = new System.Drawing.Point(13, 315);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(175, 32);
+ this.buttonShowOnMap.TabIndex = 24;
+ this.buttonShowOnMap.Text = "Посмотреть карту";
+ this.buttonShowOnMap.UseVisualStyleBackColor = true;
+ this.buttonShowOnMap.Click += new System.EventHandler(this.buttonShowOnMap_Click);
//
- // buttonDown
+ // buttonShowStorage
//
- this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDown.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowDown;
- this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.buttonDown.Location = new System.Drawing.Point(543, 375);
- this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(30, 30);
- this.buttonDown.TabIndex = 13;
- this.buttonDown.UseVisualStyleBackColor = true;
- this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
+ this.buttonShowStorage.Location = new System.Drawing.Point(13, 249);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(175, 32);
+ this.buttonShowStorage.TabIndex = 23;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.buttonShowStorage_Click);
//
- // buttonUp
+ // buttonRemoveArtillery
//
- this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonUp.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowUp;
- this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.buttonUp.Location = new System.Drawing.Point(543, 342);
- this.buttonUp.Name = "buttonUp";
- this.buttonUp.Size = new System.Drawing.Size(30, 30);
- this.buttonUp.TabIndex = 12;
- this.buttonUp.UseVisualStyleBackColor = true;
- this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
+ this.buttonRemoveArtillery.Location = new System.Drawing.Point(13, 177);
+ this.buttonRemoveArtillery.Name = "buttonRemoveArtillery";
+ this.buttonRemoveArtillery.Size = new System.Drawing.Size(175, 32);
+ this.buttonRemoveArtillery.TabIndex = 22;
+ this.buttonRemoveArtillery.Text = "Удалить артиллерию";
+ this.buttonRemoveArtillery.UseVisualStyleBackColor = true;
+ this.buttonRemoveArtillery.Click += new System.EventHandler(this.buttonRemoveArtillery_Click);
//
- // buttonLeft
+ // maskedTextBoxPosition
//
- this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonLeft.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowLeft;
- this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
- this.buttonLeft.Location = new System.Drawing.Point(509, 375);
- this.buttonLeft.Name = "buttonLeft";
- this.buttonLeft.Size = new System.Drawing.Size(30, 30);
- this.buttonLeft.TabIndex = 11;
- this.buttonLeft.UseVisualStyleBackColor = true;
- this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(13, 148);
+ this.maskedTextBoxPosition.Mask = "00";
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
+ this.maskedTextBoxPosition.TabIndex = 21;
//
- // buttonCreate
+ // buttonAddArtillery
//
- 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, 382);
- this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(75, 23);
- this.buttonCreate.TabIndex = 10;
- this.buttonCreate.Text = "Создать";
- this.buttonCreate.UseVisualStyleBackColor = true;
- this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
- //
- // pictureBoxArtilleries
- //
- this.pictureBoxArtilleries.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictureBoxArtilleries.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxArtilleries.Name = "pictureBoxArtilleries";
- this.pictureBoxArtilleries.Size = new System.Drawing.Size(624, 419);
- this.pictureBoxArtilleries.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxArtilleries.TabIndex = 9;
- this.pictureBoxArtilleries.TabStop = false;
- //
- // statusStrip1
- //
- this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.SpeedStatusLabel,
- this.WeightStatusLabel,
- this.ColorStatusLabel});
- this.statusStrip1.Location = new System.Drawing.Point(0, 419);
- this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(624, 22);
- this.statusStrip1.TabIndex = 8;
- //
- // SpeedStatusLabel
- //
- this.SpeedStatusLabel.Name = "SpeedStatusLabel";
- this.SpeedStatusLabel.Size = new System.Drawing.Size(62, 17);
- this.SpeedStatusLabel.Text = "Скорость:";
- //
- // WeightStatusLabel
- //
- this.WeightStatusLabel.Name = "WeightStatusLabel";
- this.WeightStatusLabel.Size = new System.Drawing.Size(29, 17);
- this.WeightStatusLabel.Text = "Вес:";
- //
- // ColorStatusLabel
- //
- this.ColorStatusLabel.Name = "ColorStatusLabel";
- this.ColorStatusLabel.Size = new System.Drawing.Size(36, 17);
- this.ColorStatusLabel.Text = "Цвет:";
+ this.buttonAddArtillery.Location = new System.Drawing.Point(13, 83);
+ this.buttonAddArtillery.Name = "buttonAddArtillery";
+ this.buttonAddArtillery.Size = new System.Drawing.Size(175, 32);
+ this.buttonAddArtillery.TabIndex = 20;
+ this.buttonAddArtillery.Text = "Добавить артиллерию";
+ this.buttonAddArtillery.UseVisualStyleBackColor = true;
+ this.buttonAddArtillery.Click += new System.EventHandler(this.buttonAddArtillery_Click);
//
// comboBoxSelectorMap
//
@@ -160,49 +119,98 @@
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта",
"Лесная карта"});
- this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
+ this.comboBoxSelectorMap.Location = new System.Drawing.Point(13, 22);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
- this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23);
- this.comboBoxSelectorMap.TabIndex = 16;
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
+ this.comboBoxSelectorMap.TabIndex = 19;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelectorMap_SelectedIndexChanged);
//
- // FormMap
+ // buttonRight
+ //
+ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRight.BackgroundImage = global::SelfPropelledArtilleryUnit.Properties.Resources.ArrowRight;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonRight.Location = new System.Drawing.Point(124, 399);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(30, 30);
+ this.buttonRight.TabIndex = 18;
+ 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::SelfPropelledArtilleryUnit.Properties.Resources.ArrowDown;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonDown.Location = new System.Drawing.Point(88, 399);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 17;
+ 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::SelfPropelledArtilleryUnit.Properties.Resources.ArrowUp;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonUp.Location = new System.Drawing.Point(88, 366);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ this.buttonUp.TabIndex = 16;
+ 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::SelfPropelledArtilleryUnit.Properties.Resources.ArrowLeft;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
+ this.buttonLeft.Location = new System.Drawing.Point(54, 399);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(30, 30);
+ this.buttonLeft.TabIndex = 15;
+ this.buttonLeft.UseVisualStyleBackColor = true;
+ this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
+ //
+ // pictureBoxArtilleries
+ //
+ this.pictureBoxArtilleries.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBoxArtilleries.Location = new System.Drawing.Point(0, 0);
+ this.pictureBoxArtilleries.Name = "pictureBoxArtilleries";
+ this.pictureBoxArtilleries.Size = new System.Drawing.Size(600, 450);
+ this.pictureBoxArtilleries.TabIndex = 1;
+ this.pictureBoxArtilleries.TabStop = false;
+ //
+ // FormMapWithSetArtilleries
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(624, 441);
- this.Controls.Add(this.comboBoxSelectorMap);
- this.Controls.Add(this.createAdvancedButton);
- this.Controls.Add(this.buttonRight);
- this.Controls.Add(this.buttonDown);
- this.Controls.Add(this.buttonUp);
- this.Controls.Add(this.buttonLeft);
- this.Controls.Add(this.buttonCreate);
+ this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.pictureBoxArtilleries);
- this.Controls.Add(this.statusStrip1);
- this.Name = "FormMap";
+ this.Controls.Add(this.toolsGroupBox);
+ this.Name = "FormMapWithSetArtilleries";
this.Text = "Artillery";
+ this.toolsGroupBox.ResumeLayout(false);
+ this.toolsGroupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxArtilleries)).EndInit();
- this.statusStrip1.ResumeLayout(false);
- this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
- this.PerformLayout();
}
#endregion
- private Button createAdvancedButton;
+ private GroupBox toolsGroupBox;
+ private PictureBox pictureBoxArtilleries;
private Button buttonRight;
private Button buttonDown;
private Button buttonUp;
private Button buttonLeft;
- private Button buttonCreate;
- private PictureBox pictureBoxArtilleries;
- private StatusStrip statusStrip1;
- private ToolStripStatusLabel SpeedStatusLabel;
- private ToolStripStatusLabel WeightStatusLabel;
- private ToolStripStatusLabel ColorStatusLabel;
private ComboBox comboBoxSelectorMap;
+ private Button buttonShowOnMap;
+ private Button buttonShowStorage;
+ private Button buttonRemoveArtillery;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Button buttonAddArtillery;
}
}
\ No newline at end of file
diff --git a/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.cs b/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.cs
new file mode 100644
index 0000000..a755fdd
--- /dev/null
+++ b/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.cs
@@ -0,0 +1,139 @@
+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 Artilleries
+{
+ public partial class FormMapWithSetArtilleries : Form
+ {
+ private MapWithSetArtilleriesGeneric
+_mapArtilleriesCollectionGeneric;
+
+ public FormMapWithSetArtilleries()
+ {
+ InitializeComponent();
+ }
+
+ private void comboBoxSelectorMap_SelectedIndexChanged(object sender,
+EventArgs e)
+ {
+ AbstractMap map = null;
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Простая карта":
+ map = new SimpleMap();
+ break;
+ case "Лесная карта":
+ map = new ForestMap();
+ break;
+ }
+ if (map != null)
+ {
+ _mapArtilleriesCollectionGeneric = new
+ MapWithSetArtilleriesGeneric(
+ pictureBoxArtilleries.Width, pictureBoxArtilleries.Height, map);
+ }
+ else
+ {
+ _mapArtilleriesCollectionGeneric = null;
+ }
+ }
+
+ private void buttonAddArtillery_Click(object sender, EventArgs e)
+ {
+ if (_mapArtilleriesCollectionGeneric == null)
+ {
+ return;
+ }
+ FormArtillery form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ DrawingObjectArtillery car = new(form.SelectedArtillery);
+ if (_mapArtilleriesCollectionGeneric + car)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+
+ private void buttonRemoveArtillery_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 (_mapArtilleriesCollectionGeneric - pos)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+
+ private void buttonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapArtilleriesCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowSet();
+ }
+
+ private void buttonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapArtilleriesCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.ShowOnMap();
+ }
+
+ private void buttonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapArtilleriesCollectionGeneric == 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;
+ }
+ pictureBoxArtilleries.Image = _mapArtilleriesCollectionGeneric.MoveObject(dir);
+ }
+ }
+}
diff --git a/SelfPropelledArtilleryUnit/FormMap.resx b/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.resx
similarity index 93%
rename from SelfPropelledArtilleryUnit/FormMap.resx
rename to SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.resx
index 5cb320f..f298a7b 100644
--- a/SelfPropelledArtilleryUnit/FormMap.resx
+++ b/SelfPropelledArtilleryUnit/FormMapWithSetArtilleries.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/SelfPropelledArtilleryUnit/MapWithArtilleriesGeneric.cs b/SelfPropelledArtilleryUnit/MapWithSetArtilleriesGeneric.cs
similarity index 85%
rename from SelfPropelledArtilleryUnit/MapWithArtilleriesGeneric.cs
rename to SelfPropelledArtilleryUnit/MapWithSetArtilleriesGeneric.cs
index 5c9d2c7..b1cddb9 100644
--- a/SelfPropelledArtilleryUnit/MapWithArtilleriesGeneric.cs
+++ b/SelfPropelledArtilleryUnit/MapWithSetArtilleriesGeneric.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Artilleries
{
- internal class MapWithArtilleriesGeneric
+ internal class MapWithSetArtilleriesGeneric
where T : class, IDrawingObject
where U : AbstractMap
{
@@ -17,7 +17,7 @@ namespace Artilleries
private readonly SetArtilleriesGeneric _setArtilleries;
private readonly U _map;
- public MapWithArtilleriesGeneric(int picWidth, int picHeight, U map)
+ public MapWithSetArtilleriesGeneric(int picWidth, int picHeight, U map)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
@@ -27,16 +27,25 @@ namespace Artilleries
_map = map;
}
- public static bool operator +(MapWithArtilleriesGeneric map, T artillery)
+ public static bool operator +(MapWithSetArtilleriesGeneric map, T artillery)
{
return map._setArtilleries.Insert(artillery); // TODO
}
- public static bool operator -(MapWithArtilleriesGeneric map, int position)
+ public static bool operator -(MapWithSetArtilleriesGeneric map, int position)
{
return map._setArtilleries.Remove(position); // TODO
}
+ public Bitmap ShowSet()
+ {
+ Bitmap bmp = new(_pictureWidth, _pictureHeight);
+ Graphics gr = Graphics.FromImage(bmp);
+ DrawBackground(gr);
+ DrawArtilleries(gr);
+ return bmp;
+ }
+
public Bitmap ShowOnMap()
{
Shaking();
diff --git a/SelfPropelledArtilleryUnit/Program.cs b/SelfPropelledArtilleryUnit/Program.cs
index 2b37e99..5f48e30 100644
--- a/SelfPropelledArtilleryUnit/Program.cs
+++ b/SelfPropelledArtilleryUnit/Program.cs
@@ -6,7 +6,7 @@ namespace Artilleries
static void Main()
{
ApplicationConfiguration.Initialize();
- Application.Run(new FormMap());
+ Application.Run(new FormMapWithSetArtilleries());
}
}
}
\ No newline at end of file