Urdack
This commit is contained in:
parent
8f20040737
commit
3f669751ff
89
WarmlyShip/WarmlyShip/FormMapWithSetShip.Designer.cs
generated
89
WarmlyShip/WarmlyShip/FormMapWithSetShip.Designer.cs
generated
@ -29,17 +29,17 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.button4 = new System.Windows.Forms.Button();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||
this.buttonRemoveShip = 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.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -51,9 +51,9 @@
|
||||
this.groupBox1.Controls.Add(this.buttonLeft);
|
||||
this.groupBox1.Controls.Add(this.buttonUp);
|
||||
this.groupBox1.Controls.Add(this.buttonRight);
|
||||
this.groupBox1.Controls.Add(this.button4);
|
||||
this.groupBox1.Controls.Add(this.button3);
|
||||
this.groupBox1.Controls.Add(this.button2);
|
||||
this.groupBox1.Controls.Add(this.buttonShowOnMap);
|
||||
this.groupBox1.Controls.Add(this.buttonShowStorage);
|
||||
this.groupBox1.Controls.Add(this.buttonRemoveShip);
|
||||
this.groupBox1.Controls.Add(this.buttonAddShip);
|
||||
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
@ -64,6 +64,14 @@
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Инструменты";
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 116);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(188, 23);
|
||||
this.maskedTextBoxPosition.TabIndex = 11;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
@ -112,35 +120,35 @@
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// button4
|
||||
// buttonShowOnMap
|
||||
//
|
||||
this.button4.Location = new System.Drawing.Point(6, 281);
|
||||
this.button4.Name = "button4";
|
||||
this.button4.Size = new System.Drawing.Size(188, 23);
|
||||
this.button4.TabIndex = 5;
|
||||
this.button4.Text = "Посмотреть карту";
|
||||
this.button4.UseVisualStyleBackColor = true;
|
||||
this.button4.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
this.buttonShowOnMap.Location = new System.Drawing.Point(6, 281);
|
||||
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||
this.buttonShowOnMap.Size = new System.Drawing.Size(188, 23);
|
||||
this.buttonShowOnMap.TabIndex = 5;
|
||||
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
//
|
||||
// button3
|
||||
// buttonShowStorage
|
||||
//
|
||||
this.button3.Location = new System.Drawing.Point(6, 226);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Size = new System.Drawing.Size(188, 23);
|
||||
this.button3.TabIndex = 4;
|
||||
this.button3.Text = "Посмотреть хранилище";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
this.button3.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||
this.buttonShowStorage.Location = new System.Drawing.Point(6, 226);
|
||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||
this.buttonShowStorage.Size = new System.Drawing.Size(188, 23);
|
||||
this.buttonShowStorage.TabIndex = 4;
|
||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||
//
|
||||
// button2
|
||||
// buttonRemoveShip
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(6, 170);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(188, 23);
|
||||
this.button2.TabIndex = 3;
|
||||
this.button2.Text = "Удалить корабль";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.ButtonRemoveShip_Click);
|
||||
this.buttonRemoveShip.Location = new System.Drawing.Point(6, 170);
|
||||
this.buttonRemoveShip.Name = "buttonRemoveShip";
|
||||
this.buttonRemoveShip.Size = new System.Drawing.Size(188, 23);
|
||||
this.buttonRemoveShip.TabIndex = 3;
|
||||
this.buttonRemoveShip.Text = "Удалить корабль";
|
||||
this.buttonRemoveShip.UseVisualStyleBackColor = true;
|
||||
this.buttonRemoveShip.Click += new System.EventHandler(this.ButtonRemoveShip_Click);
|
||||
//
|
||||
// buttonAddShip
|
||||
//
|
||||
@ -155,10 +163,15 @@
|
||||
// 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
|
||||
//
|
||||
@ -169,14 +182,6 @@
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 116);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(188, 23);
|
||||
this.maskedTextBoxPosition.TabIndex = 11;
|
||||
//
|
||||
// FormMapWithSetShip
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
@ -199,9 +204,9 @@
|
||||
private PictureBox pictureBox;
|
||||
private Button buttonAddShip;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private Button button4;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private Button buttonShowOnMap;
|
||||
private Button buttonShowStorage;
|
||||
private Button buttonRemoveShip;
|
||||
private Button buttonDown;
|
||||
private Button buttonLeft;
|
||||
private Button buttonUp;
|
||||
|
@ -7,13 +7,14 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.DataFormats;
|
||||
using WarmlyShip;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
public partial class FormMapWithSetShip : Form
|
||||
{
|
||||
private MapWithSetShipGeneric<DrawningObjectShip, AbstractMap> _mapShipsCollectionGeneric;
|
||||
private MapWithSetShipGeneric<DrawningObjectShip, AbstractMap> _mapShipCollectionGeneric;
|
||||
public bool ShipOnMap = false;
|
||||
|
||||
public FormMapWithSetShip()
|
||||
{
|
||||
@ -28,20 +29,25 @@ namespace WarmlyShip
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Вторая карта":
|
||||
map = new SecondMap();
|
||||
break;
|
||||
case "Последняя карта":
|
||||
map = new LastMap();
|
||||
break;
|
||||
}
|
||||
if (map != null)
|
||||
{
|
||||
_mapShipsCollectionGeneric = new MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
||||
_mapShipCollectionGeneric = new MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapShipsCollectionGeneric = null;
|
||||
_mapShipCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipsCollectionGeneric == null)
|
||||
if (_mapShipCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -49,10 +55,10 @@ namespace WarmlyShip
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawningObjectShip ship = new(form.SelectedShip);
|
||||
if (_mapShipsCollectionGeneric + ship)
|
||||
if (_mapShipCollectionGeneric + ship)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -67,15 +73,16 @@ namespace WarmlyShip
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapShipsCollectionGeneric - pos)
|
||||
if (_mapShipCollectionGeneric - pos)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -85,28 +92,31 @@ namespace WarmlyShip
|
||||
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipsCollectionGeneric == null)
|
||||
if (_mapShipCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowSet();
|
||||
ShipOnMap = false;
|
||||
}
|
||||
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipsCollectionGeneric == null)
|
||||
if (_mapShipCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowOnMap();
|
||||
pictureBox.Image = _mapShipCollectionGeneric.ShowOnMap();
|
||||
ShipOnMap = true;
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapShipsCollectionGeneric == null)
|
||||
if (_mapShipCollectionGeneric == null || !ShipOnMap)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
Direction dir = Direction.None;
|
||||
switch (name)
|
||||
@ -124,7 +134,7 @@ namespace WarmlyShip
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBox.Image = _mapShipsCollectionGeneric.MoveObject(dir);
|
||||
pictureBox.Image = _mapShipCollectionGeneric.MoveObject(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user