Changed forms
This commit is contained in:
parent
f604ea29fc
commit
e4e328590f
@ -9,7 +9,7 @@ namespace Boats
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
||||
internal enum Direction
|
||||
public enum Direction
|
||||
{
|
||||
None = 0,
|
||||
Up = 1,
|
||||
|
@ -9,7 +9,7 @@ namespace Boats
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
internal class DrawingBoat
|
||||
public class DrawingBoat
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
|
@ -9,7 +9,7 @@ namespace Boats
|
||||
/// <summary>
|
||||
/// Класс-сущность "Лодка"
|
||||
/// </summary>
|
||||
internal class EntityBoat
|
||||
public class EntityBoat
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
|
14
Boats/Boats/FormBoat.Designer.cs
generated
14
Boats/Boats/FormBoat.Designer.cs
generated
@ -39,6 +39,7 @@
|
||||
this.ButtonRight = new System.Windows.Forms.Button();
|
||||
this.ButtonDown = new System.Windows.Forms.Button();
|
||||
this.ButtonCreateModificate = new System.Windows.Forms.Button();
|
||||
this.ButtonSelectBoat = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBoat)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -155,11 +156,23 @@
|
||||
this.ButtonCreateModificate.UseVisualStyleBackColor = true;
|
||||
this.ButtonCreateModificate.Click += new System.EventHandler(this.ButtonCreateModificate_Click);
|
||||
//
|
||||
// ButtonSelectBoat
|
||||
//
|
||||
this.ButtonSelectBoat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.ButtonSelectBoat.Location = new System.Drawing.Point(491, 381);
|
||||
this.ButtonSelectBoat.Name = "ButtonSelectBoat";
|
||||
this.ButtonSelectBoat.Size = new System.Drawing.Size(117, 29);
|
||||
this.ButtonSelectBoat.TabIndex = 8;
|
||||
this.ButtonSelectBoat.Text = "Выбрать";
|
||||
this.ButtonSelectBoat.UseVisualStyleBackColor = true;
|
||||
this.ButtonSelectBoat.Click += new System.EventHandler(this.ButtonSelectBoat_Click);
|
||||
//
|
||||
// FormBoat
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.ButtonSelectBoat);
|
||||
this.Controls.Add(this.ButtonCreateModificate);
|
||||
this.Controls.Add(this.ButtonDown);
|
||||
this.Controls.Add(this.ButtonRight);
|
||||
@ -191,5 +204,6 @@
|
||||
private Button ButtonRight;
|
||||
private Button ButtonDown;
|
||||
private Button ButtonCreateModificate;
|
||||
private Button ButtonSelectBoat;
|
||||
}
|
||||
}
|
@ -12,7 +12,8 @@ namespace Boats
|
||||
{
|
||||
public partial class FormBoat : Form
|
||||
{
|
||||
private DrawingBoat _boat;
|
||||
DrawingBoat _boat;
|
||||
public DrawingBoat SelectedBoat { get; private set; }
|
||||
public FormBoat()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -44,18 +45,21 @@ namespace Boats
|
||||
pictureBoxBoat.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать"
|
||||
/// Обработчик нажатия кнопки "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
Random rnd = new Random();
|
||||
Color color = Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255));
|
||||
ColorDialog dialog = new ColorDialog();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
_boat = new DrawingBoat(
|
||||
rnd.Next(100, 300),
|
||||
rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256),
|
||||
rnd.Next(0, 256), rnd.Next(0, 256))
|
||||
rnd.Next(1000, 3000),
|
||||
color
|
||||
);
|
||||
SetData();
|
||||
Draw();
|
||||
@ -67,21 +71,34 @@ namespace Boats
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
if (_boat == null)
|
||||
return;
|
||||
|
||||
string btnName = ((Button)sender).Name;
|
||||
|
||||
switch (btnName)
|
||||
{
|
||||
case "ButtonUp":
|
||||
_boat?.MoveTransport(Direction.Up);
|
||||
{
|
||||
_boat.MoveTransport(Direction.Up);
|
||||
}
|
||||
break;
|
||||
case "ButtonDown":
|
||||
_boat?.MoveTransport(Direction.Down);
|
||||
{
|
||||
_boat.MoveTransport(Direction.Down);
|
||||
}
|
||||
break;
|
||||
case "ButtonLeft":
|
||||
_boat?.MoveTransport(Direction.Left);
|
||||
{
|
||||
_boat.MoveTransport(Direction.Left);
|
||||
}
|
||||
break;
|
||||
case "ButtonRight":
|
||||
_boat?.MoveTransport(Direction.Right);
|
||||
{
|
||||
_boat.MoveTransport(Direction.Right);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
@ -104,16 +121,44 @@ namespace Boats
|
||||
private void ButtonCreateModificate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
|
||||
// Предлагаем установить свой основной цвет
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new ColorDialog();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
_boat = new DrawingCatamaran(
|
||||
rnd.Next(100, 300),
|
||||
rnd.Next(1000, 3000),
|
||||
Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
|
||||
Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
|
||||
color,
|
||||
dopColor,
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2))
|
||||
);
|
||||
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Выбрать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSelectBoat_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedBoat = _boat;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,126 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Boats
|
||||
{
|
||||
public partial class FormMap : Form
|
||||
{
|
||||
private AbstractMap _abstractMap;
|
||||
public FormMap()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractMap = new SimpleMap();
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод установки данных
|
||||
/// </summary>
|
||||
private void SetData(DrawingBoat boat)
|
||||
{
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {boat.Boat.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {boat.Boat.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Цвет: {boat.Boat.BodyColor.Name}";
|
||||
pictureBoxMap.Image = _abstractMap.CreateMap(pictureBoxMap.Width, pictureBoxMap.Height,
|
||||
new DrawingObjectBoat(boat));
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
var boat = new DrawingBoat(
|
||||
rnd.Next(100, 300),
|
||||
rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256),
|
||||
rnd.Next(0, 256), rnd.Next(0, 256))
|
||||
);
|
||||
SetData(boat);
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработчик нажатий кнопок передвижения
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//получаем имя кнопки
|
||||
string btnName = ((Button)sender)?.Name ?? string.Empty;
|
||||
Direction dir = Direction.None;
|
||||
|
||||
switch (btnName)
|
||||
{
|
||||
case "ButtonUp":
|
||||
{
|
||||
dir = Direction.Up;
|
||||
}
|
||||
break;
|
||||
case "ButtonDown":
|
||||
{
|
||||
dir = Direction.Down;
|
||||
}
|
||||
break;
|
||||
case "ButtonLeft":
|
||||
{
|
||||
dir = Direction.Left;
|
||||
}
|
||||
break;
|
||||
case "ButtonRight":
|
||||
{
|
||||
dir = Direction.Right;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pictureBoxMap.Image = _abstractMap?.MoveObject(dir);
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Модификация"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreateModificate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
|
||||
var boat = new DrawingCatamaran(
|
||||
rnd.Next(100, 300),
|
||||
rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
|
||||
Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2))
|
||||
);
|
||||
SetData(boat);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (comboBoxSelectorMap.Text)
|
||||
{
|
||||
case "Простая карта":
|
||||
_abstractMap = new SimpleMap();
|
||||
break;
|
||||
case "Океан карта":
|
||||
_abstractMap = new OceanMap();
|
||||
break;
|
||||
case "Линии карта":
|
||||
_abstractMap = new LineMap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
namespace Boats
|
||||
{
|
||||
partial class FormMap
|
||||
partial class FormMapWithSetBoats
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -28,132 +28,137 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxMap = new System.Windows.Forms.PictureBox();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.ButtonCreate = new System.Windows.Forms.Button();
|
||||
this.ButtonUp = new System.Windows.Forms.Button();
|
||||
this.ButtonLeft = new System.Windows.Forms.Button();
|
||||
this.ButtonRight = new System.Windows.Forms.Button();
|
||||
this.groupBox = new System.Windows.Forms.GroupBox();
|
||||
this.ButtonDown = new System.Windows.Forms.Button();
|
||||
this.ButtonCreateModificate = 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.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
this.ButtonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.ButtonShowStorage = new System.Windows.Forms.Button();
|
||||
this.ButtonRemoveBoat = new System.Windows.Forms.Button();
|
||||
this.ButtonAddBoat = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMap)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxMap
|
||||
// groupBox
|
||||
//
|
||||
this.pictureBoxMap.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxMap.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxMap.Name = "pictureBoxMap";
|
||||
this.pictureBoxMap.Size = new System.Drawing.Size(800, 424);
|
||||
this.pictureBoxMap.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxMap.TabIndex = 0;
|
||||
this.pictureBoxMap.TabStop = false;
|
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelBodyColor});
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 424);
|
||||
this.statusStrip.Name = "statusStrip";
|
||||
this.statusStrip.Size = new System.Drawing.Size(800, 26);
|
||||
this.statusStrip.TabIndex = 1;
|
||||
this.statusStrip.Text = "statusStrip1";
|
||||
//
|
||||
// toolStripStatusLabelSpeed
|
||||
//
|
||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(76, 20);
|
||||
this.toolStripStatusLabelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// toolStripStatusLabelWeight
|
||||
//
|
||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(36, 20);
|
||||
this.toolStripStatusLabelWeight.Text = "Вес:";
|
||||
//
|
||||
// toolStripStatusLabelBodyColor
|
||||
//
|
||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20);
|
||||
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
|
||||
//
|
||||
// ButtonCreate
|
||||
//
|
||||
this.ButtonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.ButtonCreate.Location = new System.Drawing.Point(12, 381);
|
||||
this.ButtonCreate.Name = "ButtonCreate";
|
||||
this.ButtonCreate.Size = new System.Drawing.Size(94, 29);
|
||||
this.ButtonCreate.TabIndex = 2;
|
||||
this.ButtonCreate.Text = "Создать";
|
||||
this.ButtonCreate.UseVisualStyleBackColor = true;
|
||||
this.ButtonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// ButtonUp
|
||||
//
|
||||
this.ButtonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonUp.BackgroundImage = global::Boats.Properties.Resources.arrow_up;
|
||||
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonUp.Location = new System.Drawing.Point(710, 344);
|
||||
this.ButtonUp.Name = "ButtonUp";
|
||||
this.ButtonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonUp.TabIndex = 3;
|
||||
this.ButtonUp.UseVisualStyleBackColor = true;
|
||||
this.ButtonUp.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::Boats.Properties.Resources.arrow_left;
|
||||
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonLeft.Location = new System.Drawing.Point(674, 380);
|
||||
this.ButtonLeft.Name = "ButtonLeft";
|
||||
this.ButtonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonLeft.TabIndex = 4;
|
||||
this.ButtonLeft.UseVisualStyleBackColor = true;
|
||||
this.ButtonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// ButtonRight
|
||||
//
|
||||
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonRight.BackgroundImage = global::Boats.Properties.Resources.arrow_right;
|
||||
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonRight.Location = new System.Drawing.Point(746, 380);
|
||||
this.ButtonRight.Name = "ButtonRight";
|
||||
this.ButtonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonRight.TabIndex = 5;
|
||||
this.ButtonRight.UseVisualStyleBackColor = true;
|
||||
this.ButtonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
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.maskedTextBoxPosition);
|
||||
this.groupBox.Controls.Add(this.ButtonShowOnMap);
|
||||
this.groupBox.Controls.Add(this.ButtonShowStorage);
|
||||
this.groupBox.Controls.Add(this.ButtonRemoveBoat);
|
||||
this.groupBox.Controls.Add(this.ButtonAddBoat);
|
||||
this.groupBox.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox.Location = new System.Drawing.Point(901, 0);
|
||||
this.groupBox.Name = "groupBox";
|
||||
this.groupBox.Size = new System.Drawing.Size(250, 589);
|
||||
this.groupBox.TabIndex = 0;
|
||||
this.groupBox.TabStop = false;
|
||||
this.groupBox.Text = "Инструменты";
|
||||
//
|
||||
// ButtonDown
|
||||
//
|
||||
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonDown.BackgroundImage = global::Boats.Properties.Resources.arrow_down;
|
||||
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonDown.Location = new System.Drawing.Point(710, 380);
|
||||
this.ButtonDown.Location = new System.Drawing.Point(99, 537);
|
||||
this.ButtonDown.Name = "ButtonDown";
|
||||
this.ButtonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonDown.TabIndex = 6;
|
||||
this.ButtonDown.TabIndex = 10;
|
||||
this.ButtonDown.UseVisualStyleBackColor = true;
|
||||
this.ButtonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// ButtonCreateModificate
|
||||
// ButtonRight
|
||||
//
|
||||
this.ButtonCreateModificate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.ButtonCreateModificate.Location = new System.Drawing.Point(138, 381);
|
||||
this.ButtonCreateModificate.Name = "ButtonCreateModificate";
|
||||
this.ButtonCreateModificate.Size = new System.Drawing.Size(117, 29);
|
||||
this.ButtonCreateModificate.TabIndex = 7;
|
||||
this.ButtonCreateModificate.Text = "Модификация";
|
||||
this.ButtonCreateModificate.UseVisualStyleBackColor = true;
|
||||
this.ButtonCreateModificate.Click += new System.EventHandler(this.ButtonCreateModificate_Click);
|
||||
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonRight.BackgroundImage = global::Boats.Properties.Resources.arrow_right;
|
||||
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonRight.Location = new System.Drawing.Point(135, 537);
|
||||
this.ButtonRight.Name = "ButtonRight";
|
||||
this.ButtonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonRight.TabIndex = 9;
|
||||
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::Boats.Properties.Resources.arrow_left;
|
||||
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonLeft.Location = new System.Drawing.Point(63, 537);
|
||||
this.ButtonLeft.Name = "ButtonLeft";
|
||||
this.ButtonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonLeft.TabIndex = 8;
|
||||
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::Boats.Properties.Resources.arrow_up;
|
||||
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonUp.Location = new System.Drawing.Point(99, 501);
|
||||
this.ButtonUp.Name = "ButtonUp";
|
||||
this.ButtonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonUp.TabIndex = 7;
|
||||
this.ButtonUp.UseVisualStyleBackColor = true;
|
||||
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 168);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(232, 27);
|
||||
this.maskedTextBoxPosition.TabIndex = 5;
|
||||
//
|
||||
// ButtonShowOnMap
|
||||
//
|
||||
this.ButtonShowOnMap.Location = new System.Drawing.Point(6, 389);
|
||||
this.ButtonShowOnMap.Name = "ButtonShowOnMap";
|
||||
this.ButtonShowOnMap.Size = new System.Drawing.Size(232, 40);
|
||||
this.ButtonShowOnMap.TabIndex = 4;
|
||||
this.ButtonShowOnMap.Text = "Просмотреть карту";
|
||||
this.ButtonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.ButtonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
//
|
||||
// ButtonShowStorage
|
||||
//
|
||||
this.ButtonShowStorage.Location = new System.Drawing.Point(6, 303);
|
||||
this.ButtonShowStorage.Name = "ButtonShowStorage";
|
||||
this.ButtonShowStorage.Size = new System.Drawing.Size(232, 40);
|
||||
this.ButtonShowStorage.TabIndex = 3;
|
||||
this.ButtonShowStorage.Text = "Просмотреть хранилище";
|
||||
this.ButtonShowStorage.UseVisualStyleBackColor = true;
|
||||
this.ButtonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||
//
|
||||
// ButtonRemoveBoat
|
||||
//
|
||||
this.ButtonRemoveBoat.Location = new System.Drawing.Point(6, 212);
|
||||
this.ButtonRemoveBoat.Name = "ButtonRemoveBoat";
|
||||
this.ButtonRemoveBoat.Size = new System.Drawing.Size(232, 40);
|
||||
this.ButtonRemoveBoat.TabIndex = 2;
|
||||
this.ButtonRemoveBoat.Text = "Удалить лодку";
|
||||
this.ButtonRemoveBoat.UseVisualStyleBackColor = true;
|
||||
this.ButtonRemoveBoat.Click += new System.EventHandler(this.ButtonRemoveBoat_Click);
|
||||
//
|
||||
// ButtonAddBoat
|
||||
//
|
||||
this.ButtonAddBoat.Location = new System.Drawing.Point(6, 97);
|
||||
this.ButtonAddBoat.Name = "ButtonAddBoat";
|
||||
this.ButtonAddBoat.Size = new System.Drawing.Size(232, 40);
|
||||
this.ButtonAddBoat.TabIndex = 1;
|
||||
this.ButtonAddBoat.Text = "Добавить лодку";
|
||||
this.ButtonAddBoat.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddBoat.Click += new System.EventHandler(this.ButtonAddBoat_Click);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
@ -163,49 +168,50 @@
|
||||
"Простая карта",
|
||||
"Океан карта",
|
||||
"Линии карта"});
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
|
||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 26);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
|
||||
this.comboBoxSelectorMap.TabIndex = 8;
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(238, 28);
|
||||
this.comboBoxSelectorMap.TabIndex = 0;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||
//
|
||||
// FormMap
|
||||
// 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(901, 589);
|
||||
this.pictureBox.TabIndex = 1;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// FormMapWithSetBoats
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.Controls.Add(this.ButtonCreateModificate);
|
||||
this.Controls.Add(this.ButtonDown);
|
||||
this.Controls.Add(this.ButtonRight);
|
||||
this.Controls.Add(this.ButtonLeft);
|
||||
this.Controls.Add(this.ButtonUp);
|
||||
this.Controls.Add(this.ButtonCreate);
|
||||
this.Controls.Add(this.pictureBoxMap);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.Name = "FormMap";
|
||||
this.Text = "Лодка";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxMap)).EndInit();
|
||||
this.statusStrip.ResumeLayout(false);
|
||||
this.statusStrip.PerformLayout();
|
||||
this.ClientSize = new System.Drawing.Size(1151, 589);
|
||||
this.Controls.Add(this.pictureBox);
|
||||
this.Controls.Add(this.groupBox);
|
||||
this.Name = "FormMapWithSetBoats";
|
||||
this.Text = "Карта с набором элементов";
|
||||
this.groupBox.ResumeLayout(false);
|
||||
this.groupBox.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxMap;
|
||||
private StatusStrip statusStrip;
|
||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||
private Button ButtonCreate;
|
||||
private Button ButtonUp;
|
||||
private Button ButtonLeft;
|
||||
private Button ButtonRight;
|
||||
private Button ButtonDown;
|
||||
private Button ButtonCreateModificate;
|
||||
private GroupBox groupBox;
|
||||
private MaskedTextBox maskedTextBoxPosition;
|
||||
private Button ButtonShowOnMap;
|
||||
private Button ButtonShowStorage;
|
||||
private Button ButtonRemoveBoat;
|
||||
private Button ButtonAddBoat;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private PictureBox pictureBox;
|
||||
private Button ButtonDown;
|
||||
private Button ButtonRight;
|
||||
private Button ButtonLeft;
|
||||
private Button ButtonUp;
|
||||
}
|
||||
}
|
173
Boats/Boats/FormMapWithSetBoats.cs
Normal file
173
Boats/Boats/FormMapWithSetBoats.cs
Normal file
@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Boats
|
||||
{
|
||||
public partial class FormMapWithSetBoats : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект от класса карты с набором объектов
|
||||
/// </summary>
|
||||
private MapWithSetBoatsGeneric<DrawingObjectBoat, AbstractMap> _mapBoatsCollectionGeneric;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormMapWithSetBoats()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Выбор карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
switch (comboBoxSelectorMap.Text)
|
||||
{
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Линии карта":
|
||||
map = new LineMap();
|
||||
break;
|
||||
case "Океан карта":
|
||||
map = new OceanMap();
|
||||
break;
|
||||
}
|
||||
if (map != null)
|
||||
{
|
||||
_mapBoatsCollectionGeneric = new MapWithSetBoatsGeneric<DrawingObjectBoat, AbstractMap>(
|
||||
pictureBox.Width, pictureBox.Height, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapBoatsCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddBoat_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapBoatsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormBoat form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
bool added = false;
|
||||
if (form.SelectedBoat != null)
|
||||
{
|
||||
DrawingObjectBoat boat = new(form.SelectedBoat);
|
||||
if (_mapBoatsCollectionGeneric + boat != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapBoatsCollectionGeneric.ShowSet();
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
if (!added)
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveBoat_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
pos -= 1;
|
||||
if (_mapBoatsCollectionGeneric - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _mapBoatsCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapBoatsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapBoatsCollectionGeneric.ShowSet();
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapBoatsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBox.Image = _mapBoatsCollectionGeneric.ShowOnMap();
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapBoatsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
Direction dir = Direction.None;
|
||||
switch (name)
|
||||
{
|
||||
case "ButtonUp":
|
||||
dir = Direction.Up;
|
||||
break;
|
||||
case "ButtonDown":
|
||||
dir = Direction.Down;
|
||||
break;
|
||||
case "ButtonLeft":
|
||||
dir = Direction.Left;
|
||||
break;
|
||||
case "ButtonRight":
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
}
|
||||
pictureBox.Image = _mapBoatsCollectionGeneric.MoveObject(dir);
|
||||
}
|
||||
}
|
||||
}
|
@ -57,7 +57,4 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -11,7 +11,7 @@ namespace Boats
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormMap());
|
||||
Application.Run(new FormMapWithSetBoats());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user