Перегрузка операторов.
This commit is contained in:
parent
55300032aa
commit
6344340950
@ -72,6 +72,7 @@
|
|||||||
this.ButtonAddShip.TabIndex = 11;
|
this.ButtonAddShip.TabIndex = 11;
|
||||||
this.ButtonAddShip.Text = "Добавить корабль";
|
this.ButtonAddShip.Text = "Добавить корабль";
|
||||||
this.ButtonAddShip.UseVisualStyleBackColor = true;
|
this.ButtonAddShip.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonAddShip.Click += new System.EventHandler(this.ButtonAddShip_Click);
|
||||||
//
|
//
|
||||||
// ComboBoxSelectorMap
|
// ComboBoxSelectorMap
|
||||||
//
|
//
|
||||||
@ -83,6 +84,7 @@
|
|||||||
this.ComboBoxSelectorMap.Name = "ComboBoxSelectorMap";
|
this.ComboBoxSelectorMap.Name = "ComboBoxSelectorMap";
|
||||||
this.ComboBoxSelectorMap.Size = new System.Drawing.Size(288, 33);
|
this.ComboBoxSelectorMap.Size = new System.Drawing.Size(288, 33);
|
||||||
this.ComboBoxSelectorMap.TabIndex = 10;
|
this.ComboBoxSelectorMap.TabIndex = 10;
|
||||||
|
this.ComboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
@ -94,6 +96,7 @@
|
|||||||
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;
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
@ -105,6 +108,7 @@
|
|||||||
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;
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonDown
|
// buttonDown
|
||||||
//
|
//
|
||||||
@ -116,6 +120,7 @@
|
|||||||
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;
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
@ -127,6 +132,7 @@
|
|||||||
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;
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
// button3
|
// button3
|
||||||
//
|
//
|
||||||
@ -136,6 +142,7 @@
|
|||||||
this.button3.TabIndex = 3;
|
this.button3.TabIndex = 3;
|
||||||
this.button3.Text = "Посмотреть карту";
|
this.button3.Text = "Посмотреть карту";
|
||||||
this.button3.UseVisualStyleBackColor = true;
|
this.button3.UseVisualStyleBackColor = true;
|
||||||
|
this.button3.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||||
//
|
//
|
||||||
// ButtonShowStorage
|
// ButtonShowStorage
|
||||||
//
|
//
|
||||||
@ -145,6 +152,7 @@
|
|||||||
this.ButtonShowStorage.TabIndex = 2;
|
this.ButtonShowStorage.TabIndex = 2;
|
||||||
this.ButtonShowStorage.Text = "Просмотреть хранилище";
|
this.ButtonShowStorage.Text = "Просмотреть хранилище";
|
||||||
this.ButtonShowStorage.UseVisualStyleBackColor = true;
|
this.ButtonShowStorage.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||||
//
|
//
|
||||||
// ButtonRemoveShip
|
// ButtonRemoveShip
|
||||||
//
|
//
|
||||||
@ -154,6 +162,7 @@
|
|||||||
this.ButtonRemoveShip.TabIndex = 1;
|
this.ButtonRemoveShip.TabIndex = 1;
|
||||||
this.ButtonRemoveShip.Text = "Удалить корабль";
|
this.ButtonRemoveShip.Text = "Удалить корабль";
|
||||||
this.ButtonRemoveShip.UseVisualStyleBackColor = true;
|
this.ButtonRemoveShip.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonRemoveShip.Click += new System.EventHandler(this.ButtonRemoveShip_Click);
|
||||||
//
|
//
|
||||||
// maskedTextBoxPosition
|
// maskedTextBoxPosition
|
||||||
//
|
//
|
||||||
|
@ -25,10 +25,8 @@ namespace ContainerShip
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Выбор карты
|
/// Добавление объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AbstractMap map = null;
|
AbstractMap map = null;
|
||||||
@ -43,17 +41,13 @@ namespace ContainerShip
|
|||||||
}
|
}
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
_mapShipsCollectionGeneric = new MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>(
|
_mapShipsCollectionGeneric = new MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
||||||
pictureBox.Width, pictureBox.Height, map);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_mapShipsCollectionGeneric = null;
|
_mapShipsCollectionGeneric = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <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)
|
||||||
@ -65,8 +59,8 @@ namespace ContainerShip
|
|||||||
FormShip form = new();
|
FormShip form = new();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
DrawingObjectShip car = new(form.SelectedShip);
|
DrawingObjectShip ship = new(form.SelectedShip);
|
||||||
if (_mapShipsCollectionGeneric + car)
|
if (_mapShipsCollectionGeneric + ship != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
||||||
@ -93,7 +87,7 @@ namespace ContainerShip
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_mapShipsCollectionGeneric - pos)
|
if (_mapShipsCollectionGeneric - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
|
||||||
|
116
ContainerShip/ContainerShip/FormShip.Designer.cs
generated
116
ContainerShip/ContainerShip/FormShip.Designer.cs
generated
@ -32,14 +32,14 @@
|
|||||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
|
||||||
this.pictureBoxShip = new System.Windows.Forms.PictureBox();
|
this.pictureBoxShip = new System.Windows.Forms.PictureBox();
|
||||||
this.ButtonCreate = new System.Windows.Forms.Button();
|
this.ButtonCreate = new System.Windows.Forms.Button();
|
||||||
this.ButtonCreateModif = new System.Windows.Forms.Button();
|
this.ButtonCreateModif = new System.Windows.Forms.Button();
|
||||||
this.ButtonSelectShip = new System.Windows.Forms.Button();
|
this.ButtonSelectShip = 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.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -62,66 +62,21 @@
|
|||||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(93, 25);
|
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(93, 25);
|
||||||
this.toolStripStatusLabelSpeed.Text = "Скорость:";
|
this.toolStripStatusLabelSpeed.Text = "Скорость:";
|
||||||
|
this.toolStripStatusLabelSpeed.Click += new System.EventHandler(this.toolStripStatusLabelSpeed_Click);
|
||||||
//
|
//
|
||||||
// toolStripStatusLabelWeight
|
// toolStripStatusLabelWeight
|
||||||
//
|
//
|
||||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(43, 25);
|
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(43, 25);
|
||||||
this.toolStripStatusLabelWeight.Text = "Вес:";
|
this.toolStripStatusLabelWeight.Text = "Вес:";
|
||||||
|
this.toolStripStatusLabelWeight.Click += new System.EventHandler(this.toolStripStatusLabelWeight_Click);
|
||||||
//
|
//
|
||||||
// toolStripStatusLabelBodyColor
|
// toolStripStatusLabelBodyColor
|
||||||
//
|
//
|
||||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(55, 25);
|
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(55, 25);
|
||||||
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
|
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
|
||||||
//
|
this.toolStripStatusLabelBodyColor.Click += new System.EventHandler(this.toolStripStatusLabelBodyColor_Click);
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonRight.Location = new System.Drawing.Point(738, 362);
|
|
||||||
this.buttonRight.Name = "buttonRight";
|
|
||||||
this.buttonRight.Size = new System.Drawing.Size(50, 50);
|
|
||||||
this.buttonRight.TabIndex = 2;
|
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonUp.Location = new System.Drawing.Point(682, 306);
|
|
||||||
this.buttonUp.Name = "buttonUp";
|
|
||||||
this.buttonUp.Size = new System.Drawing.Size(50, 50);
|
|
||||||
this.buttonUp.TabIndex = 3;
|
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonDown.Location = new System.Drawing.Point(682, 362);
|
|
||||||
this.buttonDown.Name = "buttonDown";
|
|
||||||
this.buttonDown.Size = new System.Drawing.Size(50, 50);
|
|
||||||
this.buttonDown.TabIndex = 4;
|
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(626, 362);
|
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(50, 50);
|
|
||||||
this.buttonLeft.TabIndex = 5;
|
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
//
|
||||||
// pictureBoxShip
|
// pictureBoxShip
|
||||||
//
|
//
|
||||||
@ -131,6 +86,7 @@
|
|||||||
this.pictureBoxShip.Size = new System.Drawing.Size(800, 418);
|
this.pictureBoxShip.Size = new System.Drawing.Size(800, 418);
|
||||||
this.pictureBoxShip.TabIndex = 7;
|
this.pictureBoxShip.TabIndex = 7;
|
||||||
this.pictureBoxShip.TabStop = false;
|
this.pictureBoxShip.TabStop = false;
|
||||||
|
this.pictureBoxShip.Click += new System.EventHandler(this.pictureBoxShip_Click);
|
||||||
//
|
//
|
||||||
// ButtonCreate
|
// ButtonCreate
|
||||||
//
|
//
|
||||||
@ -168,6 +124,54 @@
|
|||||||
this.ButtonSelectShip.UseVisualStyleBackColor = false;
|
this.ButtonSelectShip.UseVisualStyleBackColor = false;
|
||||||
this.ButtonSelectShip.Click += new System.EventHandler(this.ButtonSelectShip_Click);
|
this.ButtonSelectShip.Click += new System.EventHandler(this.ButtonSelectShip_Click);
|
||||||
//
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(738, 362);
|
||||||
|
this.buttonRight.Name = "buttonRight";
|
||||||
|
this.buttonRight.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.buttonRight.TabIndex = 2;
|
||||||
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonLeft.Location = new System.Drawing.Point(626, 362);
|
||||||
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
|
this.buttonLeft.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.buttonLeft.TabIndex = 5;
|
||||||
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonUp.Location = new System.Drawing.Point(682, 306);
|
||||||
|
this.buttonUp.Name = "buttonUp";
|
||||||
|
this.buttonUp.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.buttonUp.TabIndex = 3;
|
||||||
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(682, 362);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(50, 50);
|
||||||
|
this.buttonDown.TabIndex = 4;
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
// FormShip
|
// FormShip
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||||
@ -196,10 +200,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private StatusStrip statusStrip1;
|
private StatusStrip statusStrip1;
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||||
@ -207,5 +207,9 @@
|
|||||||
private Button ButtonCreate;
|
private Button ButtonCreate;
|
||||||
private Button ButtonCreateModif;
|
private Button ButtonCreateModif;
|
||||||
private Button ButtonSelectShip;
|
private Button ButtonSelectShip;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonDown;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace ContainerShip
|
namespace ContainerShip
|
||||||
{
|
{
|
||||||
public partial class FormShip : Form
|
public partial class FormShip : Form
|
||||||
@ -75,22 +77,35 @@ namespace ContainerShip
|
|||||||
}
|
}
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_ship = new DrawingShip(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
_ship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxShip.Width, pictureBoxShip.Height);
|
ColorDialog dialog = new();
|
||||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_ship.Ship.Speed}";
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_ship.Ship.Weight}";
|
{
|
||||||
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_ship.Ship.BodyColor.Name}";
|
color = dialog.Color;
|
||||||
Draw();
|
}
|
||||||
|
_ship = new DrawingShip(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
||||||
|
SetData();
|
||||||
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_ship = new DrawingContainerShip(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
Color.FromArgb(rnd.Next(0,256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
ColorDialog dialog = new();
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
Convert.ToBoolean(rnd.Next(0,2)), Convert.ToBoolean(rnd.Next(0,2)));
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialogDop = new();
|
||||||
|
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialogDop.Color;
|
||||||
|
}
|
||||||
|
_ship = new DrawingContainerShip(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||||
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
@ -100,5 +115,25 @@ namespace ContainerShip
|
|||||||
SelectedShip = _ship;
|
SelectedShip = _ship;
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void pictureBoxShip_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toolStripStatusLabelBodyColor_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toolStripStatusLabelWeight_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toolStripStatusLabelSpeed_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -50,26 +50,6 @@ namespace ContainerShip
|
|||||||
_map = map;
|
_map = map;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перегрузка оператора сложения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="map"></param>
|
|
||||||
/// <param name="car"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool operator +(MapWithSetShipsGeneric<T, U> map, T ship)
|
|
||||||
{
|
|
||||||
return map._setShips.Insert(ship);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора вычитания
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="map"></param>
|
|
||||||
/// <param name="position"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static bool operator -(MapWithSetShipsGeneric<T, U> map, int position)
|
|
||||||
{
|
|
||||||
return map._setShips.Remove(position);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод всего набора объектов
|
/// Вывод всего набора объектов
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -163,9 +143,31 @@ namespace ContainerShip
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < _setShips.Count; i++)
|
for (int i = 0; i < _setShips.Count; i++)
|
||||||
{
|
{
|
||||||
//TODO установка позиции
|
int countOfShipsInLine = _pictureWidth / _placeSizeWidth;
|
||||||
|
int countOfShipsInColumn = _pictureHeight / _placeSizeHeight;
|
||||||
|
_setShips.Get(i)?.SetObject((countOfShipsInLine - (i % countOfShipsInLine) - 1) * _placeSizeWidth, (countOfShipsInColumn - (i / countOfShipsInLine) - 1) * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
||||||
_setShips.Get(i)?.DrawingObject(g);
|
_setShips.Get(i)?.DrawingObject(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перегрузка операторов
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="map"></param>
|
||||||
|
/// <param name="ship"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int operator +(MapWithSetShipsGeneric<T, U> map, T ship)
|
||||||
|
{
|
||||||
|
return map._setShips.Insert(ship);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перегрузка оператора вычитания
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="map"></param>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T operator -(MapWithSetShipsGeneric<T, U> map, int position)
|
||||||
|
{
|
||||||
|
return map._setShips.Remove(position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace ContainerShip
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="car">Добавляемый автомобиль</param>
|
/// <param name="car">Добавляемый автомобиль</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Insert(T ship)
|
public int Insert(T ship)
|
||||||
{
|
{
|
||||||
return Insert(ship, 0);
|
return Insert(ship, 0);
|
||||||
}
|
}
|
||||||
@ -40,11 +40,11 @@ namespace ContainerShip
|
|||||||
/// <param name="ship">Добавляемый корабль</param>
|
/// <param name="ship">Добавляемый корабль</param>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Insert(T ship, int position)
|
public int Insert(T ship, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= _places.Length)
|
if (position < 0 || position >= _places.Length)
|
||||||
{
|
{
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
if (_places[position] == null)
|
if (_places[position] == null)
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ namespace ContainerShip
|
|||||||
}
|
}
|
||||||
if (freePlace == -1)
|
if (freePlace == -1)
|
||||||
{
|
{
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -76,21 +76,22 @@ namespace ContainerShip
|
|||||||
_places[position] = ship;
|
_places[position] = ship;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return position;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
/// Удаление объекта из набора с конкретной позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position"></param>
|
/// <param name="position"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= _places.Length)
|
if (position < 0 || position >= _places.Length)
|
||||||
{
|
{
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
T ship = _places[position];
|
||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return true;
|
return ship;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта из набора по позиции
|
/// Получение объекта из набора по позиции
|
||||||
|
Loading…
Reference in New Issue
Block a user