Форма
This commit is contained in:
parent
a975f1df1d
commit
148e7e9c4b
173
WarmlyShip/WarmlyShip/FormMapWithSetShip.Designer.cs
generated
173
WarmlyShip/WarmlyShip/FormMapWithSetShip.Designer.cs
generated
@ -29,47 +29,118 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBox = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.ListBoxMaps = new System.Windows.Forms.ListBox();
|
||||
this.ButtonDeleteMap = new System.Windows.Forms.Button();
|
||||
this.ButtonAddMap = new System.Windows.Forms.Button();
|
||||
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonAddShip = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonRemoveShip = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddShip = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox
|
||||
//
|
||||
this.groupBox.Controls.Add(this.groupBox1);
|
||||
this.groupBox.Controls.Add(this.buttonDown);
|
||||
this.groupBox.Controls.Add(this.buttonRight);
|
||||
this.groupBox.Controls.Add(this.buttonLeft);
|
||||
this.groupBox.Controls.Add(this.buttonUp);
|
||||
this.groupBox.Controls.Add(this.buttonShowOnMap);
|
||||
this.groupBox.Controls.Add(this.buttonAddShip);
|
||||
this.groupBox.Controls.Add(this.buttonShowStorage);
|
||||
this.groupBox.Controls.Add(this.buttonShowOnMap);
|
||||
this.groupBox.Controls.Add(this.buttonRemoveShip);
|
||||
this.groupBox.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBox.Controls.Add(this.buttonAddShip);
|
||||
this.groupBox.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox.Location = new System.Drawing.Point(600, 0);
|
||||
this.groupBox.Location = new System.Drawing.Point(617, 0);
|
||||
this.groupBox.Name = "groupBox";
|
||||
this.groupBox.Size = new System.Drawing.Size(200, 450);
|
||||
this.groupBox.Size = new System.Drawing.Size(200, 495);
|
||||
this.groupBox.TabIndex = 0;
|
||||
this.groupBox.TabStop = false;
|
||||
this.groupBox.Text = "Инструменты";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.ListBoxMaps);
|
||||
this.groupBox1.Controls.Add(this.ButtonDeleteMap);
|
||||
this.groupBox1.Controls.Add(this.ButtonAddMap);
|
||||
this.groupBox1.Controls.Add(this.textBoxNewMapName);
|
||||
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBox1.Location = new System.Drawing.Point(6, 26);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(189, 218);
|
||||
this.groupBox1.TabIndex = 18;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Карты";
|
||||
//
|
||||
// ListBoxMaps
|
||||
//
|
||||
this.ListBoxMaps.FormattingEnabled = true;
|
||||
this.ListBoxMaps.ItemHeight = 15;
|
||||
this.ListBoxMaps.Location = new System.Drawing.Point(10, 101);
|
||||
this.ListBoxMaps.Name = "ListBoxMaps";
|
||||
this.ListBoxMaps.Size = new System.Drawing.Size(175, 79);
|
||||
this.ListBoxMaps.TabIndex = 12;
|
||||
this.ListBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||
//
|
||||
// ButtonDeleteMap
|
||||
//
|
||||
this.ButtonDeleteMap.Location = new System.Drawing.Point(9, 185);
|
||||
this.ButtonDeleteMap.Name = "ButtonDeleteMap";
|
||||
this.ButtonDeleteMap.Size = new System.Drawing.Size(175, 21);
|
||||
this.ButtonDeleteMap.TabIndex = 13;
|
||||
this.ButtonDeleteMap.Text = "Удалить карту";
|
||||
this.ButtonDeleteMap.UseVisualStyleBackColor = true;
|
||||
this.ButtonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
||||
//
|
||||
// ButtonAddMap
|
||||
//
|
||||
this.ButtonAddMap.Location = new System.Drawing.Point(10, 74);
|
||||
this.ButtonAddMap.Name = "ButtonAddMap";
|
||||
this.ButtonAddMap.Size = new System.Drawing.Size(174, 21);
|
||||
this.ButtonAddMap.TabIndex = 11;
|
||||
this.ButtonAddMap.Text = "Добавить карту";
|
||||
this.ButtonAddMap.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||
//
|
||||
// textBoxNewMapName
|
||||
//
|
||||
this.textBoxNewMapName.Location = new System.Drawing.Point(10, 21);
|
||||
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||
this.textBoxNewMapName.Size = new System.Drawing.Size(175, 23);
|
||||
this.textBoxNewMapName.TabIndex = 10;
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Карта океана с рифами",
|
||||
"Карта речки c камнями"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(10, 47);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 9;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::WarmlyShip.Properties.Resources.arrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(87, 403);
|
||||
this.buttonDown.Location = new System.Drawing.Point(89, 459);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 9;
|
||||
@ -81,7 +152,7 @@
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::WarmlyShip.Properties.Resources.arrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(123, 403);
|
||||
this.buttonRight.Location = new System.Drawing.Point(126, 459);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 8;
|
||||
@ -93,7 +164,7 @@
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::WarmlyShip.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(51, 403);
|
||||
this.buttonLeft.Location = new System.Drawing.Point(53, 459);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 7;
|
||||
@ -105,41 +176,52 @@
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::WarmlyShip.Properties.Resources.arrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(87, 367);
|
||||
this.buttonUp.Location = new System.Drawing.Point(89, 423);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 6;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonShowOnMap
|
||||
// buttonAddShip
|
||||
//
|
||||
this.buttonShowOnMap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(19, 312);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(169, 30);
|
||||
this.buttonShowOnMap.TabIndex = 5;
|
||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
this.buttonAddShip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonAddShip.Location = new System.Drawing.Point(10, 253);
|
||||
this.buttonAddShip.Name = "buttonAddShip";
|
||||
this.buttonAddShip.Size = new System.Drawing.Size(186, 30);
|
||||
this.buttonAddShip.TabIndex = 1;
|
||||
this.buttonAddShip.Text = "Добавить корабль";
|
||||
this.buttonAddShip.UseVisualStyleBackColor = true;
|
||||
this.buttonAddShip.Click += new System.EventHandler(this.ButtonAddShip_Click);
|
||||
//
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.buttonShowStorage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(19, 233);
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(10, 351);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(169, 30);
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(186, 30);
|
||||
this.buttonShowStorage.TabIndex = 4;
|
||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||
//
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.buttonShowOnMap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(10, 387);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(186, 30);
|
||||
this.buttonShowOnMap.TabIndex = 5;
|
||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
//
|
||||
// buttonRemoveShip
|
||||
//
|
||||
this.buttonRemoveShip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRemoveShip.Location = new System.Drawing.Point(19, 171);
|
||||
this.buttonRemoveShip.Location = new System.Drawing.Point(10, 315);
|
||||
this.buttonRemoveShip.Name = "buttonRemoveShip";
|
||||
this.buttonRemoveShip.Size = new System.Drawing.Size(169, 30);
|
||||
this.buttonRemoveShip.Size = new System.Drawing.Size(186, 30);
|
||||
this.buttonRemoveShip.TabIndex = 3;
|
||||
this.buttonRemoveShip.Text = "Удалить корабль";
|
||||
this.buttonRemoveShip.UseVisualStyleBackColor = true;
|
||||
@ -148,44 +230,18 @@
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(19, 142);
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(10, 289);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(169, 23);
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(186, 23);
|
||||
this.maskedTextBoxPosition.TabIndex = 2;
|
||||
//
|
||||
// buttonAddShip
|
||||
//
|
||||
this.buttonAddShip.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonAddShip.Location = new System.Drawing.Point(19, 90);
|
||||
this.buttonAddShip.Name = "buttonAddShip";
|
||||
this.buttonAddShip.Size = new System.Drawing.Size(169, 30);
|
||||
this.buttonAddShip.TabIndex = 1;
|
||||
this.buttonAddShip.Text = "Добавить корабль";
|
||||
this.buttonAddShip.UseVisualStyleBackColor = true;
|
||||
this.buttonAddShip.Click += new System.EventHandler(this.ButtonAddShip_Click);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
this.comboBoxSelectorMap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||
"Простая карта",
|
||||
"Карта океана с рифами",
|
||||
"Карта речки c камнями"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(19, 33);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(169, 23);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||
//
|
||||
// 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(600, 450);
|
||||
this.pictureBox.Size = new System.Drawing.Size(617, 495);
|
||||
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
@ -194,13 +250,15 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.ClientSize = new System.Drawing.Size(817, 495);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.groupBox);
|
||||
this.Name = "FormMapWithSetShip";
|
||||
this.Text = "FormMapWithSetShip";
|
||||
this.groupBox.ResumeLayout(false);
|
||||
this.groupBox.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
@ -221,5 +279,10 @@
|
||||
private Button buttonAddShip;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private PictureBox pictureBox;
|
||||
private GroupBox groupBox1;
|
||||
private Button ButtonDeleteMap;
|
||||
private ListBox ListBoxMaps;
|
||||
private Button ButtonAddMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using WarmlyShip;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@ -17,9 +18,41 @@ namespace WarmlyShip
|
||||
/// Объект от класса карты с набором объектов
|
||||
/// </summary>
|
||||
private MapWithSetShipGeneric<DrawningObjectShip, AbstractMap> _mapShipCollectionGeneric;
|
||||
private readonly Dictionary<string, AbstractMap> _mapDict = new()
|
||||
{
|
||||
{"Простая карта", new SimpleMap() },
|
||||
{"Карта океана с рифами", new OceanMap() },
|
||||
{"Карта речки c камнями",new RiverMap() }
|
||||
};
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
public FormMapWithSetShip()
|
||||
{
|
||||
InitializeComponent();
|
||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||
comboBoxSelectorMap.Items.Clear();
|
||||
foreach (var elem in _mapDict)
|
||||
{
|
||||
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||
}
|
||||
}
|
||||
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>
|
||||
/// Выбор карты
|
||||
@ -58,7 +91,7 @@ namespace WarmlyShip
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipCollectionGeneric == null)
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -66,10 +99,10 @@ namespace WarmlyShip
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectShip ship = new(form.SelectedShip);
|
||||
if (_mapShipCollectionGeneric + ship != -1)
|
||||
if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] + ship != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -84,6 +117,10 @@ namespace WarmlyShip
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
return;
|
||||
@ -93,10 +130,10 @@ namespace WarmlyShip
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapShipCollectionGeneric - pos != null)
|
||||
if (_mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -110,11 +147,11 @@ namespace WarmlyShip
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipCollectionGeneric == null)
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод карты
|
||||
@ -123,11 +160,11 @@ namespace WarmlyShip
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipCollectionGeneric == null)
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowOnMap();
|
||||
pictureBox.Image = _mapsCollection[ListBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение
|
||||
@ -136,7 +173,7 @@ namespace WarmlyShip
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipCollectionGeneric == null)
|
||||
if (ListBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -158,7 +195,40 @@ namespace WarmlyShip
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBox.Image = _mapShipCollectionGeneric.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 (!_mapDict.ContainsKey(comboBoxSelectorMap.Text))
|
||||
{
|
||||
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_mapsCollection.AddMap(textBoxNewMapName.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);
|
||||
ReloadMaps();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@
|
||||
Pen pen = new(Color.Sienna, 3);
|
||||
Brush brush = new SolidBrush(Color.DodgerBlue);
|
||||
g.FillRectangle(brush, 0, 0, _pictureWidth, _pictureHeight);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth + 1; i++)
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth ; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{
|
||||
@ -117,11 +117,11 @@
|
||||
|
||||
foreach (var ship in _setShip.GetShip())
|
||||
{
|
||||
ship?.SetObject(_pictureWidth - _placeSizeWidth * curWidth - (_pictureWidth / 7) + 130,
|
||||
ship?.SetObject(_pictureWidth - _placeSizeWidth * curWidth - (_pictureWidth / 7) + 30,
|
||||
curHeight * _placeSizeHeight + 15, _pictureWidth, _pictureHeight);
|
||||
ship?.DrawningObject(g);
|
||||
|
||||
if (curWidth < widthEl + 1)
|
||||
if (curWidth < widthEl )
|
||||
curWidth++;
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user