Лабораторная работа №4, исправленны недочеты.
This commit is contained in:
parent
1bf55f260e
commit
44408586b5
119
Warship/Warship/FormMapWithSetWarships.Designer.cs
generated
119
Warship/Warship/FormMapWithSetWarships.Designer.cs
generated
@ -29,6 +29,11 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.groupBoxTools = new System.Windows.Forms.GroupBox();
|
this.groupBoxTools = 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.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
this.buttonRemoveWarship = new System.Windows.Forms.Button();
|
this.buttonRemoveWarship = new System.Windows.Forms.Button();
|
||||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||||
@ -38,14 +43,16 @@
|
|||||||
this.buttonUp = new System.Windows.Forms.Button();
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||||
this.buttonAddWarship = new System.Windows.Forms.Button();
|
this.buttonAddWarship = 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.textBoxMap = new System.Windows.Forms.TextBox();
|
||||||
this.groupBoxTools.SuspendLayout();
|
this.groupBoxTools.SuspendLayout();
|
||||||
|
this.groupBoxMaps.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
|
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
||||||
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonRemoveWarship);
|
this.groupBoxTools.Controls.Add(this.buttonRemoveWarship);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
|
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
|
||||||
@ -55,18 +62,73 @@
|
|||||||
this.groupBoxTools.Controls.Add(this.buttonUp);
|
this.groupBoxTools.Controls.Add(this.buttonUp);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
|
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
|
||||||
this.groupBoxTools.Controls.Add(this.buttonAddWarship);
|
this.groupBoxTools.Controls.Add(this.buttonAddWarship);
|
||||||
this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBoxTools.Location = new System.Drawing.Point(811, 0);
|
this.groupBoxTools.Location = new System.Drawing.Point(859, 0);
|
||||||
this.groupBoxTools.Name = "groupBoxTools";
|
this.groupBoxTools.Name = "groupBoxTools";
|
||||||
this.groupBoxTools.Size = new System.Drawing.Size(204, 554);
|
this.groupBoxTools.Size = new System.Drawing.Size(204, 652);
|
||||||
this.groupBoxTools.TabIndex = 0;
|
this.groupBoxTools.TabIndex = 0;
|
||||||
this.groupBoxTools.TabStop = false;
|
this.groupBoxTools.TabStop = false;
|
||||||
this.groupBoxTools.Text = "Инструменты";
|
this.groupBoxTools.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
|
// groupBoxMaps
|
||||||
|
//
|
||||||
|
this.groupBoxMaps.Controls.Add(this.textBoxMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.ButtonDeleteMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.ButtonAddMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||||
|
this.groupBoxMaps.Location = new System.Drawing.Point(10, 22);
|
||||||
|
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||||
|
this.groupBoxMaps.Size = new System.Drawing.Size(188, 266);
|
||||||
|
this.groupBoxMaps.TabIndex = 11;
|
||||||
|
this.groupBoxMaps.TabStop = false;
|
||||||
|
this.groupBoxMaps.Text = "Карты";
|
||||||
|
//
|
||||||
|
// ButtonDeleteMap
|
||||||
|
//
|
||||||
|
this.ButtonDeleteMap.Location = new System.Drawing.Point(12, 223);
|
||||||
|
this.ButtonDeleteMap.Name = "ButtonDeleteMap";
|
||||||
|
this.ButtonDeleteMap.Size = new System.Drawing.Size(168, 33);
|
||||||
|
this.ButtonDeleteMap.TabIndex = 4;
|
||||||
|
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(10, 118);
|
||||||
|
this.listBoxMaps.Name = "listBoxMaps";
|
||||||
|
this.listBoxMaps.Size = new System.Drawing.Size(170, 94);
|
||||||
|
this.listBoxMaps.TabIndex = 3;
|
||||||
|
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// ButtonAddMap
|
||||||
|
//
|
||||||
|
this.ButtonAddMap.Location = new System.Drawing.Point(8, 79);
|
||||||
|
this.ButtonAddMap.Name = "ButtonAddMap";
|
||||||
|
this.ButtonAddMap.Size = new System.Drawing.Size(174, 35);
|
||||||
|
this.ButtonAddMap.TabIndex = 2;
|
||||||
|
this.ButtonAddMap.Text = "Добавить карту";
|
||||||
|
this.ButtonAddMap.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||||
|
//
|
||||||
|
// comboBoxSelectorMap
|
||||||
|
//
|
||||||
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
|
"Первая карта",
|
||||||
|
"Вторая карта"});
|
||||||
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(7, 50);
|
||||||
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
||||||
|
this.comboBoxSelectorMap.TabIndex = 0;
|
||||||
|
//
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 166);
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(15, 358);
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
||||||
@ -75,7 +137,7 @@
|
|||||||
//
|
//
|
||||||
// buttonRemoveWarship
|
// buttonRemoveWarship
|
||||||
//
|
//
|
||||||
this.buttonRemoveWarship.Location = new System.Drawing.Point(17, 195);
|
this.buttonRemoveWarship.Location = new System.Drawing.Point(15, 387);
|
||||||
this.buttonRemoveWarship.Name = "buttonRemoveWarship";
|
this.buttonRemoveWarship.Name = "buttonRemoveWarship";
|
||||||
this.buttonRemoveWarship.Size = new System.Drawing.Size(175, 35);
|
this.buttonRemoveWarship.Size = new System.Drawing.Size(175, 35);
|
||||||
this.buttonRemoveWarship.TabIndex = 3;
|
this.buttonRemoveWarship.TabIndex = 3;
|
||||||
@ -85,7 +147,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowStorage
|
// buttonShowStorage
|
||||||
//
|
//
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(17, 287);
|
this.buttonShowStorage.Location = new System.Drawing.Point(15, 452);
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(175, 35);
|
this.buttonShowStorage.Size = new System.Drawing.Size(175, 35);
|
||||||
this.buttonShowStorage.TabIndex = 4;
|
this.buttonShowStorage.TabIndex = 4;
|
||||||
@ -98,7 +160,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::Warship.Properties.Resources.arrowDown;
|
this.buttonDown.BackgroundImage = global::Warship.Properties.Resources.arrowDown;
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonDown.Location = new System.Drawing.Point(91, 504);
|
this.buttonDown.Location = new System.Drawing.Point(91, 602);
|
||||||
this.buttonDown.Name = "buttonDown";
|
this.buttonDown.Name = "buttonDown";
|
||||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonDown.TabIndex = 10;
|
this.buttonDown.TabIndex = 10;
|
||||||
@ -110,7 +172,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::Warship.Properties.Resources.arrowRight;
|
this.buttonRight.BackgroundImage = global::Warship.Properties.Resources.arrowRight;
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonRight.Location = new System.Drawing.Point(127, 504);
|
this.buttonRight.Location = new System.Drawing.Point(127, 602);
|
||||||
this.buttonRight.Name = "buttonRight";
|
this.buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonRight.TabIndex = 9;
|
this.buttonRight.TabIndex = 9;
|
||||||
@ -122,7 +184,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::Warship.Properties.Resources.arrowLeft;
|
this.buttonLeft.BackgroundImage = global::Warship.Properties.Resources.arrowLeft;
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(55, 504);
|
this.buttonLeft.Location = new System.Drawing.Point(55, 602);
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonLeft.TabIndex = 8;
|
this.buttonLeft.TabIndex = 8;
|
||||||
@ -134,7 +196,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::Warship.Properties.Resources.arrowUp;
|
this.buttonUp.BackgroundImage = global::Warship.Properties.Resources.arrowUp;
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonUp.Location = new System.Drawing.Point(91, 468);
|
this.buttonUp.Location = new System.Drawing.Point(91, 566);
|
||||||
this.buttonUp.Name = "buttonUp";
|
this.buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||||
this.buttonUp.TabIndex = 7;
|
this.buttonUp.TabIndex = 7;
|
||||||
@ -143,7 +205,7 @@
|
|||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
this.buttonShowOnMap.Location = new System.Drawing.Point(17, 391);
|
this.buttonShowOnMap.Location = new System.Drawing.Point(15, 493);
|
||||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35);
|
this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35);
|
||||||
this.buttonShowOnMap.TabIndex = 5;
|
this.buttonShowOnMap.TabIndex = 5;
|
||||||
@ -153,7 +215,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAddWarship
|
// buttonAddWarship
|
||||||
//
|
//
|
||||||
this.buttonAddWarship.Location = new System.Drawing.Point(17, 106);
|
this.buttonAddWarship.Location = new System.Drawing.Point(15, 317);
|
||||||
this.buttonAddWarship.Name = "buttonAddWarship";
|
this.buttonAddWarship.Name = "buttonAddWarship";
|
||||||
this.buttonAddWarship.Size = new System.Drawing.Size(175, 35);
|
this.buttonAddWarship.Size = new System.Drawing.Size(175, 35);
|
||||||
this.buttonAddWarship.TabIndex = 1;
|
this.buttonAddWarship.TabIndex = 1;
|
||||||
@ -161,39 +223,35 @@
|
|||||||
this.buttonAddWarship.UseVisualStyleBackColor = true;
|
this.buttonAddWarship.UseVisualStyleBackColor = true;
|
||||||
this.buttonAddWarship.Click += new System.EventHandler(this.ButtonAddWarship_Click);
|
this.buttonAddWarship.Click += new System.EventHandler(this.ButtonAddWarship_Click);
|
||||||
//
|
//
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
|
||||||
"Первая карта",
|
|
||||||
"Вторая карта"});
|
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(17, 32);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 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(811, 554);
|
this.pictureBox.Size = new System.Drawing.Size(859, 652);
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// textBoxMap
|
||||||
|
//
|
||||||
|
this.textBoxMap.Location = new System.Drawing.Point(5, 21);
|
||||||
|
this.textBoxMap.Name = "textBoxMap";
|
||||||
|
this.textBoxMap.Size = new System.Drawing.Size(175, 23);
|
||||||
|
this.textBoxMap.TabIndex = 12;
|
||||||
|
//
|
||||||
// FormMapWithSetWarships
|
// FormMapWithSetWarships
|
||||||
//
|
//
|
||||||
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, 554);
|
this.ClientSize = new System.Drawing.Size(1063, 652);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.groupBoxTools);
|
this.Controls.Add(this.groupBoxTools);
|
||||||
this.Name = "FormMapWithSetWarships";
|
this.Name = "FormMapWithSetWarships";
|
||||||
this.Text = "Карта с набором объектов";
|
this.Text = "Карта с набором объектов";
|
||||||
this.groupBoxTools.ResumeLayout(false);
|
this.groupBoxTools.ResumeLayout(false);
|
||||||
this.groupBoxTools.PerformLayout();
|
this.groupBoxTools.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);
|
||||||
|
|
||||||
@ -213,5 +271,10 @@
|
|||||||
private Button buttonShowStorage;
|
private Button buttonShowStorage;
|
||||||
private Button buttonRemoveWarship;
|
private Button buttonRemoveWarship;
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
|
private GroupBox groupBoxMaps;
|
||||||
|
private Button ButtonDeleteMap;
|
||||||
|
private ListBox listBoxMaps;
|
||||||
|
private Button ButtonAddMap;
|
||||||
|
private TextBox textBoxMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,40 +12,46 @@ namespace Warship
|
|||||||
{
|
{
|
||||||
public partial class FormMapWithSetWarships : Form
|
public partial class FormMapWithSetWarships : Form
|
||||||
{
|
{
|
||||||
private MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap> _mapWarshipsCollectionGeneric;
|
|
||||||
|
private readonly Dictionary<string, AbstractMap> _mapDict = new()
|
||||||
|
{
|
||||||
|
{"Первая карта",new SimpleMap() },
|
||||||
|
{"Вторая карта",new SecondMap() }
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly MapsCollection _mapsCollection;
|
||||||
|
|
||||||
public FormMapWithSetWarships()
|
public FormMapWithSetWarships()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||||
|
comboBoxSelectorMap.Items.Clear();
|
||||||
|
foreach(var elem in _mapDict)
|
||||||
|
{
|
||||||
|
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
private void ReloadMaps()
|
||||||
{
|
{
|
||||||
AbstractMap map = null;
|
int index = listBoxMaps.SelectedIndex;
|
||||||
|
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||||
switch (comboBoxSelectorMap.Text)
|
|
||||||
{
|
{
|
||||||
case "Первая карта":
|
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||||
map = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Вторая карта":
|
|
||||||
map = new SecondMap();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (map != null)
|
if (listBoxMaps.Items.Count>0&& (index == -1 || index >= listBoxMaps.Items.Count))
|
||||||
{
|
{
|
||||||
_mapWarshipsCollectionGeneric = new MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>(
|
listBoxMaps.SelectedIndex = 0;
|
||||||
pictureBox.Width, pictureBox.Height, map);
|
|
||||||
}
|
}
|
||||||
else
|
else if (listBoxMaps.Items.Count>0&&index>-1 && index < listBoxMaps.Items.Count)
|
||||||
{
|
{
|
||||||
_mapWarshipsCollectionGeneric = null;
|
listBoxMaps.SelectedIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAddWarship_Click(object sender, EventArgs e)
|
private void ButtonAddWarship_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapWarshipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex==-1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -53,10 +59,10 @@ namespace Warship
|
|||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
DrawingObjectWarship warship = new(form.SelectedWarship);
|
DrawingObjectWarship warship = new(form.SelectedWarship);
|
||||||
if (_mapWarshipsCollectionGeneric + warship>=0)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString()??string.Empty]+warship!=-1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -67,6 +73,10 @@ namespace Warship
|
|||||||
|
|
||||||
private void ButtonRemoveWarship_Click(object sender, EventArgs e)
|
private void ButtonRemoveWarship_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -76,10 +86,10 @@ namespace Warship
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_mapWarshipsCollectionGeneric - pos !=null)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos !=null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -89,25 +99,25 @@ namespace Warship
|
|||||||
|
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapWarshipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapWarshipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.ShowOnMap();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapWarshipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -128,7 +138,43 @@ namespace Warship
|
|||||||
dir = Direction.Right;
|
dir = Direction.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapWarshipsCollectionGeneric.MoveObject(dir);
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAddMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxMap.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_mapDict.ContainsKey(comboBoxSelectorMap.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
listBoxMaps.Items.Clear();
|
||||||
|
_mapsCollection.AddMap(textBoxMap.Text, _mapDict[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);
|
||||||
|
listBoxMaps.Items.Clear();
|
||||||
|
ReloadMaps();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,14 +110,13 @@ namespace Warship
|
|||||||
//todo
|
//todo
|
||||||
int width = _pictureWidth / _placeSizeWidth;
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
int height = _pictureHeight / _placeSizeHeight;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
int i= 0;
|
||||||
|
|
||||||
for (int i = 0; i < _setWarship.Count; i++)
|
foreach(var warship in _setWarship.GetWarships())
|
||||||
{
|
{
|
||||||
if (_setWarship[i] != null)
|
warship.SetObject(i % width * _placeSizeWidth, (height - 1 - i / width) * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
||||||
{
|
warship.DrawingObject(gr);
|
||||||
_setWarship[i].SetObject(i % width * _placeSizeWidth, (height - 1 - i / width) * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
i++;
|
||||||
_setWarship[i]?.DrawingObject(gr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,28 +15,39 @@ namespace Warship
|
|||||||
private readonly int _pictureWidth;
|
private readonly int _pictureWidth;
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
|
|
||||||
public MapsCollection(int pictureWidth,int pictureHeight)
|
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||||
{
|
{
|
||||||
_mapStorages = new Dictionary<string, MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>>;
|
_mapStorages = new Dictionary<string, MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>>();
|
||||||
_pictureWidth = pictureWidth;
|
_pictureWidth = pictureWidth;
|
||||||
_pictureHeight = pictureHeight;
|
_pictureHeight = pictureHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddMap(string name,AbstractMap map)
|
public void AddMap(string name, AbstractMap map)
|
||||||
{
|
{
|
||||||
//todo
|
if (_mapStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Карта уже существует");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_mapStorages.Add(name, new MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DelMap(string name)
|
public void DelMap(string name)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
_mapStorages.Remove(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapWithSetWarshipsGeneric<DrawingObjectWarship,AbstractMap> this[string ind]
|
public MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap> this[string ind]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
//todo
|
if (_mapStorages.ContainsKey(ind))
|
||||||
|
return _mapStorages[ind];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,52 +23,29 @@ namespace Warship
|
|||||||
|
|
||||||
public int Insert(T warship)
|
public int Insert(T warship)
|
||||||
{
|
{
|
||||||
//todo
|
if (_places.Count + 1 >= _maxCount)
|
||||||
return Insert(warship,0);
|
return -1;
|
||||||
|
_places.Insert(0, warship);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T warship, int position)
|
public int Insert(T warship, int position)
|
||||||
{
|
{
|
||||||
//todo
|
if (position >= _maxCount || position < 0)
|
||||||
int EmptyEl=-1;
|
|
||||||
|
|
||||||
if (position>=Count || position < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
if (_places.Count + 1 >= _maxCount)
|
||||||
if (_places[position] == null)
|
return -1;
|
||||||
{
|
_places.Insert(position, warship);
|
||||||
_places[position] = warship;
|
return position;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (_places[position] != null)
|
|
||||||
{
|
|
||||||
for (int i = position + 1; i < Count; i++)
|
|
||||||
if (_places[i] == null)
|
|
||||||
{
|
|
||||||
EmptyEl = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EmptyEl == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (int i = EmptyEl; i > position; i--)
|
|
||||||
_places[i] = _places[i - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
_places[position] = warship;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
//todo
|
if (position >= _maxCount || position < 0)
|
||||||
if (position >= Count || position < 0 || _places[position]==null)
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
T deleted =_places[position];
|
T deleted =_places[position];
|
||||||
_places[position] = null;
|
_places.RemoveAt(position);
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,12 +53,14 @@ namespace Warship
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
//todo
|
if (position < 0 || position >= _maxCount)
|
||||||
|
return null;
|
||||||
return _places[position];
|
return _places[position];
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
//todo
|
if (position < 0 || position >= _maxCount)
|
||||||
|
Insert(value, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public IEnumerable<T> GetWarships()
|
public IEnumerable<T> GetWarships()
|
||||||
|
Loading…
Reference in New Issue
Block a user