Этап 3. Форма + фикс T Remove.
This commit is contained in:
parent
6c787200aa
commit
20291ba6a8
@ -29,8 +29,13 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
this.ButtonAddShip = new System.Windows.Forms.Button();
|
this.groupBoxMaps = new System.Windows.Forms.GroupBox();
|
||||||
|
this.ButtonDeleteMap = new System.Windows.Forms.Button();
|
||||||
|
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||||
|
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||||
|
this.ButtonAddMap = new System.Windows.Forms.Button();
|
||||||
this.ComboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
this.ComboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
|
this.ButtonAddShip = new System.Windows.Forms.Button();
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
@ -41,13 +46,14 @@
|
|||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
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.ButtonAddShip);
|
this.groupBox1.Controls.Add(this.ButtonAddShip);
|
||||||
this.groupBox1.Controls.Add(this.ComboBoxSelectorMap);
|
|
||||||
this.groupBox1.Controls.Add(this.buttonUp);
|
this.groupBox1.Controls.Add(this.buttonUp);
|
||||||
this.groupBox1.Controls.Add(this.buttonRight);
|
this.groupBox1.Controls.Add(this.buttonRight);
|
||||||
this.groupBox1.Controls.Add(this.buttonDown);
|
this.groupBox1.Controls.Add(this.buttonDown);
|
||||||
@ -59,20 +65,61 @@
|
|||||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBox1.Location = new System.Drawing.Point(553, 0);
|
this.groupBox1.Location = new System.Drawing.Point(553, 0);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.groupBox1.Name = "groupBox1";
|
||||||
this.groupBox1.Size = new System.Drawing.Size(300, 508);
|
this.groupBox1.Size = new System.Drawing.Size(300, 687);
|
||||||
this.groupBox1.TabIndex = 0;
|
this.groupBox1.TabIndex = 0;
|
||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Инструменты";
|
this.groupBox1.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// ButtonAddShip
|
// groupBoxMaps
|
||||||
//
|
//
|
||||||
this.ButtonAddShip.Location = new System.Drawing.Point(6, 74);
|
this.groupBoxMaps.Controls.Add(this.ButtonDeleteMap);
|
||||||
this.ButtonAddShip.Name = "ButtonAddShip";
|
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||||
this.ButtonAddShip.Size = new System.Drawing.Size(288, 34);
|
this.groupBoxMaps.Controls.Add(this.textBoxNewMapName);
|
||||||
this.ButtonAddShip.TabIndex = 11;
|
this.groupBoxMaps.Controls.Add(this.ButtonAddMap);
|
||||||
this.ButtonAddShip.Text = "Добавить корабль";
|
this.groupBoxMaps.Controls.Add(this.ComboBoxSelectorMap);
|
||||||
this.ButtonAddShip.UseVisualStyleBackColor = true;
|
this.groupBoxMaps.Location = new System.Drawing.Point(10, 32);
|
||||||
this.ButtonAddShip.Click += new System.EventHandler(this.ButtonAddShip_Click);
|
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||||
|
this.groupBoxMaps.Size = new System.Drawing.Size(284, 327);
|
||||||
|
this.groupBoxMaps.TabIndex = 12;
|
||||||
|
this.groupBoxMaps.TabStop = false;
|
||||||
|
this.groupBoxMaps.Text = "Карты";
|
||||||
|
//
|
||||||
|
// ButtonDeleteMap
|
||||||
|
//
|
||||||
|
this.ButtonDeleteMap.Location = new System.Drawing.Point(6, 277);
|
||||||
|
this.ButtonDeleteMap.Name = "ButtonDeleteMap";
|
||||||
|
this.ButtonDeleteMap.Size = new System.Drawing.Size(272, 44);
|
||||||
|
this.ButtonDeleteMap.TabIndex = 15;
|
||||||
|
this.ButtonDeleteMap.Text = "Удалить карту";
|
||||||
|
this.ButtonDeleteMap.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
||||||
|
//
|
||||||
|
// listBoxMaps
|
||||||
|
//
|
||||||
|
this.listBoxMaps.FormattingEnabled = true;
|
||||||
|
this.listBoxMaps.ItemHeight = 25;
|
||||||
|
this.listBoxMaps.Location = new System.Drawing.Point(6, 167);
|
||||||
|
this.listBoxMaps.Name = "listBoxMaps";
|
||||||
|
this.listBoxMaps.Size = new System.Drawing.Size(272, 104);
|
||||||
|
this.listBoxMaps.TabIndex = 14;
|
||||||
|
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// textBoxNewMapName
|
||||||
|
//
|
||||||
|
this.textBoxNewMapName.Location = new System.Drawing.Point(6, 39);
|
||||||
|
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||||
|
this.textBoxNewMapName.Size = new System.Drawing.Size(272, 31);
|
||||||
|
this.textBoxNewMapName.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// ButtonAddMap
|
||||||
|
//
|
||||||
|
this.ButtonAddMap.Location = new System.Drawing.Point(6, 115);
|
||||||
|
this.ButtonAddMap.Name = "ButtonAddMap";
|
||||||
|
this.ButtonAddMap.Size = new System.Drawing.Size(272, 44);
|
||||||
|
this.ButtonAddMap.TabIndex = 12;
|
||||||
|
this.ButtonAddMap.Text = "Добавить карту";
|
||||||
|
this.ButtonAddMap.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||||
//
|
//
|
||||||
// ComboBoxSelectorMap
|
// ComboBoxSelectorMap
|
||||||
//
|
//
|
||||||
@ -80,18 +127,27 @@
|
|||||||
this.ComboBoxSelectorMap.Items.AddRange(new object[] {
|
this.ComboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
"Простая карта",
|
"Простая карта",
|
||||||
"Модифицированная карта"});
|
"Модифицированная карта"});
|
||||||
this.ComboBoxSelectorMap.Location = new System.Drawing.Point(6, 35);
|
this.ComboBoxSelectorMap.Location = new System.Drawing.Point(6, 76);
|
||||||
this.ComboBoxSelectorMap.Name = "ComboBoxSelectorMap";
|
this.ComboBoxSelectorMap.Name = "ComboBoxSelectorMap";
|
||||||
this.ComboBoxSelectorMap.Size = new System.Drawing.Size(288, 33);
|
this.ComboBoxSelectorMap.Size = new System.Drawing.Size(272, 33);
|
||||||
this.ComboBoxSelectorMap.TabIndex = 10;
|
this.ComboBoxSelectorMap.TabIndex = 10;
|
||||||
this.ComboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
//
|
||||||
|
// ButtonAddShip
|
||||||
|
//
|
||||||
|
this.ButtonAddShip.Location = new System.Drawing.Point(6, 365);
|
||||||
|
this.ButtonAddShip.Name = "ButtonAddShip";
|
||||||
|
this.ButtonAddShip.Size = new System.Drawing.Size(288, 34);
|
||||||
|
this.ButtonAddShip.TabIndex = 11;
|
||||||
|
this.ButtonAddShip.Text = "Добавить корабль";
|
||||||
|
this.ButtonAddShip.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonAddShip.Click += new System.EventHandler(this.ButtonAddShip_Click);
|
||||||
//
|
//
|
||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
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::ContainerShip.Properties.Resources.upArrow;
|
this.buttonUp.BackgroundImage = global::ContainerShip.Properties.Resources.upArrow;
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonUp.Location = new System.Drawing.Point(131, 390);
|
this.buttonUp.Location = new System.Drawing.Point(131, 569);
|
||||||
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 = 9;
|
this.buttonUp.TabIndex = 9;
|
||||||
@ -103,7 +159,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::ContainerShip.Properties.Resources.LeftArrow;
|
this.buttonRight.BackgroundImage = global::ContainerShip.Properties.Resources.LeftArrow;
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonRight.Location = new System.Drawing.Point(187, 446);
|
this.buttonRight.Location = new System.Drawing.Point(187, 625);
|
||||||
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 = 8;
|
this.buttonRight.TabIndex = 8;
|
||||||
@ -115,7 +171,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::ContainerShip.Properties.Resources.DownArrow;
|
this.buttonDown.BackgroundImage = global::ContainerShip.Properties.Resources.DownArrow;
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonDown.Location = new System.Drawing.Point(131, 446);
|
this.buttonDown.Location = new System.Drawing.Point(131, 625);
|
||||||
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 = 7;
|
this.buttonDown.TabIndex = 7;
|
||||||
@ -127,7 +183,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::ContainerShip.Properties.Resources.RightArrow;
|
this.buttonLeft.BackgroundImage = global::ContainerShip.Properties.Resources.RightArrow;
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(75, 446);
|
this.buttonLeft.Location = new System.Drawing.Point(75, 625);
|
||||||
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 = 6;
|
this.buttonLeft.TabIndex = 6;
|
||||||
@ -136,9 +192,9 @@
|
|||||||
//
|
//
|
||||||
// button3
|
// button3
|
||||||
//
|
//
|
||||||
this.button3.Location = new System.Drawing.Point(8, 292);
|
this.button3.Location = new System.Drawing.Point(6, 529);
|
||||||
this.button3.Name = "button3";
|
this.button3.Name = "button3";
|
||||||
this.button3.Size = new System.Drawing.Size(286, 34);
|
this.button3.Size = new System.Drawing.Size(288, 34);
|
||||||
this.button3.TabIndex = 3;
|
this.button3.TabIndex = 3;
|
||||||
this.button3.Text = "Посмотреть карту";
|
this.button3.Text = "Посмотреть карту";
|
||||||
this.button3.UseVisualStyleBackColor = true;
|
this.button3.UseVisualStyleBackColor = true;
|
||||||
@ -146,7 +202,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonShowStorage
|
// ButtonShowStorage
|
||||||
//
|
//
|
||||||
this.ButtonShowStorage.Location = new System.Drawing.Point(6, 243);
|
this.ButtonShowStorage.Location = new System.Drawing.Point(6, 489);
|
||||||
this.ButtonShowStorage.Name = "ButtonShowStorage";
|
this.ButtonShowStorage.Name = "ButtonShowStorage";
|
||||||
this.ButtonShowStorage.Size = new System.Drawing.Size(288, 34);
|
this.ButtonShowStorage.Size = new System.Drawing.Size(288, 34);
|
||||||
this.ButtonShowStorage.TabIndex = 2;
|
this.ButtonShowStorage.TabIndex = 2;
|
||||||
@ -156,7 +212,7 @@
|
|||||||
//
|
//
|
||||||
// ButtonRemoveShip
|
// ButtonRemoveShip
|
||||||
//
|
//
|
||||||
this.ButtonRemoveShip.Location = new System.Drawing.Point(6, 162);
|
this.ButtonRemoveShip.Location = new System.Drawing.Point(6, 442);
|
||||||
this.ButtonRemoveShip.Name = "ButtonRemoveShip";
|
this.ButtonRemoveShip.Name = "ButtonRemoveShip";
|
||||||
this.ButtonRemoveShip.Size = new System.Drawing.Size(288, 41);
|
this.ButtonRemoveShip.Size = new System.Drawing.Size(288, 41);
|
||||||
this.ButtonRemoveShip.TabIndex = 1;
|
this.ButtonRemoveShip.TabIndex = 1;
|
||||||
@ -166,7 +222,7 @@
|
|||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 125);
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 405);
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(288, 31);
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(288, 31);
|
||||||
@ -177,7 +233,7 @@
|
|||||||
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(553, 508);
|
this.pictureBox.Size = new System.Drawing.Size(553, 687);
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -185,13 +241,15 @@
|
|||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(853, 508);
|
this.ClientSize = new System.Drawing.Size(853, 687);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Name = "FormMapWithSetShips";
|
this.Name = "FormMapWithSetShips";
|
||||||
this.Text = "Карта с набором объектов";
|
this.Text = "Карта с набором объектов";
|
||||||
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);
|
||||||
|
|
||||||
@ -211,5 +269,10 @@
|
|||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button ButtonAddShip;
|
private Button ButtonAddShip;
|
||||||
private ComboBox ComboBoxSelectorMap;
|
private ComboBox ComboBoxSelectorMap;
|
||||||
|
private ListBox listBoxMaps;
|
||||||
|
private TextBox textBoxNewMapName;
|
||||||
|
private Button ButtonAddMap;
|
||||||
|
private GroupBox groupBoxMaps;
|
||||||
|
private Button ButtonDeleteMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,46 +13,60 @@ namespace ContainerShip
|
|||||||
{
|
{
|
||||||
public partial class FormMapWithSetShips : Form
|
public partial class FormMapWithSetShips : Form
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь для выпадающего списка
|
||||||
|
/// </summary>
|
||||||
|
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||||
|
{
|
||||||
|
{ "Простая карта", new SimpleMap() }
|
||||||
|
};
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Объект от класса карты с набором объектов
|
/// Объект от класса карты с набором объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap> _mapShipsCollectionGeneric;
|
private readonly MapsCollection _mapsCollection;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormMapWithSetShips()
|
public FormMapWithSetShips()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||||
|
ComboBoxSelectorMap.Items.Clear();
|
||||||
|
foreach (var elem in _mapsDict)
|
||||||
|
{
|
||||||
|
ComboBoxSelectorMap.Items.Add(elem.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Заполнение listBoxMaps
|
||||||
|
/// </summary>
|
||||||
|
private void ReloadMaps()
|
||||||
|
{
|
||||||
|
int index = listBoxMaps.SelectedIndex;
|
||||||
|
|
||||||
|
listBoxMaps.Items.Clear();
|
||||||
|
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
||||||
|
{
|
||||||
|
listBoxMaps.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxMaps.SelectedIndex = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта
|
/// Добавление объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
AbstractMap map = null;
|
|
||||||
switch (ComboBoxSelectorMap.Text)
|
|
||||||
{
|
|
||||||
case "Простая карта":
|
|
||||||
map = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Модифицированная карта":
|
|
||||||
map = new ModifyMap();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (map != null)
|
|
||||||
{
|
|
||||||
_mapShipsCollectionGeneric = new MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_mapShipsCollectionGeneric = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapShipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -60,10 +74,10 @@ namespace ContainerShip
|
|||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
DrawingObjectShip ship = new(form.SelectedShip);
|
DrawingObjectShip ship = new(form.SelectedShip);
|
||||||
if (_mapShipsCollectionGeneric + ship != -1)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + ship != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -78,6 +92,10 @@ namespace ContainerShip
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
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;
|
||||||
@ -87,10 +105,10 @@ namespace ContainerShip
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_mapShipsCollectionGeneric - pos != null)
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -104,11 +122,11 @@ namespace ContainerShip
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapShipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод карты
|
/// Вывод карты
|
||||||
@ -117,11 +135,11 @@ namespace ContainerShip
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapShipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowOnMap();
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перемещение
|
/// Перемещение
|
||||||
@ -130,7 +148,7 @@ namespace ContainerShip
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_mapShipsCollectionGeneric == null)
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -152,7 +170,50 @@ namespace ContainerShip
|
|||||||
dir = Direction.Right;
|
dir = Direction.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pictureBox.Image = _mapShipsCollectionGeneric.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(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();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Выбор карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace ContainerShip
|
|||||||
public void AddMap(string name, AbstractMap map)
|
public void AddMap(string name, AbstractMap map)
|
||||||
{
|
{
|
||||||
// TODO Прописать логику для добавления
|
// TODO Прописать логику для добавления
|
||||||
if (_mapStorages.ContainsKey(name)) return;
|
if (_mapStorages.ContainsKey(name)) return; //уникальное имя
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_mapStorages.Add(name, new MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
_mapStorages.Add(name, new MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||||
|
@ -56,12 +56,12 @@ namespace ContainerShip
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= _places.Count)
|
if (position < 0 || position >= _maxCount)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
T ship = _places[position];
|
T ship = _places[position];
|
||||||
_places[position] = null;
|
_places.RemoveAt(position);
|
||||||
return ship;
|
return ship;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user