Compare commits
1 Commits
LabWork_04
...
LabWork_02
| Author | SHA1 | Date | |
|---|---|---|---|
| d8d55f9585 |
120
WarmlyShip/WarmlyShip/FormMapWithSetShip.Designer.cs
generated
120
WarmlyShip/WarmlyShip/FormMapWithSetShip.Designer.cs
generated
@@ -29,12 +29,6 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
this.groupBoxMaps = new System.Windows.Forms.GroupBox();
|
|
||||||
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
|
||||||
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
|
||||||
this.buttonAddMap = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
|
||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
@@ -44,15 +38,14 @@
|
|||||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||||
this.buttonRemoveShip = new System.Windows.Forms.Button();
|
this.buttonRemoveShip = new System.Windows.Forms.Button();
|
||||||
this.buttonAddShip = new System.Windows.Forms.Button();
|
this.buttonAddShip = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
this.groupBoxMaps.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
this.groupBox1.Controls.Add(this.groupBoxMaps);
|
|
||||||
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
||||||
this.groupBox1.Controls.Add(this.buttonDown);
|
this.groupBox1.Controls.Add(this.buttonDown);
|
||||||
this.groupBox1.Controls.Add(this.buttonLeft);
|
this.groupBox1.Controls.Add(this.buttonLeft);
|
||||||
@@ -62,81 +55,18 @@
|
|||||||
this.groupBox1.Controls.Add(this.buttonShowStorage);
|
this.groupBox1.Controls.Add(this.buttonShowStorage);
|
||||||
this.groupBox1.Controls.Add(this.buttonRemoveShip);
|
this.groupBox1.Controls.Add(this.buttonRemoveShip);
|
||||||
this.groupBox1.Controls.Add(this.buttonAddShip);
|
this.groupBox1.Controls.Add(this.buttonAddShip);
|
||||||
|
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
||||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBox1.Location = new System.Drawing.Point(815, 0);
|
this.groupBox1.Location = new System.Drawing.Point(600, 0);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.groupBox1.Name = "groupBox1";
|
||||||
this.groupBox1.Size = new System.Drawing.Size(200, 648);
|
this.groupBox1.Size = new System.Drawing.Size(200, 450);
|
||||||
this.groupBox1.TabIndex = 0;
|
this.groupBox1.TabIndex = 0;
|
||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Инструменты";
|
this.groupBox1.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// groupBoxMaps
|
|
||||||
//
|
|
||||||
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
|
|
||||||
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
|
||||||
this.groupBoxMaps.Controls.Add(this.buttonAddMap);
|
|
||||||
this.groupBoxMaps.Controls.Add(this.textBoxNewMapName);
|
|
||||||
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.groupBoxMaps.Location = new System.Drawing.Point(6, 22);
|
|
||||||
this.groupBoxMaps.Name = "groupBoxMaps";
|
|
||||||
this.groupBoxMaps.Size = new System.Drawing.Size(188, 244);
|
|
||||||
this.groupBoxMaps.TabIndex = 12;
|
|
||||||
this.groupBoxMaps.TabStop = false;
|
|
||||||
this.groupBoxMaps.Text = "Карта";
|
|
||||||
//
|
|
||||||
// buttonDeleteMap
|
|
||||||
//
|
|
||||||
this.buttonDeleteMap.Location = new System.Drawing.Point(6, 209);
|
|
||||||
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
|
||||||
this.buttonDeleteMap.Size = new System.Drawing.Size(176, 23);
|
|
||||||
this.buttonDeleteMap.TabIndex = 3;
|
|
||||||
this.buttonDeleteMap.Text = "Удалить карту";
|
|
||||||
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
|
||||||
//
|
|
||||||
// listBoxMaps
|
|
||||||
//
|
|
||||||
this.listBoxMaps.FormattingEnabled = true;
|
|
||||||
this.listBoxMaps.ItemHeight = 15;
|
|
||||||
this.listBoxMaps.Location = new System.Drawing.Point(6, 109);
|
|
||||||
this.listBoxMaps.Name = "listBoxMaps";
|
|
||||||
this.listBoxMaps.Size = new System.Drawing.Size(176, 94);
|
|
||||||
this.listBoxMaps.TabIndex = 2;
|
|
||||||
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// buttonAddMap
|
|
||||||
//
|
|
||||||
this.buttonAddMap.Location = new System.Drawing.Point(6, 80);
|
|
||||||
this.buttonAddMap.Name = "buttonAddMap";
|
|
||||||
this.buttonAddMap.Size = new System.Drawing.Size(176, 23);
|
|
||||||
this.buttonAddMap.TabIndex = 1;
|
|
||||||
this.buttonAddMap.Text = "Добавить карту";
|
|
||||||
this.buttonAddMap.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
|
||||||
//
|
|
||||||
// textBoxNewMapName
|
|
||||||
//
|
|
||||||
this.textBoxNewMapName.Location = new System.Drawing.Point(6, 22);
|
|
||||||
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
|
||||||
this.textBoxNewMapName.Size = new System.Drawing.Size(176, 23);
|
|
||||||
this.textBoxNewMapName.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
|
||||||
"Простая карта",
|
|
||||||
"Вторая карта",
|
|
||||||
"Последняя карта"});
|
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 51);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(176, 23);
|
|
||||||
this.comboBoxSelectorMap.TabIndex = 0;
|
|
||||||
//this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 345);
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 116);
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(188, 23);
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(188, 23);
|
||||||
@@ -147,7 +77,7 @@
|
|||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonDown.BackgroundImage = global::WarmlyShip.Properties.Resources.todown;
|
this.buttonDown.BackgroundImage = global::WarmlyShip.Properties.Resources.todown;
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonDown.Location = new System.Drawing.Point(75, 589);
|
this.buttonDown.Location = new System.Drawing.Point(75, 391);
|
||||||
this.buttonDown.Name = "buttonDown";
|
this.buttonDown.Name = "buttonDown";
|
||||||
this.buttonDown.Size = new System.Drawing.Size(50, 50);
|
this.buttonDown.Size = new System.Drawing.Size(50, 50);
|
||||||
this.buttonDown.TabIndex = 10;
|
this.buttonDown.TabIndex = 10;
|
||||||
@@ -159,7 +89,7 @@
|
|||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonLeft.BackgroundImage = global::WarmlyShip.Properties.Resources.toleft;
|
this.buttonLeft.BackgroundImage = global::WarmlyShip.Properties.Resources.toleft;
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(19, 589);
|
this.buttonLeft.Location = new System.Drawing.Point(19, 391);
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(50, 50);
|
this.buttonLeft.Size = new System.Drawing.Size(50, 50);
|
||||||
this.buttonLeft.TabIndex = 9;
|
this.buttonLeft.TabIndex = 9;
|
||||||
@@ -171,7 +101,7 @@
|
|||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonUp.BackgroundImage = global::WarmlyShip.Properties.Resources.totop;
|
this.buttonUp.BackgroundImage = global::WarmlyShip.Properties.Resources.totop;
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonUp.Location = new System.Drawing.Point(75, 533);
|
this.buttonUp.Location = new System.Drawing.Point(75, 335);
|
||||||
this.buttonUp.Name = "buttonUp";
|
this.buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(50, 50);
|
this.buttonUp.Size = new System.Drawing.Size(50, 50);
|
||||||
this.buttonUp.TabIndex = 8;
|
this.buttonUp.TabIndex = 8;
|
||||||
@@ -183,7 +113,7 @@
|
|||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonRight.BackgroundImage = global::WarmlyShip.Properties.Resources.toright;
|
this.buttonRight.BackgroundImage = global::WarmlyShip.Properties.Resources.toright;
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonRight.Location = new System.Drawing.Point(131, 589);
|
this.buttonRight.Location = new System.Drawing.Point(131, 391);
|
||||||
this.buttonRight.Name = "buttonRight";
|
this.buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(50, 50);
|
this.buttonRight.Size = new System.Drawing.Size(50, 50);
|
||||||
this.buttonRight.TabIndex = 7;
|
this.buttonRight.TabIndex = 7;
|
||||||
@@ -192,7 +122,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(6, 432);
|
this.buttonShowOnMap.Location = new System.Drawing.Point(6, 281);
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(188, 23);
|
this.buttonShowOnMap.Size = new System.Drawing.Size(188, 23);
|
||||||
this.buttonShowOnMap.TabIndex = 5;
|
this.buttonShowOnMap.TabIndex = 5;
|
||||||
@@ -202,7 +132,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowStorage
|
// buttonShowStorage
|
||||||
//
|
//
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(6, 403);
|
this.buttonShowStorage.Location = new System.Drawing.Point(6, 226);
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(188, 23);
|
this.buttonShowStorage.Size = new System.Drawing.Size(188, 23);
|
||||||
this.buttonShowStorage.TabIndex = 4;
|
this.buttonShowStorage.TabIndex = 4;
|
||||||
@@ -212,7 +142,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRemoveShip
|
// buttonRemoveShip
|
||||||
//
|
//
|
||||||
this.buttonRemoveShip.Location = new System.Drawing.Point(6, 374);
|
this.buttonRemoveShip.Location = new System.Drawing.Point(6, 170);
|
||||||
this.buttonRemoveShip.Name = "buttonRemoveShip";
|
this.buttonRemoveShip.Name = "buttonRemoveShip";
|
||||||
this.buttonRemoveShip.Size = new System.Drawing.Size(188, 23);
|
this.buttonRemoveShip.Size = new System.Drawing.Size(188, 23);
|
||||||
this.buttonRemoveShip.TabIndex = 3;
|
this.buttonRemoveShip.TabIndex = 3;
|
||||||
@@ -222,7 +152,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAddShip
|
// buttonAddShip
|
||||||
//
|
//
|
||||||
this.buttonAddShip.Location = new System.Drawing.Point(6, 316);
|
this.buttonAddShip.Location = new System.Drawing.Point(6, 65);
|
||||||
this.buttonAddShip.Name = "buttonAddShip";
|
this.buttonAddShip.Name = "buttonAddShip";
|
||||||
this.buttonAddShip.Size = new System.Drawing.Size(188, 23);
|
this.buttonAddShip.Size = new System.Drawing.Size(188, 23);
|
||||||
this.buttonAddShip.TabIndex = 1;
|
this.buttonAddShip.TabIndex = 1;
|
||||||
@@ -230,12 +160,25 @@
|
|||||||
this.buttonAddShip.UseVisualStyleBackColor = true;
|
this.buttonAddShip.UseVisualStyleBackColor = true;
|
||||||
this.buttonAddShip.Click += new System.EventHandler(this.ButtonAddShip_Click);
|
this.buttonAddShip.Click += new System.EventHandler(this.ButtonAddShip_Click);
|
||||||
//
|
//
|
||||||
|
// comboBoxSelectorMap
|
||||||
|
//
|
||||||
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
|
"Простая карта",
|
||||||
|
"Вторая карта",
|
||||||
|
"Последняя карта"});
|
||||||
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 22);
|
||||||
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(188, 23);
|
||||||
|
this.comboBoxSelectorMap.TabIndex = 0;
|
||||||
|
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||||
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.pictureBox.Name = "pictureBox";
|
this.pictureBox.Name = "pictureBox";
|
||||||
this.pictureBox.Size = new System.Drawing.Size(815, 648);
|
this.pictureBox.Size = new System.Drawing.Size(600, 450);
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
@@ -243,15 +186,13 @@
|
|||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1015, 648);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Name = "FormMapWithSetShip";
|
this.Name = "FormMapWithSetShip";
|
||||||
this.Text = "FormMapWithSetShip";
|
this.Text = "FormMapWithSetShip";
|
||||||
this.groupBox1.ResumeLayout(false);
|
this.groupBox1.ResumeLayout(false);
|
||||||
this.groupBox1.PerformLayout();
|
this.groupBox1.PerformLayout();
|
||||||
this.groupBoxMaps.ResumeLayout(false);
|
|
||||||
this.groupBoxMaps.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
@@ -271,10 +212,5 @@
|
|||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
private GroupBox groupBoxMaps;
|
|
||||||
private Button buttonDeleteMap;
|
|
||||||
private ListBox listBoxMaps;
|
|
||||||
private Button buttonAddMap;
|
|
||||||
private TextBox textBoxNewMapName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,88 +8,46 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using WarmlyShip;
|
using WarmlyShip;
|
||||||
using static System.Windows.Forms.DataFormats;
|
|
||||||
|
|
||||||
namespace WarmlyShip
|
namespace WarmlyShip
|
||||||
{
|
{
|
||||||
public partial class FormMapWithSetShip : Form
|
public partial class FormMapWithSetShip : Form
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
private MapWithSetShipGeneric<DrawningObjectShip, AbstractMap> _mapShipCollectionGeneric;
|
||||||
{
|
public bool ShipOnMap = false;
|
||||||
{ "Простая карта", new SimpleMap() },
|
|
||||||
{ "Вторая карта", new SecondMap() },
|
|
||||||
{ "Последняя карта", new LastMap() }
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly MapsCollection _mapsCollection;
|
|
||||||
|
|
||||||
public FormMapWithSetShip()
|
public FormMapWithSetShip()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
|
||||||
comboBoxSelectorMap.Items.Clear();
|
|
||||||
foreach (var elem in _mapsDict)
|
|
||||||
{
|
|
||||||
comboBoxSelectorMap.Items.Add(elem.Key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadMaps()
|
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
int index = listBoxMaps.SelectedIndex;
|
AbstractMap map = null;
|
||||||
listBoxMaps.Items.Clear();
|
switch (comboBoxSelectorMap.Text)
|
||||||
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
|
||||||
{
|
{
|
||||||
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
case "Простая карта":
|
||||||
|
map = new SimpleMap();
|
||||||
|
break;
|
||||||
|
case "Вторая карта":
|
||||||
|
map = new SecondMap();
|
||||||
|
break;
|
||||||
|
case "Последняя карта":
|
||||||
|
map = new LastMap();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
if (map != null)
|
||||||
{
|
{
|
||||||
listBoxMaps.SelectedIndex = 0;
|
_mapShipCollectionGeneric = new MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
||||||
}
|
}
|
||||||
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
else
|
||||||
{
|
{
|
||||||
listBoxMaps.SelectedIndex = index;
|
_mapShipCollectionGeneric = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
|
||||||
ReloadMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ??
|
|
||||||
string.Empty);
|
|
||||||
ReloadMaps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
if (_mapShipCollectionGeneric == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -97,10 +55,10 @@ namespace WarmlyShip
|
|||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
DrawningObjectShip ship = new(form.SelectedShip);
|
DrawningObjectShip ship = new(form.SelectedShip);
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + ship > -1)
|
if (_mapShipCollectionGeneric + ship > -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -111,10 +69,6 @@ namespace WarmlyShip
|
|||||||
|
|
||||||
private void ButtonRemoveShip_Click(object sender, EventArgs e)
|
private void ButtonRemoveShip_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -124,11 +78,10 @@ namespace WarmlyShip
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
if (_mapShipCollectionGeneric - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image =
|
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||||
_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -138,25 +91,27 @@ namespace WarmlyShip
|
|||||||
|
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
if (_mapShipCollectionGeneric == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||||
|
ShipOnMap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
if (_mapShipCollectionGeneric == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
pictureBox.Image = _mapShipCollectionGeneric.ShowOnMap();
|
||||||
|
ShipOnMap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
if (_mapShipCollectionGeneric == null || !ShipOnMap)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -178,7 +133,7 @@ namespace WarmlyShip
|
|||||||
dir = Direction.Right;
|
dir = Direction.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
pictureBox.Image = _mapShipCollectionGeneric.MoveObject(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,13 @@ namespace WarmlyShip
|
|||||||
public Bitmap ShowOnMap()
|
public Bitmap ShowOnMap()
|
||||||
{
|
{
|
||||||
Shaking();
|
Shaking();
|
||||||
foreach (var ship in _setShips.GetShips())
|
for (int i = 0; i < _setShips.Count; i++)
|
||||||
{
|
{
|
||||||
return _map.CreateMap(_pictureWidth, _pictureHeight, ship);
|
var ship = _setShips.Get(i);
|
||||||
|
if (ship != null)
|
||||||
|
{
|
||||||
|
return _map.CreateMap(_pictureWidth, _pictureHeight, ship);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new(_pictureWidth, _pictureHeight);
|
return new(_pictureWidth, _pictureHeight);
|
||||||
}
|
}
|
||||||
@@ -70,11 +74,11 @@ namespace WarmlyShip
|
|||||||
int j = _setShips.Count - 1;
|
int j = _setShips.Count - 1;
|
||||||
for (int i = 0; i < _setShips.Count; ++i)
|
for (int i = 0; i < _setShips.Count; ++i)
|
||||||
{
|
{
|
||||||
if (_setShips[i] == null)
|
if (_setShips.Get(i) == null)
|
||||||
{
|
{
|
||||||
for (; j > i; --j)
|
for (; j > i; --j)
|
||||||
{
|
{
|
||||||
var car = _setShips[j];
|
var car = _setShips.Get(j);
|
||||||
if (car != null)
|
if (car != null)
|
||||||
{
|
{
|
||||||
_setShips.Insert(car, i);
|
_setShips.Insert(car, i);
|
||||||
@@ -107,28 +111,15 @@ namespace WarmlyShip
|
|||||||
|
|
||||||
private void DrawShips(Graphics g)
|
private void DrawShips(Graphics g)
|
||||||
{
|
{
|
||||||
/*for (int i = 0; i < _setShips.Count; ++i)
|
for (int i = 0; i < _setShips.Count; ++i)
|
||||||
{
|
{
|
||||||
if (_setShips[i] != null )
|
if (_setShips.Get(i) != null )
|
||||||
{
|
{
|
||||||
int temp = 0;
|
int temp = 0;
|
||||||
if (_setShips[i].GetCurrentPosition().Bottom - _setShips[i].GetCurrentPosition().Top < 75) temp = (int)(_setShips[i].GetCurrentPosition().Bottom - _setShips[i].GetCurrentPosition().Top);
|
if (_setShips.Get(i).GetCurrentPosition().Bottom - _setShips.Get(i).GetCurrentPosition().Top < 75) temp = (int)(_setShips.Get(i).GetCurrentPosition().Bottom - _setShips.Get(i).GetCurrentPosition().Top);
|
||||||
_setShips[i].SetObject((_pictureWidth / _placeSizeWidth - (i % (_pictureWidth / _placeSizeWidth)) - 1) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight + temp, _pictureWidth, _pictureHeight);
|
_setShips.Get(i).SetObject((_pictureWidth / _placeSizeWidth - (i % (_pictureWidth / _placeSizeWidth)) - 1) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight + temp, _pictureWidth, _pictureHeight);
|
||||||
_setShips[i].DrawningObject(g);
|
_setShips.Get(i).DrawningObject(g);
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
foreach (var ship in _setShips.GetShips())
|
|
||||||
{
|
|
||||||
if (ship != null)
|
|
||||||
{
|
|
||||||
int temp = 0;
|
|
||||||
if (ship.GetCurrentPosition().Bottom - ship.GetCurrentPosition().Top < 75) temp = (int)(ship.GetCurrentPosition().Bottom - ship.GetCurrentPosition().Top);
|
|
||||||
ship.SetObject((_pictureWidth / _placeSizeWidth - (i % (_pictureWidth / _placeSizeWidth)) - 1) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight + temp, _pictureWidth, _pictureHeight);
|
|
||||||
ship.DrawningObject(g);
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace WarmlyShip
|
|
||||||
{
|
|
||||||
internal class MapsCollection
|
|
||||||
{
|
|
||||||
readonly Dictionary<string, MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>> _mapStorages;
|
|
||||||
|
|
||||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
|
||||||
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
|
|
||||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
|
||||||
{
|
|
||||||
_mapStorages = new Dictionary<string, MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>>();
|
|
||||||
_pictureWidth = pictureWidth;
|
|
||||||
_pictureHeight = pictureHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddMap(string name, AbstractMap map)
|
|
||||||
{
|
|
||||||
if (_mapStorages.ContainsKey(name)) return;
|
|
||||||
_mapStorages.Add(name, new MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DelMap(string name)
|
|
||||||
{
|
|
||||||
if (!_mapStorages.ContainsKey(name)) return;
|
|
||||||
_mapStorages.Remove(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapWithSetShipGeneric<DrawningObjectShip, AbstractMap> this[string ind]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if(_mapStorages.ContainsKey(ind)) return _mapStorages[ind];
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,15 +9,19 @@ namespace WarmlyShip
|
|||||||
internal class SetShipGeneric<T>
|
internal class SetShipGeneric<T>
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
private readonly List<T> _places;
|
private readonly T[] _places;
|
||||||
public int Count => _places.Count;
|
public int Count => _places.Length;
|
||||||
|
|
||||||
private readonly int _maxCount;
|
|
||||||
|
|
||||||
public SetShipGeneric(int count)
|
public SetShipGeneric(int count)
|
||||||
{
|
{
|
||||||
_maxCount = count;
|
_places = new T[count];
|
||||||
_places = new List<T>();
|
}
|
||||||
|
|
||||||
|
private bool CanInsert(int position)
|
||||||
|
{
|
||||||
|
for (int i = position; i < _places.Length; ++i)
|
||||||
|
if (_places[i] == null) return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T ship)
|
public int Insert(T ship)
|
||||||
@@ -27,8 +31,19 @@ namespace WarmlyShip
|
|||||||
|
|
||||||
public int Insert(T ship, int position)
|
public int Insert(T ship, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > Count || Count == _maxCount) return -1;
|
if (position < 0 || position > _places.Length) return -1;
|
||||||
_places.Insert(position, ship);
|
if (_places[position] != null && CanInsert(position))
|
||||||
|
{
|
||||||
|
for (int i = _places.Length - 1; i > position; --i)
|
||||||
|
{
|
||||||
|
if (_places[i] == null)
|
||||||
|
{
|
||||||
|
_places[i] = _places[i - 1];
|
||||||
|
_places[i - 1] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_places[position] = ship;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,33 +54,10 @@ namespace WarmlyShip
|
|||||||
return DelElement;
|
return DelElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T this[int position]
|
public T Get(int position)
|
||||||
{
|
{
|
||||||
get
|
if (position < 0 || position > _places.Length) return null;
|
||||||
{
|
return _places[position];
|
||||||
if (position < 0 || position > Count) return null;
|
|
||||||
return _places[position];
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Insert(value, position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public IEnumerable<T> GetShips()
|
|
||||||
{
|
|
||||||
foreach (var ship in _places)
|
|
||||||
{
|
|
||||||
if (ship != null)
|
|
||||||
{
|
|
||||||
yield return ship;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user