diff --git a/AircraftCarrier/AircraftCarrier/FormAircraftCarrier.Designer.cs b/AircraftCarrier/AircraftCarrier/FormAircraftCarrier.Designer.cs
index 918d3ea..37a1a63 100644
--- a/AircraftCarrier/AircraftCarrier/FormAircraftCarrier.Designer.cs
+++ b/AircraftCarrier/AircraftCarrier/FormAircraftCarrier.Designer.cs
@@ -39,6 +39,7 @@
this.buttonUp = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonCreateModif = new System.Windows.Forms.Button();
+ this.buttonSelectAircraftCarrier = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAircraftCarrier)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@@ -52,6 +53,7 @@
this.pictureBoxAircraftCarrier.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxAircraftCarrier.TabIndex = 0;
this.pictureBoxAircraftCarrier.TabStop = false;
+ //this.pictureBoxAircraftCarrier.Click += new System.EventHandler(this.PictureBoxAircraftCarrier_Click);
this.pictureBoxAircraftCarrier.Resize += new System.EventHandler(this.PictureBoxAircraftCarrier_Resize);
//
// statusStrip
@@ -153,11 +155,22 @@
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
//
+ // buttonSelectAircraftCarrier
+ //
+ this.buttonSelectAircraftCarrier.Location = new System.Drawing.Point(520, 380);
+ this.buttonSelectAircraftCarrier.Name = "buttonSelectAircraftCarrier";
+ this.buttonSelectAircraftCarrier.Size = new System.Drawing.Size(94, 29);
+ this.buttonSelectAircraftCarrier.TabIndex = 8;
+ this.buttonSelectAircraftCarrier.Text = "Выбрать";
+ this.buttonSelectAircraftCarrier.UseVisualStyleBackColor = true;
+ this.buttonSelectAircraftCarrier.Click += new System.EventHandler(this.ButtonSelectAircraftCarrier_Click);
+ //
// FormAircraftCarrier
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonSelectAircraftCarrier);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonUp);
@@ -190,5 +203,6 @@
private Button buttonUp;
private Button buttonDown;
private Button buttonCreateModif;
+ private Button buttonSelectAircraftCarrier;
}
}
\ No newline at end of file
diff --git a/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.Designer.cs b/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.Designer.cs
new file mode 100644
index 0000000..e8d1b4d
--- /dev/null
+++ b/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.Designer.cs
@@ -0,0 +1,208 @@
+namespace AircraftCarrier
+{
+ partial class FormMapWithSetAircraftCarriers
+ {
+ ///
+ /// 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.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonShowOnMap = new System.Windows.Forms.Button();
+ this.buttonShowStorage = new System.Windows.Forms.Button();
+ this.buttonRemoveAircraftCarrier = new System.Windows.Forms.Button();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonAddAircraftCarrier = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.buttonLeft);
+ this.groupBox1.Controls.Add(this.buttonDown);
+ this.groupBox1.Controls.Add(this.buttonUp);
+ this.groupBox1.Controls.Add(this.buttonRight);
+ this.groupBox1.Controls.Add(this.buttonShowOnMap);
+ this.groupBox1.Controls.Add(this.buttonShowStorage);
+ this.groupBox1.Controls.Add(this.buttonRemoveAircraftCarrier);
+ this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
+ this.groupBox1.Controls.Add(this.buttonAddAircraftCarrier);
+ this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
+ this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
+ this.groupBox1.Location = new System.Drawing.Point(550, 0);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(250, 450);
+ this.groupBox1.TabIndex = 0;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Инструменты";
+ //
+ // buttonLeft
+ //
+ //this.buttonLeft.BackgroundImage = global::AircraftCarrier.Properties.Resources.Left;
+ this.buttonLeft.Location = new System.Drawing.Point(61, 402);
+ 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);
+ //
+ // buttonDown
+ //
+ //this.buttonDown.BackgroundImage = global::AircraftCarrier.Properties.Resources.Down;
+ this.buttonDown.Location = new System.Drawing.Point(97, 402);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 10;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonUp
+ //
+ this.buttonUp.Location = new System.Drawing.Point(97, 366);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ this.buttonUp.TabIndex = 9;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonRight
+ //
+ this.buttonRight.Location = new System.Drawing.Point(133, 402);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(30, 30);
+ this.buttonRight.TabIndex = 8;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonShowOnMap
+ //
+ this.buttonShowOnMap.Location = new System.Drawing.Point(25, 321);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(184, 29);
+ this.buttonShowOnMap.TabIndex = 6;
+ this.buttonShowOnMap.Text = "Посмотреть карту";
+ this.buttonShowOnMap.UseVisualStyleBackColor = true;
+ this.buttonShowOnMap.Click += new System.EventHandler(this.buttonShowOnMap_Click);
+ //
+ // buttonShowStorage
+ //
+ this.buttonShowStorage.Location = new System.Drawing.Point(25, 280);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(184, 29);
+ this.buttonShowStorage.TabIndex = 5;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.buttonShowStorage_Click);
+ //
+ // buttonRemoveAircraftCarrier
+ //
+ this.buttonRemoveAircraftCarrier.Location = new System.Drawing.Point(25, 230);
+ this.buttonRemoveAircraftCarrier.Name = "buttonRemoveAircraftCarrier";
+ this.buttonRemoveAircraftCarrier.Size = new System.Drawing.Size(184, 29);
+ this.buttonRemoveAircraftCarrier.TabIndex = 4;
+ this.buttonRemoveAircraftCarrier.Text = "Удалить авианосец";
+ this.buttonRemoveAircraftCarrier.UseVisualStyleBackColor = true;
+ this.buttonRemoveAircraftCarrier.Click += new System.EventHandler(this.buttonRemoveAircraftCarrier_Click);
+ //
+ // maskedTextBoxPosition
+ //
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(25, 168);
+ this.maskedTextBoxPosition.Mask = "00";
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(184, 27);
+ this.maskedTextBoxPosition.TabIndex = 3;
+ //
+ // buttonAddAircraftCarrier
+ //
+ this.buttonAddAircraftCarrier.Location = new System.Drawing.Point(25, 110);
+ this.buttonAddAircraftCarrier.Name = "buttonAddAircraftCarrier";
+ this.buttonAddAircraftCarrier.Size = new System.Drawing.Size(184, 29);
+ this.buttonAddAircraftCarrier.TabIndex = 2;
+ this.buttonAddAircraftCarrier.Text = "Добавить авианосец";
+ this.buttonAddAircraftCarrier.UseVisualStyleBackColor = true;
+ this.buttonAddAircraftCarrier.Click += new System.EventHandler(this.ButtonAddAircraftCarrier_Click);
+ //
+ // comboBoxSelectorMap
+ //
+ this.comboBoxSelectorMap.FormattingEnabled = true;
+ this.comboBoxSelectorMap.Items.AddRange(new object[] {
+ "Простая карта",
+ "Сложная карта"});
+ this.comboBoxSelectorMap.Location = new System.Drawing.Point(25, 61);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(184, 28);
+ this.comboBoxSelectorMap.TabIndex = 0;
+ this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
+ this.comboBoxSelectorMap.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // pictureBox
+ //
+ this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBox.Location = new System.Drawing.Point(0, 0);
+ this.pictureBox.Name = "pictureBox";
+ this.pictureBox.Size = new System.Drawing.Size(550, 450);
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ //this.pictureBox.Click += new System.EventHandler(this.pictureBox1_Click);
+ //
+ // FormMapWithSetAircraftCarriers
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.pictureBox);
+ this.Controls.Add(this.groupBox1);
+ this.Name = "FormMapWithSetAircraftCarriers";
+ this.Text = "Карта с набором объектов";
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBox1;
+ private Button buttonLeft;
+ private Button buttonDown;
+ private Button buttonUp;
+ private Button buttonRight;
+ private Button buttonShowOnMap;
+ private Button buttonShowStorage;
+ private Button buttonRemoveAircraftCarrier;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Button buttonAddAircraftCarrier;
+ private ComboBox comboBoxSelectorMap;
+ private PictureBox pictureBox;
+ }
+}
\ No newline at end of file
diff --git a/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.cs b/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.cs
new file mode 100644
index 0000000..37d36e2
--- /dev/null
+++ b/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.cs
@@ -0,0 +1,134 @@
+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 AircraftCarrier
+{
+ public partial class FormMapWithSetAircraftCarriers : Form
+ {
+ private MapWithSetAircraftCarriersGeneric
+_mapAircraftCarriersCollectionGeneric;
+ ///
+ /// Конструктор
+ ///
+ public FormMapWithSetAircraftCarriers()
+ {
+ InitializeComponent();
+ }
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ AbstractMap map = null;
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Простая карта":
+ map = new SimpleMap();
+ break;
+ case "Сложная карта":
+ map = new ComplexMap();
+ break;
+ }
+ if (map != null)
+ {
+ _mapAircraftCarriersCollectionGeneric = new
+ MapWithSetAircraftCarriersGeneric(
+ pictureBox.Width, pictureBox.Height, map);
+ }
+ else
+ {
+ _mapAircraftCarriersCollectionGeneric = null;
+ }
+ }
+ private void ButtonAddAircraftCarrier_Click(object sender, EventArgs e)
+ {
+ if (_mapAircraftCarriersCollectionGeneric == null)
+ {
+ return;
+ }
+ FormAircraftCarrier form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ DrawningObjectAircraftCarrier aircraftcarrier = new(form.SelectedAircraftCarrier);
+ if ((_mapAircraftCarriersCollectionGeneric + aircraftcarrier) != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapAircraftCarriersCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+ private void buttonRemoveAircraftCarrier_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 (_mapAircraftCarriersCollectionGeneric - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _mapAircraftCarriersCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+ private void buttonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapAircraftCarriersCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapAircraftCarriersCollectionGeneric.ShowSet();
+ }
+ private void buttonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapAircraftCarriersCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapAircraftCarriersCollectionGeneric.ShowOnMap();
+ }
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapAircraftCarriersCollectionGeneric == 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;
+ }
+ pictureBox.Image = _mapAircraftCarriersCollectionGeneric.MoveObject(dir);
+ }
+ }
+}
\ No newline at end of file
diff --git a/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.resx b/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/AircraftCarrier/AircraftCarrier/FormMapWithSetAircraftCarriers.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