From d1bfd8cebe0b0fe83020930c136038f81358fa29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=9A=D1=83=D0=B4=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Sun, 10 Mar 2024 15:11:14 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=80=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=B8=20=D0=B2=D0=B2=D0=BE=D0=B4=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => Drawings}/DirectionType.cs | 2 +- .../Drawings/DrawningContainerShip.cs | 67 ++++++++++ .../DrawningShip.cs} | 124 ++++++++---------- .../Entities/EntityContainerShip.cs | 39 ++++++ .../Entities/EntityShip.cs | 40 ++++++ .../EntityContainerShip.cs | 62 --------- .../FormContainerShip.Designer.cs | 18 ++- .../ProjectContainerShip/FormContainerShip.cs | 63 ++++++--- 8 files changed, 258 insertions(+), 157 deletions(-) rename ProjectContainerShip/ProjectContainerShip/{ => Drawings}/DirectionType.cs (87%) create mode 100644 ProjectContainerShip/ProjectContainerShip/Drawings/DrawningContainerShip.cs rename ProjectContainerShip/ProjectContainerShip/{DrawningContainerShip.cs => Drawings/DrawningShip.cs} (60%) create mode 100644 ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs create mode 100644 ProjectContainerShip/ProjectContainerShip/Entities/EntityShip.cs delete mode 100644 ProjectContainerShip/ProjectContainerShip/EntityContainerShip.cs diff --git a/ProjectContainerShip/ProjectContainerShip/DirectionType.cs b/ProjectContainerShip/ProjectContainerShip/Drawings/DirectionType.cs similarity index 87% rename from ProjectContainerShip/ProjectContainerShip/DirectionType.cs rename to ProjectContainerShip/ProjectContainerShip/Drawings/DirectionType.cs index 0759eab..735683f 100644 --- a/ProjectContainerShip/ProjectContainerShip/DirectionType.cs +++ b/ProjectContainerShip/ProjectContainerShip/Drawings/DirectionType.cs @@ -1,4 +1,4 @@ -namespace ProjectContainerShip; +namespace ProjectContainerShip.Drawings; public enum DirectionType { diff --git a/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningContainerShip.cs new file mode 100644 index 0000000..80d6e61 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningContainerShip.cs @@ -0,0 +1,67 @@ +using ProjectContainerShip.Entities; + +namespace ProjectContainerShip.Drawings; + +public class DrawningContainerShip : DrawningShip +{ + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия крана + /// Признак наличия контейнеров + public DrawningContainerShip(int speed, double weight, Color bodycolor, Color additionalcolor, bool crane, bool container) : base(120,40) + { + EntityShip = new EntityContainerShip(speed, weight, bodycolor, additionalcolor, crane, container); + } + + public override void DrawTransport(Graphics g) + { + if (EntityShip == null || EntityShip is not EntityContainerShip containerShip || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + Pen pen = new(Color.Black); + Brush additionalBrush = new SolidBrush(containerShip.AdditionalColor); + + if (containerShip.Container) + + { + // Верхний маленький контейнер + Point[] container = + { + new Point((int)_startPosX + 30, (int)_startPosY + 10), + new Point((int)_startPosX + 30, (int)_startPosY ), + new Point((int)_startPosX + 55, (int)_startPosY), + new Point((int)_startPosX + 55, (int)_startPosY + 10) + }; + + g.FillPolygon(additionalBrush, container); + g.DrawPolygon(pen, container); + + //Контейнер под маленьким контейнером + g.FillRectangle(additionalBrush, (int)_startPosX + 20, (int)_startPosY + 10, 27, 10); + g.DrawRectangle(pen, (int)_startPosX + 20, (int)_startPosY + 10, 27, 10); + + } + + base.DrawTransport(g); + + if (containerShip.Crane) + { + g.DrawLine(pen, (int)_startPosX + 70, (int)_startPosY + 10, (int)_startPosX + 70, (int)_startPosY); + g.DrawLine(pen, (int)_startPosX + 70, (int)_startPosY, (int)_startPosX + 110, (int)_startPosY); + g.DrawLine(pen, (int)_startPosX + 70, (int)_startPosY, (int)_startPosX + 110, (int)_startPosY + 5); + g.DrawLine(pen, (int)_startPosX + 110, (int)_startPosY, (int)_startPosX + 110, (int)_startPosY + 30); + + //Хваталка контейнера + g.DrawLine(pen, (int)(_startPosX + 100), (int)(_startPosY + 30), (int)_startPosX + 120, (int)(_startPosY + 30)); + g.DrawLine(pen, (int)(_startPosX + 100), (int)(_startPosY + 30), (int)_startPosX + 100, (int)(_startPosY + 35)); + g.DrawLine(pen, (int)(_startPosX + 120), (int)(_startPosY + 30), (int)_startPosX + 120, (int)(_startPosY + 35)); + } + } +} diff --git a/ProjectContainerShip/ProjectContainerShip/DrawningContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningShip.cs similarity index 60% rename from ProjectContainerShip/ProjectContainerShip/DrawningContainerShip.cs rename to ProjectContainerShip/ProjectContainerShip/Drawings/DrawningShip.cs index 6ce9893..af340f2 100644 --- a/ProjectContainerShip/ProjectContainerShip/DrawningContainerShip.cs +++ b/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningShip.cs @@ -1,11 +1,18 @@ -namespace ProjectContainerShip; +using ProjectContainerShip.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; -public class DrawningContainerShip +namespace ProjectContainerShip.Drawings; + +public class DrawningShip { /// /// Класс-сущность /// - public EntityContainerShip? EntityContainerShip { get; private set; } + public EntityShip? EntityShip { get; protected set; } /// /// Ширина окна @@ -20,42 +27,56 @@ public class DrawningContainerShip /// /// Левая координата прорисовки контейнеровоза /// - private int? _startPosX; + protected int? _startPosX; /// /// Верхняя координата прорисовки контейнеровоза /// - private int? _startPosY; + protected int? _startPosY; /// /// Ширина прорисовки контейнеровоза /// - private readonly int _drawningContainerShipWidth = 120; + private readonly int _drawningContainerShipWidth = 100; /// /// Высота прорисовки контейнеровоза /// - private readonly int _drawningContainerShipHeight = 40; + private readonly int _drawningContainerShipHeight = 30; /// - /// Инициализация свойств + /// Пустой конструктор /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия крана - /// Признак наличия контейнеров - public void Init(int speed, double weight, Color bodycolor, Color additionalcolor, bool crane, bool container) + private DrawningShip() { - EntityContainerShip = new EntityContainerShip(); - EntityContainerShip.Init(speed,weight,bodycolor,additionalcolor,crane,container); _pictureWidth = null; _pictureHeight = null; _startPosX = null; _startPosY = null; } + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + public DrawningShip(int speed, double weight, Color bodycolor) : this() + { + EntityShip = new EntityShip(speed, weight, bodycolor); + } + + /// + /// Конструктор для наследников + /// + /// Ширина прорисовки корабля + /// Высота прорисовки корабля + protected DrawningShip(int drawningContainerShipWidth, int drawningContainerShipHeight) : this() + { + _drawningContainerShipWidth = drawningContainerShipWidth; + _drawningContainerShipHeight = drawningContainerShipHeight; + } + /// /// Установка границ поля /// @@ -64,7 +85,7 @@ public class DrawningContainerShip /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах public bool SetPictureSize(int width, int height) { - if (_drawningContainerShipWidth > width || _drawningContainerShipHeight> height) + if (_drawningContainerShipWidth > width || _drawningContainerShipHeight > height) { return false; } @@ -98,7 +119,7 @@ public class DrawningContainerShip { return; } - + if (x + _drawningContainerShipWidth > _pictureWidth) { _startPosX = _pictureWidth - _drawningContainerShipWidth; @@ -121,7 +142,7 @@ public class DrawningContainerShip /// true - перемещене выполнено, false - перемещение невозможно public bool MoveTransport(DirectionType direction) { - if (EntityContainerShip == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityShip == null || !_startPosX.HasValue || !_startPosY.HasValue) { return false; } @@ -130,30 +151,30 @@ public class DrawningContainerShip { //влево case DirectionType.Left: - if (_startPosX.Value - EntityContainerShip.Step > 0) + if (_startPosX.Value - EntityShip.Step > 0) { - _startPosX -= (int)EntityContainerShip.Step; + _startPosX -= (int)EntityShip.Step; } return true; //вверх case DirectionType.Up: - if (_startPosY.Value - EntityContainerShip.Step > 0) + if (_startPosY.Value - EntityShip.Step > 0) { - _startPosY -= (int)EntityContainerShip.Step; + _startPosY -= (int)EntityShip.Step; } return true; // вправо case DirectionType.Right: - if (_startPosX.Value + _drawningContainerShipWidth + EntityContainerShip.Step < _pictureWidth) + if (_startPosX.Value + _drawningContainerShipWidth + EntityShip.Step < _pictureWidth) { - _startPosX += (int)EntityContainerShip.Step; + _startPosX += (int)EntityShip.Step; } return true; //вниз case DirectionType.Down: - if (_startPosY.Value + _drawningContainerShipHeight + EntityContainerShip.Step < _pictureHeight) + if (_startPosY.Value + _drawningContainerShipHeight + EntityShip.Step < _pictureHeight) { - _startPosY += (int)EntityContainerShip.Step; + _startPosY += (int)EntityShip.Step; } return true; default: @@ -165,15 +186,14 @@ public class DrawningContainerShip /// Прорисовка объекта /// /// - public void DrawTransport(Graphics g) + public virtual void DrawTransport(Graphics g) { - if (EntityContainerShip == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityShip == null || !_startPosX.HasValue || !_startPosY.HasValue) { return; } Pen pen = new(Color.Black); - Brush additionalBrush = new SolidBrush(EntityContainerShip.AdditionalColor); //Корпус контейнеровоза g.DrawPolygon(pen, new Point[] @@ -184,8 +204,7 @@ public class DrawningContainerShip } ); - - Brush br = new SolidBrush(EntityContainerShip.BodyColor); + Brush br = new SolidBrush(EntityShip.BodyColor); g.FillPolygon(br, new Point[] { new Point((int)_startPosX+10,(int)_startPosY+20),new Point((int)_startPosX+100,(int)_startPosY+20), @@ -200,44 +219,7 @@ public class DrawningContainerShip g.DrawLine(pen, (int)_startPosX + 26, (int)_startPosY + 31, (int)_startPosX + 30, (int)_startPosY + 31); //Длинный контейнер справа - g.DrawRectangle(pen,(int)_startPosX+40,(int)_startPosY+10,57,10); + g.DrawRectangle(pen, (int)_startPosX + 40, (int)_startPosY + 10, 57, 10); g.FillRectangle(br, (int)_startPosX + 40, (int)_startPosY + 10, 57, 10); - - //Кран - if (EntityContainerShip.Crane) - { - g.DrawLine(pen, (int)_startPosX + 70, (int)_startPosY + 10, (int)_startPosX + 70, (int)_startPosY); - g.DrawLine(pen, (int)_startPosX + 70, (int)_startPosY, (int)_startPosX + 110, (int)_startPosY); - g.DrawLine(pen, (int)_startPosX + 70, (int)_startPosY, (int)_startPosX + 110, (int)_startPosY + 5); - g.DrawLine(pen, (int)_startPosX + 110, (int)_startPosY, (int)_startPosX + 110, (int)_startPosY + 30); - - //Хваталка контейнера - g.DrawLine(pen,(int)(_startPosX + 100),(int)(_startPosY + 30), (int)_startPosX + 120, (int)(_startPosY + 30)); - g.DrawLine(pen, (int)(_startPosX + 100), (int)(_startPosY + 30), (int)_startPosX + 100, (int)(_startPosY + 35)); - g.DrawLine(pen, (int)(_startPosX + 120), (int)(_startPosY + 30), (int)_startPosX + 120, (int)(_startPosY + 35)); - } - - //Контейнер - if (EntityContainerShip.Container) - - { - // Верхний маленький контейнер - Point[] container = - { - new Point((int)_startPosX + 30, (int)_startPosY + 10), - new Point((int)_startPosX + 30, (int)_startPosY ), - new Point((int)_startPosX + 55, (int)_startPosY), - new Point((int)_startPosX + 55, (int)_startPosY + 10) - }; - - g.FillPolygon(additionalBrush, container); - g.DrawPolygon(pen, container); - - //Контейнер под маленьким контейнером - g.FillRectangle(additionalBrush, (int)_startPosX + 20, (int)_startPosY + 10, 27, 10); - g.DrawRectangle(pen, (int)_startPosX + 20, (int)_startPosY + 10, 27, 10); - - } } - } diff --git a/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs new file mode 100644 index 0000000..00fb2b8 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs @@ -0,0 +1,39 @@ +namespace ProjectContainerShip.Entities; + +/// +/// Класс-сущность Контейнеровоз +/// +public class EntityContainerShip : EntityShip +{ + /// + /// Дополнительный цвет (для опциональных элементов) + /// + public Color AdditionalColor { get; private set; } + + /// + /// Признак (опция) наличия крана + /// + public bool Crane { get; private set; } + + /// + /// Признак (опция) наличия контейнеров + /// + public bool Container { get; private set; } + + /// + /// + /// + /// Скорость + /// Вес контейнеровоза + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия крана + /// Признак наличия контейнеров + public EntityContainerShip(int speed, double weight, Color bodyColor, Color additionalColor, bool crane, bool container) : base(speed,weight,bodyColor) + { + AdditionalColor = additionalColor; + Crane = crane; + Container = container; + } + +} diff --git a/ProjectContainerShip/ProjectContainerShip/Entities/EntityShip.cs b/ProjectContainerShip/ProjectContainerShip/Entities/EntityShip.cs new file mode 100644 index 0000000..f231d27 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/Entities/EntityShip.cs @@ -0,0 +1,40 @@ +namespace ProjectContainerShip.Entities; + +/// +/// Класс-сущность "Корабль" +/// +public class EntityShip +{ + /// + /// Скорость + /// + public int Speed { get; private set; } + + /// + /// Вес + /// + public double Weight { get; private set; } + + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + + /// + /// Шаг перемещения грузового судна + /// + public double Step => Speed * 100 / Weight; + + /// + /// Конструктор сущности + /// + /// Скорость + /// Вес контейнеровоза + /// Основной цвет + public EntityShip(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } +} diff --git a/ProjectContainerShip/ProjectContainerShip/EntityContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/EntityContainerShip.cs deleted file mode 100644 index 2e6654b..0000000 --- a/ProjectContainerShip/ProjectContainerShip/EntityContainerShip.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace ProjectContainerShip; - - /// - /// Класс-сущность Контейнеровоз - /// - public class EntityContainerShip - { - /// - /// Скорость - /// - public int Speed { get; private set; } - - /// - /// Вес - /// - public double Weight { get; private set; } - - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } - - /// - /// Дополнительный цвет (для опциональных элементов) - /// - public Color AdditionalColor { get; private set; } - - /// - /// Признак (опция) наличия обвеса - /// - public bool Crane { get; private set; } - - /// - /// Признак (опция) наличия контейнеров - /// - public bool Container { get; private set; } - - /// - /// Шаг перемещения грузового судна - /// - public double Step => Speed * 100 / Weight; - - /// - /// - /// - /// Скорость - /// Вес контейнеровоза - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия крана - /// Признак наличия контейнеров - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool crane, bool container) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; - AdditionalColor = additionalColor; - Crane = crane; - Container = container; - } - - } diff --git a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs index e38cb64..80ca97c 100644 --- a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs +++ b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs @@ -34,6 +34,7 @@ buttonRight = new Button(); buttonDown = new Button(); buttonUp = new Button(); + buttonCreateShip = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxContainerShip).BeginInit(); SuspendLayout(); // @@ -51,9 +52,9 @@ buttonCreateContainerShip.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonCreateContainerShip.Location = new Point(12, 457); buttonCreateContainerShip.Name = "buttonCreateContainerShip"; - buttonCreateContainerShip.Size = new Size(150, 46); + buttonCreateContainerShip.Size = new Size(316, 46); buttonCreateContainerShip.TabIndex = 1; - buttonCreateContainerShip.Text = "Создать"; + buttonCreateContainerShip.Text = "Создать контейнеровоз"; buttonCreateContainerShip.UseVisualStyleBackColor = true; buttonCreateContainerShip.Click += ButtonCreateContainerShip_Click; // @@ -105,11 +106,23 @@ buttonUp.UseVisualStyleBackColor = true; buttonUp.Click += ButtonMove_Click; // + // buttonCreateShip + // + buttonCreateShip.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateShip.Location = new Point(358, 457); + buttonCreateShip.Name = "buttonCreateShip"; + buttonCreateShip.Size = new Size(316, 46); + buttonCreateShip.TabIndex = 6; + buttonCreateShip.Text = "Создать корабль"; + buttonCreateShip.UseVisualStyleBackColor = true; + buttonCreateShip.Click += ButtonCreateShip_Click; + // // FormContainerShip // AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1256, 529); + Controls.Add(buttonCreateShip); Controls.Add(buttonUp); Controls.Add(buttonDown); Controls.Add(buttonRight); @@ -132,5 +145,6 @@ private Button buttonRight; private Button buttonDown; private Button buttonUp; + private Button buttonCreateShip; } } \ No newline at end of file diff --git a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.cs index 2d7fbba..5992cab 100644 --- a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.cs +++ b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.cs @@ -1,4 +1,5 @@ using System; +using ProjectContainerShip.Drawings; namespace ProjectContainerShip; @@ -10,7 +11,7 @@ public partial class FormContainerShip : Form /// /// Поле-объект для прорисовки объекта /// - private DrawningContainerShip? _drawningContainerShip; + private DrawningShip? _drawningShip; /// /// Конструктор формы @@ -25,34 +26,54 @@ public partial class FormContainerShip : Form /// private void Draw() { - if (_drawningContainerShip == null) + if (_drawningShip == null) { return; } Bitmap bmp = new(pictureBoxContainerShip.Width, pictureBoxContainerShip.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningContainerShip.DrawTransport(gr); + _drawningShip.DrawTransport(gr); pictureBoxContainerShip.Image = bmp; } + private void CreateObject(string type) + { + Random random = new(); + switch (type) + { + case nameof(DrawningShip): + _drawningShip = new DrawningShip(random.Next(100, 300), random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256))); + break; + case nameof(DrawningContainerShip): + _drawningShip = new DrawningContainerShip(random.Next(100, 300), random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + break; + default: + return; + } + + _drawningShip.SetPictureSize(pictureBoxContainerShip.Width, pictureBoxContainerShip.Height); + _drawningShip.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } + /// - /// Обработка нажатия кнопки "Создать" + /// Обработка нажатия кнопки "Создать контейнеровоз" /// /// /// - private void ButtonCreateContainerShip_Click(object sender, EventArgs e) - { - Random random = new(); - _drawningContainerShip = new DrawningContainerShip(); - _drawningContainerShip.Init(random.Next(100, 300), random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); - _drawningContainerShip.SetPictureSize(pictureBoxContainerShip.Width, pictureBoxContainerShip.Height); - _drawningContainerShip.SetPosition(random.Next(10, 100), random.Next(10, 100)); - Draw(); - } + private void ButtonCreateContainerShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningContainerShip)); + + /// + /// Обработка нажатия кнопки "Создать корабль" + /// + /// + /// + private void ButtonCreateShip_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningShip)); /// /// Перемещение объекта по форме (нажатие кнопок навигации) @@ -61,7 +82,7 @@ public partial class FormContainerShip : Form /// private void ButtonMove_Click(object sender, EventArgs e) { - if (_drawningContainerShip == null) + if (_drawningShip == null) { return; } @@ -71,16 +92,16 @@ public partial class FormContainerShip : Form switch (name) { case "buttonUp": - result = _drawningContainerShip.MoveTransport(DirectionType.Up); + result = _drawningShip.MoveTransport(DirectionType.Up); break; case "buttonDown": - result = _drawningContainerShip.MoveTransport(DirectionType.Down); + result = _drawningShip.MoveTransport(DirectionType.Down); break; case "buttonLeft": - result = _drawningContainerShip.MoveTransport(DirectionType.Left); + result = _drawningShip.MoveTransport(DirectionType.Left); break; case "buttonRight": - result = _drawningContainerShip.MoveTransport(DirectionType.Right); + result = _drawningShip.MoveTransport(DirectionType.Right); break; } -- 2.25.1 From d8b8e68bb74f387e622192d127a59fb002ed7b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=9A=D1=83=D0=B4=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Sun, 10 Mar 2024 17:42:44 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D1=80=D0=B0=D1=82=D0=B5=D0=B3?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drawings/DirectionType.cs | 5 + .../Drawings/DrawningShip.cs | 20 +++ .../FormContainerShip.Designer.cs | 35 ++++- .../ProjectContainerShip/FormContainerShip.cs | 49 +++++++ .../MovementStrategy/AbstractStrategy.cs | 132 ++++++++++++++++++ .../MovementStrategy/IMoveableObjects.cs | 21 +++ .../MovementStrategy/MoveToBorder.cs | 31 ++++ .../MovementStrategy/MoveToCenter.cs | 54 +++++++ .../MovementStrategy/MoveableShip.cs | 64 +++++++++ .../MovementStrategy/MovementDirection.cs | 27 ++++ .../MovementStrategy/ObjectParameters.cs | 69 +++++++++ .../MovementStrategy/StrategyStatus.cs | 22 +++ 12 files changed, 528 insertions(+), 1 deletion(-) create mode 100644 ProjectContainerShip/ProjectContainerShip/MovementStrategy/AbstractStrategy.cs create mode 100644 ProjectContainerShip/ProjectContainerShip/MovementStrategy/IMoveableObjects.cs create mode 100644 ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveToBorder.cs create mode 100644 ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveToCenter.cs create mode 100644 ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveableShip.cs create mode 100644 ProjectContainerShip/ProjectContainerShip/MovementStrategy/MovementDirection.cs create mode 100644 ProjectContainerShip/ProjectContainerShip/MovementStrategy/ObjectParameters.cs create mode 100644 ProjectContainerShip/ProjectContainerShip/MovementStrategy/StrategyStatus.cs diff --git a/ProjectContainerShip/ProjectContainerShip/Drawings/DirectionType.cs b/ProjectContainerShip/ProjectContainerShip/Drawings/DirectionType.cs index 735683f..9706f84 100644 --- a/ProjectContainerShip/ProjectContainerShip/Drawings/DirectionType.cs +++ b/ProjectContainerShip/ProjectContainerShip/Drawings/DirectionType.cs @@ -2,6 +2,11 @@ public enum DirectionType { + /// + /// Неизвестное направление + /// + Unknow = -1, + /// /// Вверх /// diff --git a/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningShip.cs b/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningShip.cs index af340f2..8d15fa6 100644 --- a/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningShip.cs +++ b/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningShip.cs @@ -44,6 +44,26 @@ public class DrawningShip /// private readonly int _drawningContainerShipHeight = 30; + /// + /// Координата X объекта + /// + public int? GetPosX => _startPosX; + + /// + /// Координата Y объекта + /// + public int? GetPosY => _startPosY; + + /// + /// Ширина объекта + /// + public int GetWidth => _drawningContainerShipWidth; + + /// + /// Высота объекта + /// + public int GetHeight => _drawningContainerShipHeight; + /// /// Пустой конструктор /// diff --git a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs index 80ca97c..c044adc 100644 --- a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs +++ b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs @@ -1,4 +1,5 @@ -namespace ProjectContainerShip + +namespace ProjectContainerShip { partial class FormContainerShip { @@ -35,6 +36,8 @@ buttonDown = new Button(); buttonUp = new Button(); buttonCreateShip = new Button(); + comboBoxStrategy = new ComboBox(); + buttonStrategyStep = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxContainerShip).BeginInit(); SuspendLayout(); // @@ -46,6 +49,7 @@ pictureBoxContainerShip.Size = new Size(1256, 529); pictureBoxContainerShip.TabIndex = 0; pictureBoxContainerShip.TabStop = false; + pictureBoxContainerShip.Click += pictureBoxContainerShip_Click; // // buttonCreateContainerShip // @@ -117,11 +121,33 @@ buttonCreateShip.UseVisualStyleBackColor = true; buttonCreateShip.Click += ButtonCreateShip_Click; // + // comboBoxStrategy + // + comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStrategy.FormattingEnabled = true; + comboBoxStrategy.Items.AddRange(new object[] { "К центру ", "К краю" }); + comboBoxStrategy.Location = new Point(1002, 12); + comboBoxStrategy.Name = "comboBoxStrategy"; + comboBoxStrategy.Size = new Size(242, 40); + comboBoxStrategy.TabIndex = 7; + // + // buttonStrategyStep + // + buttonStrategyStep.Location = new Point(1094, 58); + buttonStrategyStep.Name = "buttonStrategyStep"; + buttonStrategyStep.Size = new Size(150, 46); + buttonStrategyStep.TabIndex = 8; + buttonStrategyStep.Text = "Шаг"; + buttonStrategyStep.UseVisualStyleBackColor = true; + buttonStrategyStep.Click += ButtonStrategyStep_Click; + // // FormContainerShip // AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1256, 529); + Controls.Add(buttonStrategyStep); + Controls.Add(comboBoxStrategy); Controls.Add(buttonCreateShip); Controls.Add(buttonUp); Controls.Add(buttonDown); @@ -135,6 +161,11 @@ ResumeLayout(false); } + private void pictureBoxContainerShip_Click(object sender, EventArgs e) + { + throw new NotImplementedException(); + } + #endregion @@ -146,5 +177,7 @@ private Button buttonDown; private Button buttonUp; private Button buttonCreateShip; + private ComboBox comboBoxStrategy; + private Button buttonStrategyStep; } } \ No newline at end of file diff --git a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.cs index 5992cab..9f02e7f 100644 --- a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.cs +++ b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.cs @@ -1,5 +1,6 @@ using System; using ProjectContainerShip.Drawings; +using ProjectContainerShip.MovementStrategy; namespace ProjectContainerShip; @@ -13,12 +14,18 @@ public partial class FormContainerShip : Form /// private DrawningShip? _drawningShip; + /// + /// Стратегия перемещения + /// + private AbstractStrategy? _strategy; + /// /// Конструктор формы /// public FormContainerShip() { InitializeComponent(); + _strategy = null; } /// @@ -58,6 +65,8 @@ public partial class FormContainerShip : Form _drawningShip.SetPictureSize(pictureBoxContainerShip.Width, pictureBoxContainerShip.Height); _drawningShip.SetPosition(random.Next(10, 100), random.Next(10, 100)); + _strategy = null; + comboBoxStrategy.Enabled = true; Draw(); } @@ -110,4 +119,44 @@ public partial class FormContainerShip : Form Draw(); } } + + /// + /// + /// + /// + /// + private void ButtonStrategyStep_Click(object sender, EventArgs e) + { + if (_drawningShip == null) return; + + if (comboBoxStrategy.Enabled) + { + _strategy = comboBoxStrategy.SelectedIndex switch + { + 0 => new MoveToCenter(), + 1 => new MoveToBorder(), + _ => null, + }; + if (_strategy == null) + { + return; + } + _strategy.SetData(new MoveableShip(_drawningShip), pictureBoxContainerShip.Width, pictureBoxContainerShip.Height); + } + + if (_strategy == null) + { + return; + } + + comboBoxStrategy.Enabled = false; + _strategy.MakeStep(); + Draw(); + + if (_strategy.GetStatus() == StrategyStatus.Finish) + { + comboBoxStrategy.Enabled = true; + _strategy = null; + } + } } \ No newline at end of file diff --git a/ProjectContainerShip/ProjectContainerShip/MovementStrategy/AbstractStrategy.cs b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/AbstractStrategy.cs new file mode 100644 index 0000000..3cae4ba --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/AbstractStrategy.cs @@ -0,0 +1,132 @@ +namespace ProjectContainerShip.MovementStrategy; + +public abstract class AbstractStrategy +{ + /// + /// Перемещаемый объект + /// + private IMoveableObjects? _moveableObject; + + /// + /// Статус перемещения + /// + private StrategyStatus _state = StrategyStatus.NotInit; + + /// + /// Ширина поля + /// + protected int FieldWidth { get; private set; } + + /// + /// Высота поля + /// + protected int FieldHeight { get; private set; } + + /// + /// Статус перемещения + /// + public StrategyStatus GetStatus() { return _state; } + + /// + /// Установка данных + /// + /// Перемещаемый объект + /// Ширина поля + /// Высота поля + public void SetData(IMoveableObjects moveableObject, int width, int height) + { + if (moveableObject == null) + { + _state = StrategyStatus.NotInit; + return; + } + _state = StrategyStatus.InProgress; + _moveableObject = moveableObject; + FieldWidth = width; + FieldHeight = height; + } + + /// + /// Шаг перемещения + /// + public void MakeStep() + { + if (_state != StrategyStatus.InProgress) + { + return; + } + if (IsTargetDestinaion()) + { + _state = StrategyStatus.Finish; + return; + } + MoveToTarget(); + } + + /// + /// Перемещение влево + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveLeft() => MoveTo(MovementDirection.Left); + + /// + /// Перемещение вправо + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveRight() => MoveTo(MovementDirection.Right); + + /// + /// Перемещение вверх + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveUp() => MoveTo(MovementDirection.Up); + + /// + /// Перемещение вниз + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveDown() => MoveTo(MovementDirection.Down); + + /// + /// Параметры объекта + /// + protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition; + + /// + /// Шаг объекта + /// + /// + protected int? GetStep() + { + if (_state != StrategyStatus.InProgress) + { + return null; + } + return _moveableObject?.GetStep; + } + + /// + /// Перемещение к цели + /// + protected abstract void MoveToTarget(); + + /// + /// Достигнута ли цель + /// + /// + protected abstract bool IsTargetDestinaion(); + + /// + /// Попытка перемещения в требуемом направлении + /// + /// Направление + /// Результат попытки (true - удалось переместиться, false - неудача) + private bool MoveTo(MovementDirection movementDirection) + { + if (_state != StrategyStatus.InProgress) + { + return false; + } + return _moveableObject?.TryMoveObject(movementDirection) ?? false; + } +} diff --git a/ProjectContainerShip/ProjectContainerShip/MovementStrategy/IMoveableObjects.cs b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/IMoveableObjects.cs new file mode 100644 index 0000000..290841d --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/IMoveableObjects.cs @@ -0,0 +1,21 @@ +namespace ProjectContainerShip.MovementStrategy; + +public interface IMoveableObjects +{ + /// + /// Получение координаты объекта + /// + ObjectParameters? GetObjectPosition { get; } + + /// + /// Шаг объекта + /// + int GetStep { get; } + + /// + /// Попытка переместить объект в указанном направлении + /// + /// Направление + /// true - объект перемещен, false - перемещение невозможно + bool TryMoveObject(MovementDirection direction); +} diff --git a/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveToBorder.cs b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveToBorder.cs new file mode 100644 index 0000000..b82a287 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveToBorder.cs @@ -0,0 +1,31 @@ +namespace ProjectContainerShip.MovementStrategy; + +public class MoveToBorder : AbstractStrategy +{ + protected override bool IsTargetDestinaion() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) return false; + + return objParams.RightBorder + GetStep() >= FieldWidth + && objParams.DownBorder + GetStep() >= FieldHeight; + } + + protected override void MoveToTarget() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) return; + + int diffX = objParams.LeftBorder - FieldWidth; + if (Math.Abs(diffX) > GetStep()) + { + MoveRight(); + } + + int diffY = objParams.DownBorder - FieldHeight; + if (Math.Abs(diffY) > GetStep()) + { + MoveDown(); + } + } +} diff --git a/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveToCenter.cs b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveToCenter.cs new file mode 100644 index 0000000..954f4b9 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveToCenter.cs @@ -0,0 +1,54 @@ +namespace ProjectContainerShip.MovementStrategy; + +/// +/// Стратегия перемещения объекта в центр экрана +/// +public class MoveToCenter : AbstractStrategy +{ + protected override bool IsTargetDestinaion() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + + return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; + } + + protected override void MoveToTarget() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + + int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + + int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } +} diff --git a/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveableShip.cs b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveableShip.cs new file mode 100644 index 0000000..dc99630 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MoveableShip.cs @@ -0,0 +1,64 @@ +using ProjectContainerShip.Drawings; + +namespace ProjectContainerShip.MovementStrategy; + +/// +/// Класс-реализация IMoveableObjects с использованием DrawningShip +/// +public class MoveableShip : IMoveableObjects +{ + /// + /// Поле-объект класса DrawningCar или его наследника + /// + private readonly DrawningShip? _ship = null; + + /// + /// Конструктор + /// + /// Объект класса DrawningShip + public MoveableShip(DrawningShip ship) + { + _ship = ship; + } + + public ObjectParameters? GetObjectPosition + { + get + { + if (_ship == null || _ship.EntityShip == null || !_ship.GetPosX.HasValue || !_ship.GetPosY.HasValue) + { + return null; + } + return new ObjectParameters(_ship.GetPosX.Value, _ship.GetPosY.Value, _ship.GetWidth, _ship.GetHeight); + } + } + + public int GetStep => (int)(_ship?.EntityShip?.Step ?? 0); + + public bool TryMoveObject(MovementDirection direction) + { + if (_ship == null || _ship.EntityShip == null) + { + return false; + } + + return _ship.MoveTransport(GetDirectionType(direction)); + } + + /// + /// Конвертация из MovementDirection в DirectionType + /// + /// MovementDirection + /// DirectionType + private static DirectionType GetDirectionType(MovementDirection direction) + { + return direction switch + { + MovementDirection.Left => DirectionType.Left, + MovementDirection.Right => DirectionType.Right, + MovementDirection.Up => DirectionType.Up, + MovementDirection.Down => DirectionType.Down, + _ => DirectionType.Unknow, + }; + } +} diff --git a/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MovementDirection.cs b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MovementDirection.cs new file mode 100644 index 0000000..9fe86a8 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/MovementDirection.cs @@ -0,0 +1,27 @@ +namespace ProjectContainerShip.MovementStrategy; + +/// +/// Направление перемещения +/// +public enum MovementDirection +{ + /// + /// Вверх + /// + Up = 1, + + /// + /// Вниз + /// + Down = 2, + + /// + /// Влево + /// + Left = 3, + + /// + /// Вправо + /// + Right = 4 +} diff --git a/ProjectContainerShip/ProjectContainerShip/MovementStrategy/ObjectParameters.cs b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/ObjectParameters.cs new file mode 100644 index 0000000..34f5d88 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/ObjectParameters.cs @@ -0,0 +1,69 @@ +namespace ProjectContainerShip.MovementStrategy; + +public class ObjectParameters +{ + /// + /// Координата X + /// + private readonly int _x; + + /// + /// Координата Y + /// + private readonly int _y; + + /// + /// Ширина объекта + /// + private readonly int _width; + + /// + /// Высота объекта + /// + private readonly int _height; + + /// + /// Левая граница + /// + public int LeftBorder => _x; + + /// + /// Верхняя граница + /// + public int TopBorder => _y; + + /// + /// Правая граница + /// + public int RightBorder => _x + _width; + + /// + /// Нижняя граница + /// + public int DownBorder => _y + _height; + + /// + /// Середина объекта + /// + public int ObjectMiddleHorizontal => _x + _width / 2; + + /// + /// Середина объекта + /// + public int ObjectMiddleVertical => _y + _height / 2; + + /// + /// Конструктор + /// + /// Координата X + /// Координата Y + /// Ширина объекта + /// Высота объекта + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + } +} diff --git a/ProjectContainerShip/ProjectContainerShip/MovementStrategy/StrategyStatus.cs b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/StrategyStatus.cs new file mode 100644 index 0000000..0252124 --- /dev/null +++ b/ProjectContainerShip/ProjectContainerShip/MovementStrategy/StrategyStatus.cs @@ -0,0 +1,22 @@ +namespace ProjectContainerShip.MovementStrategy; + +/// +/// Статус выполнения операции перемещения +/// +public enum StrategyStatus +{ + /// + /// Все готово к началу + /// + NotInit, + + /// + /// Выполняется + /// + InProgress, + + /// + /// Завершено + /// + Finish +} -- 2.25.1 From 2383016c2ce20b3a51430f36c134f8717abf81a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=9A=D1=83=D0=B4=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Fri, 15 Mar 2024 15:52:26 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=80=D1=83=20=D0=BF=D0=BE=D0=B4=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectContainerShip/Drawings/DrawningContainerShip.cs | 3 +++ .../ProjectContainerShip/Entities/EntityContainerShip.cs | 2 +- .../ProjectContainerShip/FormContainerShip.Designer.cs | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningContainerShip.cs index 80d6e61..4dfaa2d 100644 --- a/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningContainerShip.cs +++ b/ProjectContainerShip/ProjectContainerShip/Drawings/DrawningContainerShip.cs @@ -2,6 +2,9 @@ namespace ProjectContainerShip.Drawings; +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// public class DrawningContainerShip : DrawningShip { /// diff --git a/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs b/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs index 00fb2b8..9f98d29 100644 --- a/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs +++ b/ProjectContainerShip/ProjectContainerShip/Entities/EntityContainerShip.cs @@ -21,7 +21,7 @@ public class EntityContainerShip : EntityShip public bool Container { get; private set; } /// - /// + /// Инициализация поле объекта-класса Контейнеровоза /// /// Скорость /// Вес контейнеровоза diff --git a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs index c044adc..6008ea5 100644 --- a/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs +++ b/ProjectContainerShip/ProjectContainerShip/FormContainerShip.Designer.cs @@ -123,6 +123,7 @@ namespace ProjectContainerShip // // comboBoxStrategy // + comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right; comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxStrategy.FormattingEnabled = true; comboBoxStrategy.Items.AddRange(new object[] { "К центру ", "К краю" }); @@ -133,6 +134,7 @@ namespace ProjectContainerShip // // buttonStrategyStep // + buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonStrategyStep.Location = new Point(1094, 58); buttonStrategyStep.Name = "buttonStrategyStep"; buttonStrategyStep.Size = new Size(150, 46); -- 2.25.1