From d50a0855a07789a61776c7ceb723efeeb94e45a2 Mon Sep 17 00:00:00 2001 From: kassslll <144980044+kassslll@users.noreply.github.com> Date: Sun, 18 Feb 2024 08:02:04 +0400 Subject: [PATCH 01/11] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectLiner/ProjectLiner/DirectionType.cs | 27 +++ ProjectLiner/ProjectLiner/DrawningLiner.cs | 205 ++++++++++++++++++ ProjectLiner/ProjectLiner/EntityLiner.cs | 68 ++++++ ProjectLiner/ProjectLiner/Form1.Designer.cs | 39 ---- ProjectLiner/ProjectLiner/Form1.cs | 10 - .../ProjectLiner/FormLiner.Designer.cs | 133 ++++++++++++ ProjectLiner/ProjectLiner/FormLiner.cs | 91 ++++++++ .../{Form1.resx => FormLiner.resx} | 50 ++--- ProjectLiner/ProjectLiner/Program.cs | 2 +- ProjectLiner/ProjectLiner/ProjectLiner.csproj | 15 ++ .../Properties/Resources.Designer.cs | 103 +++++++++ .../ProjectLiner/Properties/Resources.resx | 133 ++++++++++++ .../ProjectLiner/Resources/bottom.png | Bin 0 -> 5805 bytes ProjectLiner/ProjectLiner/Resources/left.png | Bin 0 -> 5248 bytes ProjectLiner/ProjectLiner/Resources/right.png | Bin 0 -> 5026 bytes ProjectLiner/ProjectLiner/Resources/top.png | Bin 0 -> 5585 bytes 16 files changed, 801 insertions(+), 75 deletions(-) create mode 100644 ProjectLiner/ProjectLiner/DirectionType.cs create mode 100644 ProjectLiner/ProjectLiner/DrawningLiner.cs create mode 100644 ProjectLiner/ProjectLiner/EntityLiner.cs delete mode 100644 ProjectLiner/ProjectLiner/Form1.Designer.cs delete mode 100644 ProjectLiner/ProjectLiner/Form1.cs create mode 100644 ProjectLiner/ProjectLiner/FormLiner.Designer.cs create mode 100644 ProjectLiner/ProjectLiner/FormLiner.cs rename ProjectLiner/ProjectLiner/{Form1.resx => FormLiner.resx} (93%) create mode 100644 ProjectLiner/ProjectLiner/Properties/Resources.Designer.cs create mode 100644 ProjectLiner/ProjectLiner/Properties/Resources.resx create mode 100644 ProjectLiner/ProjectLiner/Resources/bottom.png create mode 100644 ProjectLiner/ProjectLiner/Resources/left.png create mode 100644 ProjectLiner/ProjectLiner/Resources/right.png create mode 100644 ProjectLiner/ProjectLiner/Resources/top.png diff --git a/ProjectLiner/ProjectLiner/DirectionType.cs b/ProjectLiner/ProjectLiner/DirectionType.cs new file mode 100644 index 0000000..12c5fb2 --- /dev/null +++ b/ProjectLiner/ProjectLiner/DirectionType.cs @@ -0,0 +1,27 @@ +namespace ProjectLiner; + +/// +/// Направление перемещения +/// +public enum DirectionType +{ + /// + /// Вверх + /// + Up = 1, + + /// + /// Вниз + /// + Down = 2, + + /// + /// Влево + /// + Left = 3, + + /// + /// Вправо + /// + Right = 4 +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/DrawningLiner.cs b/ProjectLiner/ProjectLiner/DrawningLiner.cs new file mode 100644 index 0000000..76d0856 --- /dev/null +++ b/ProjectLiner/ProjectLiner/DrawningLiner.cs @@ -0,0 +1,205 @@ +namespace ProjectLiner; + +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// +public class DrawningLiner +{ + /// + /// Класс-сущность + /// + public EntityLiner? EntityLiner { get; private set; } + + /// + /// Ширина окна + /// + private int? _pictureWidth; + + /// + /// Высота окна + /// + private int? _pictureHeight; + + /// + /// Левая координата прорисовки лайнера + /// + private int? _startPosX; + + /// + /// Верхняя кооридната прорисовки лайнера + /// + private int? _startPosY; + + /// + /// Ширина прорисовки лайнера + /// + private readonly int _drawningLinerWidth = 180; + + /// + /// Высота прорисовки лайнера + /// + private readonly int _drawningLinerHeight = 125; + + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия якоря + /// Признак наличия шлюпок + /// Признак наличия трубы + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool anchor, bool boats, bool pipe) + { + EntityLiner = new EntityLiner(); + EntityLiner.Init(speed, weight, bodyColor, additionalColor, anchor, boats, pipe); + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах + public bool SetPictureSize(int width, int height) + { + _pictureWidth = width; + _pictureHeight = height; + return true; + } + + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + + if (x < 0 || y < 0) + { + return; + } + + _startPosX = x; + _startPosY = y; + } + + /// + /// Изменение направления перемещения + /// + /// Направление + /// true - перемещене выполнено, false - перемещение невозможно + public bool MoveTransport(DirectionType direction) + { + if (EntityLiner == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return false; + } + + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX.Value - EntityLiner.Step > 0) + { + _startPosX -= (int)EntityLiner.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntityLiner.Step > 0) + { + _startPosY -= (int)EntityLiner.Step; + } + return true; + // вправо + case DirectionType.Right: + if (_startPosX.Value + EntityLiner.Step < _pictureWidth-_drawningLinerWidth) + { + _startPosX += (int)EntityLiner.Step; + } + return true; + //вниз + case DirectionType.Down: + if (_startPosY.Value + EntityLiner.Step < _pictureHeight-_drawningLinerHeight) + { + _startPosY += (int)EntityLiner.Step; + } + return true; + default: + return false; + } + } + + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityLiner == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + Pen pen = new(Color.Black); + Brush additionalBrush = new SolidBrush(EntityLiner.AdditionalColor); + Brush br = new SolidBrush(EntityLiner.BodyColor); + + // якорь + if (EntityLiner.Anchor) + { + g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 85, _startPosX.Value + 45, _startPosY.Value + 115); + g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 95, _startPosX.Value + 60, _startPosY.Value + 95); + g.DrawLine(pen, _startPosX.Value + 25, _startPosY.Value + 100, _startPosX.Value + 45, _startPosY.Value + 115); + g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 115, _startPosX.Value + 65, _startPosY.Value + 100); + } + + // кузов лайнера + Point point1 = new Point(_startPosX.Value, _startPosY.Value + 80); + Point point2 = new Point(_startPosX.Value + 50, _startPosY.Value + 130); + Point point3 = new Point(_startPosX.Value + 135, _startPosY.Value + 130); + Point point4 = new Point(_startPosX.Value + 185, _startPosY.Value + 80); + Point[] curvePoints = { point1, point2, point3, point4 }; + g.FillPolygon(br, curvePoints); + + + // борт лайнера + Point point5 = new Point(_startPosX.Value+40, _startPosY.Value + 40); + Point point6 = new Point(_startPosX.Value + 140, _startPosY.Value + 40); + Point point7 = new Point(_startPosX.Value + 140, _startPosY.Value + 80); + Point point8 = new Point(_startPosX.Value + 40, _startPosY.Value + 80); + Point[] curvePoints2 = { point5, point6, point7, point8 }; + g.FillPolygon(additionalBrush, curvePoints2); + + // шлюпки + if (EntityLiner.Boats) + { + g.FillEllipse(additionalBrush, _startPosX.Value + 60, _startPosY.Value + 85, 30, 15); + g.FillEllipse(additionalBrush, _startPosX.Value + 95, _startPosY.Value + 85, 30, 15); + g.FillEllipse(additionalBrush, _startPosX.Value + 130, _startPosY.Value + 85, 30, 15); + } + + // труба + if (EntityLiner.Pipe) + { + + Point point9 = new Point(_startPosX.Value + 90, _startPosY.Value + 10); + Point point10 = new Point(_startPosX.Value + 90, _startPosY.Value + 40); + Point point11 = new Point(_startPosX.Value + 115, _startPosY.Value + 40); + Point point12 = new Point(_startPosX.Value + 115, _startPosY.Value + 10); + Point[] curvePoints3 = { point9, point10, point11, point12 }; + g.FillPolygon(br, curvePoints3); + } + } +} diff --git a/ProjectLiner/ProjectLiner/EntityLiner.cs b/ProjectLiner/ProjectLiner/EntityLiner.cs new file mode 100644 index 0000000..66d27c1 --- /dev/null +++ b/ProjectLiner/ProjectLiner/EntityLiner.cs @@ -0,0 +1,68 @@ +namespace ProjectLiner; + +/// +/// Класс-сущность "Лайнер" +/// +public class EntityLiner +{ + /// + /// Скорость + /// + 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 Anchor { get; private set; } + + /// + /// Признак (опция) наличия шлюпок + /// + public bool Boats { get; private set; } + + /// + /// Признак (опция) наличия трубы + /// + public bool Pipe { get; private set; } + + /// + /// Шаг перемещения автомобиля + /// + public double Step => Speed * 100 / Weight; + + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия якоря + /// Признак наличия шлюпок + /// Признак наличия трубы + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool anchor, bool boats, bool pipe) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Anchor = anchor; + Boats = boats; + Pipe = pipe; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/Form1.Designer.cs b/ProjectLiner/ProjectLiner/Form1.Designer.cs deleted file mode 100644 index 054e711..0000000 --- a/ProjectLiner/ProjectLiner/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectLiner -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/Form1.cs b/ProjectLiner/ProjectLiner/Form1.cs deleted file mode 100644 index 9b44028..0000000 --- a/ProjectLiner/ProjectLiner/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectLiner -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs new file mode 100644 index 0000000..e55a740 --- /dev/null +++ b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs @@ -0,0 +1,133 @@ +namespace ProjectLiner +{ + partial class FormLiner + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + pictureBoxLiner = new PictureBox(); + buttonCreate = new Button(); + buttonDown = new Button(); + buttonUp = new Button(); + buttonLeft = new Button(); + buttonRight = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).BeginInit(); + SuspendLayout(); + // + // pictureBoxLiner + // + pictureBoxLiner.Dock = DockStyle.Fill; + pictureBoxLiner.Location = new Point(0, 0); + pictureBoxLiner.Name = "pictureBoxLiner"; + pictureBoxLiner.Size = new Size(948, 614); + pictureBoxLiner.TabIndex = 0; + pictureBoxLiner.TabStop = false; + // + // buttonCreate + // + buttonCreate.Location = new Point(12, 520); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(150, 82); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.bottom; + buttonDown.BackgroundImageLayout = ImageLayout.Stretch; + buttonDown.Location = new Point(830, 552); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(50, 50); + buttonDown.TabIndex = 2; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += ButtonMove_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.top; + buttonUp.BackgroundImageLayout = ImageLayout.Stretch; + buttonUp.Location = new Point(830, 496); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(50, 50); + buttonUp.TabIndex = 3; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += ButtonMove_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.left; + buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; + buttonLeft.Location = new Point(774, 552); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(50, 50); + buttonLeft.TabIndex = 4; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += ButtonMove_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.right; + buttonRight.BackgroundImageLayout = ImageLayout.Stretch; + buttonRight.Location = new Point(886, 552); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(50, 50); + buttonRight.TabIndex = 5; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += ButtonMove_Click; + // + // FormLiner + // + AutoScaleDimensions = new SizeF(11F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(948, 614); + Controls.Add(buttonRight); + Controls.Add(buttonLeft); + Controls.Add(buttonUp); + Controls.Add(buttonDown); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxLiner); + Name = "FormLiner"; + Text = "Лайнер"; + ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).EndInit(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBoxLiner; + private Button buttonCreate; + private Button buttonDown; + private Button buttonUp; + private Button buttonLeft; + private Button buttonRight; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs new file mode 100644 index 0000000..e370c8b --- /dev/null +++ b/ProjectLiner/ProjectLiner/FormLiner.cs @@ -0,0 +1,91 @@ +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 ProjectLiner +{ + public partial class FormLiner : Form + { + private DrawningLiner? _drawningLiner; + public FormLiner() + { + InitializeComponent(); + } + + /// + /// Метод прорисовки лайнера + /// + private void Draw() + { + if (_drawningLiner == null) + { + return; + } + + Bitmap bmp = new(pictureBoxLiner.Width, pictureBoxLiner.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningLiner.DrawTransport(gr); + pictureBoxLiner.Image = bmp; + } + + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningLiner = new DrawningLiner(); + _drawningLiner.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)), Convert.ToBoolean(random.Next(0, 2))); + _drawningLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); + _drawningLiner.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } + + /// + /// Перемещение объекта по форме (нажатие кнопок навигации) + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawningLiner == null) + { + return; + } + + string name = ((Button)sender)?.Name ?? string.Empty; + bool result = false; + switch (name) + { + case "buttonUp": + result = _drawningLiner.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + result = _drawningLiner.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + result = _drawningLiner.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + result = _drawningLiner.MoveTransport(DirectionType.Right); + break; + } + + if (result) + { + Draw(); + } + } + } +} diff --git a/ProjectLiner/ProjectLiner/Form1.resx b/ProjectLiner/ProjectLiner/FormLiner.resx similarity index 93% rename from ProjectLiner/ProjectLiner/Form1.resx rename to ProjectLiner/ProjectLiner/FormLiner.resx index 1af7de1..af32865 100644 --- a/ProjectLiner/ProjectLiner/Form1.resx +++ b/ProjectLiner/ProjectLiner/FormLiner.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectLiner/ProjectLiner/Program.cs b/ProjectLiner/ProjectLiner/Program.cs index 6a14f7d..b3dc92e 100644 --- a/ProjectLiner/ProjectLiner/Program.cs +++ b/ProjectLiner/ProjectLiner/Program.cs @@ -11,7 +11,7 @@ namespace ProjectLiner // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new FormLiner()); } } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/ProjectLiner.csproj b/ProjectLiner/ProjectLiner/ProjectLiner.csproj index e1a0735..244387d 100644 --- a/ProjectLiner/ProjectLiner/ProjectLiner.csproj +++ b/ProjectLiner/ProjectLiner/ProjectLiner.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/Properties/Resources.Designer.cs b/ProjectLiner/ProjectLiner/Properties/Resources.Designer.cs new file mode 100644 index 0000000..478d0e0 --- /dev/null +++ b/ProjectLiner/ProjectLiner/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectLiner.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectLiner.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap bottom { + get { + object obj = ResourceManager.GetObject("bottom", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap left { + get { + object obj = ResourceManager.GetObject("left", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap right { + get { + object obj = ResourceManager.GetObject("right", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap top { + get { + object obj = ResourceManager.GetObject("top", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectLiner/ProjectLiner/Properties/Resources.resx b/ProjectLiner/ProjectLiner/Properties/Resources.resx new file mode 100644 index 0000000..b1de66a --- /dev/null +++ b/ProjectLiner/ProjectLiner/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\bottom.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\top.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/Resources/bottom.png b/ProjectLiner/ProjectLiner/Resources/bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..504bf06beab336162136cb7976b7d38001d1a10c GIT binary patch literal 5805 zcmeHLc~n#9w#T6*xeQ|P5jtDj*n$VQ`2L3PKnH4hKbvM1+V4 z!c%ad$ZQ!55Isu30#XMcOu+yJlqq2dfdqKR-nY7Xd)vPE_gnqrth3Me`*yy)e|z|{ z_LZ+aa7zEs{D+*JoD$yUz_)U88-UNx#tqPlLf{Y#daaB67Uw8e`daHF^szD2!QDYl zu7ar`BYgpVBffS!w-$*$*<(HqIbu5hX zRyjE}6#jt2AzJU$fNNwgf&CTf_*C1qG`kw=p6)AwI?breB~KnA_B0^8B@s9@0>!dL;ade8sX+#CP0J)ijJGNTR17x=VLWEw}v> z!SP2Qdbk+&`YH>^6h#l7rm{0f5AasnBKJ>?tpj`B?hfG6-f5}i{&UmPe2BXwGFn*C z_RumE>>D)|Ob6d`2!9PMR&4`{DRGg8yF!{3i~Zxw4eN`Th{o3YmSix$s(=}6+@PVV z)(r1s?Y+oPfHTVq*qKSVGw6spNKM&yTXNt38CJF8G5xm=9NXOd9_b z^i$4m!NBCmu$N9l&oq*sZ|HwBY{?@w!Pec!)#{_@$%n^2E>?ny#~WbX2oGAll77N< zDmd&86R-ePow5zE(0o*`kfyC?<;OyJ#K^GlkHd7B;9C$5g`qhg@fHV1k1!BJ@#X_2 zk3rbL?49ZDcY*)<#xbD`kPzXb1_(mGTqLB-uv7*y`iL>;(||u@`A=2; zrvFd!@^AY8l9+#0^55D2*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Y$Sb zp(lL}4G^ND^8BWh!o1+4AmG_GrIeVgk`X>TGslU+%gP-`=e}4So}8u*5=TO7(=*Db zbh(&MoTeSEF+%@Z612uCe=S?lGfze^A`+H@a50s^oip;Q3xzR+0O3sHU8`(iaOXEj zz+tqkQdA0Xs)_}xmnE6OdD8LUhY?TNNktihGX^Mq^?x@n`Fm#Yr*ovg$1Z<1U;7Uy fR{-wQvW2fs{}WlexEyFMDB@`6YFlP~^1?p>mu34b literal 0 HcmV?d00001 diff --git a/ProjectLiner/ProjectLiner/Resources/right.png b/ProjectLiner/ProjectLiner/Resources/right.png new file mode 100644 index 0000000000000000000000000000000000000000..f97b115950f804f40e403e50357cb7e3ced79620 GIT binary patch literal 5026 zcmeHLdt6gjwx&fa5kv{27~~<6h?ZzDK|n#GD31V=RvjKni7AkP4}$W>5H2?0D32gW zAUvcD3T>efz!3!uHCRCth!{msAf&t%LU;(lKr;JqZ}0tep7-yW`Qx0k_C9Oxwbr-S zUgtae+85q#>(?2r)6mdZPjEkaTth>X30-S6L66RvU$nvFlgQ(4&KlL7#uK2ihI;te zVGWI1md-L+3$)>1c%5{?;c#lTdUSNu#Ka^fCWg!9+JvY0fw!;-cmGHY4ZX+E^+~Rk z-c}6_0|epd;gfN1ruqfpZ{3X!kz?$8-Ix#UOhkbO&y@H2A2z&ss%&}YXIMc!@G|9t zp?~y$oe2GD|3hmX#kPVU{`egwdQ1NbIsg96jV173PB_y&{y>Dy>@s&kJ+5FX{<5=h zNTgDzj|KcgrC&$N4FBnTtEy2g{~yypRhjZv4*hEDH?H?%{+925tvbQ@J7NB%>Y~oy zMdUZCjii4B-v6nJSN;jkzpDN_LnzFd#(Nw)!q;6=Nmyn{xdo|AX+VDx?G1TLxB6pc zyA4uz?1)2E;o?lEqUJ|t^CSbWA#39@*jem;!SiKN=v69=yi^yiO41corc{`dcapA_ zFa69t9b*J{ot64ND)*=56{j+jn=iPnDO{*M9c2VxJA0u&-AG2flLibAPtsB;^eQEa zI>I0)@QOB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j8`}Y?9m9GDL3;&W_e^=pOlIw3G z|M7n8x2E&^UMO<~DI@azKY&utG;uW`l*K6q6v^};lR3F4D*&1-*m12I^z9mcATLy) zUb)QLArt^Yjel9+0R&+Gnb04c`J~U8-zo+$&a36GCN>^PgmDN$+R8HJjeP$(?X~M} zX_QX}-pcn!=!2qy?^hL)t{h<@gsbTD&HK-I8M*`%hju?A&d6)FX_VG_6yi_VEC_6^ z7;`e?T=HXEd)EMT#Il~Ro&!bqbsfm){=hm+&n7PhIx$XP2Yb6kc1`wxd?4j&Bzz&K z7o~Z4a0vE5v<+2m ze3KGtX!X-w*2jd{hy$Gu?*-Z^IOLyK*W~G{Ncwnz9tsXQH`F!9{dKozKG_j~@(EaX zI2>|n9C>&xyG>maFXysQG)7xEK&gM5S4mioyCG%Mk$NkuWIR>V? zZle^b%)mth&;Mz3# Date: Wed, 21 Feb 2024 16:33:40 +0400 Subject: [PATCH 02/11] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=20SetPosition=20=D0=B8=20SetPictureSize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectLiner/ProjectLiner/DrawningLiner.cs | 54 ++++++++++++++----- .../ProjectLiner/FormLiner.Designer.cs | 2 + 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/ProjectLiner/ProjectLiner/DrawningLiner.cs b/ProjectLiner/ProjectLiner/DrawningLiner.cs index 76d0856..d5023a3 100644 --- a/ProjectLiner/ProjectLiner/DrawningLiner.cs +++ b/ProjectLiner/ProjectLiner/DrawningLiner.cs @@ -33,7 +33,7 @@ public class DrawningLiner /// /// Ширина прорисовки лайнера /// - private readonly int _drawningLinerWidth = 180; + private readonly int _drawningLinerWidth = 150; /// /// Высота прорисовки лайнера @@ -68,9 +68,29 @@ public class DrawningLiner /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах public bool SetPictureSize(int width, int height) { - _pictureWidth = width; - _pictureHeight = height; - return true; + if (width > _drawningLinerWidth && height > _drawningLinerHeight) + { + _pictureWidth = width; + _pictureHeight = height; + if (_startPosX != null && _startPosY != null) + { + if (_startPosX.Value < 0) + _startPosX = 0; + if (_startPosY.Value < 0) + _startPosY = 0; + if (_startPosX.Value + _drawningLinerWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningLinerWidth; + } + if (_startPosY.Value + _drawningLinerHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningLinerHeight; + } + } + + return true; + } + return false; } /// @@ -84,16 +104,22 @@ public class DrawningLiner { return; } - - if (x < 0 || y < 0) + else { - return; + _startPosX = x; + _startPosY = y; + + if (_startPosX.Value + _drawningLinerWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _drawningLinerWidth; + } + if (_startPosY.Value + _drawningLinerHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _drawningLinerHeight; + } } - _startPosX = x; - _startPosY = y; } - /// /// Изменение направления перемещения /// @@ -169,7 +195,7 @@ public class DrawningLiner Point point1 = new Point(_startPosX.Value, _startPosY.Value + 80); Point point2 = new Point(_startPosX.Value + 50, _startPosY.Value + 130); Point point3 = new Point(_startPosX.Value + 135, _startPosY.Value + 130); - Point point4 = new Point(_startPosX.Value + 185, _startPosY.Value + 80); + Point point4 = new Point(_startPosX.Value + 155, _startPosY.Value + 80); Point[] curvePoints = { point1, point2, point3, point4 }; g.FillPolygon(br, curvePoints); @@ -185,9 +211,9 @@ public class DrawningLiner // шлюпки if (EntityLiner.Boats) { - g.FillEllipse(additionalBrush, _startPosX.Value + 60, _startPosY.Value + 85, 30, 15); - g.FillEllipse(additionalBrush, _startPosX.Value + 95, _startPosY.Value + 85, 30, 15); - g.FillEllipse(additionalBrush, _startPosX.Value + 130, _startPosY.Value + 85, 30, 15); + g.FillEllipse(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 85, 30, 15); + g.FillEllipse(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 85, 30, 15); + g.FillEllipse(additionalBrush, _startPosX.Value + 110, _startPosY.Value + 85, 30, 15); } // труба diff --git a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs index e55a740..94eb653 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs @@ -39,6 +39,7 @@ // // pictureBoxLiner // + pictureBoxLiner.BackColor = SystemColors.Control; pictureBoxLiner.Dock = DockStyle.Fill; pictureBoxLiner.Location = new Point(0, 0); pictureBoxLiner.Name = "pictureBoxLiner"; @@ -48,6 +49,7 @@ // // buttonCreate // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonCreate.Location = new Point(12, 520); buttonCreate.Name = "buttonCreate"; buttonCreate.Size = new Size(150, 82); From bd746e928870a62316697671aa6adaffda9ad5ca Mon Sep 17 00:00:00 2001 From: gettterot Date: Wed, 21 Feb 2024 16:54:00 +0400 Subject: [PATCH 03/11] =?UTF-8?q?=D0=A1=20=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=BD=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=BC=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B2=D1=8B=D0=BC=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectLiner/ProjectLiner/DrawningLiner.cs | 10 ++++++---- ProjectLiner/ProjectLiner/FormLiner.cs | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ProjectLiner/ProjectLiner/DrawningLiner.cs b/ProjectLiner/ProjectLiner/DrawningLiner.cs index d5023a3..35d42b6 100644 --- a/ProjectLiner/ProjectLiner/DrawningLiner.cs +++ b/ProjectLiner/ProjectLiner/DrawningLiner.cs @@ -50,10 +50,9 @@ public class DrawningLiner /// Признак наличия якоря /// Признак наличия шлюпок /// Признак наличия трубы - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool anchor, bool boats, bool pipe) + public void Init(EntityLiner liner) { - EntityLiner = new EntityLiner(); - EntityLiner.Init(speed, weight, bodyColor, additionalColor, anchor, boats, pipe); + EntityLiner = liner; _pictureWidth = null; _pictureHeight = null; _startPosX = null; @@ -108,7 +107,10 @@ public class DrawningLiner { _startPosX = x; _startPosY = y; - + if (_startPosX.Value < 0) + _startPosX = 0; + if (_startPosY.Value < 0) + _startPosY = 0; if (_startPosX.Value + _drawningLinerWidth > _pictureWidth) { _startPosX = _pictureWidth - _drawningLinerWidth; diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs index e370c8b..c72187d 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.cs @@ -42,11 +42,13 @@ namespace ProjectLiner private void buttonCreate_Click(object sender, EventArgs e) { Random random = new(); - _drawningLiner = new DrawningLiner(); - _drawningLiner.Init(random.Next(100, 300), random.Next(1000, 3000), + EntityLiner liner = new EntityLiner(); + liner.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)), Convert.ToBoolean(random.Next(0, 2))); + _drawningLiner = new DrawningLiner(); + _drawningLiner.Init(liner); _drawningLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); _drawningLiner.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); From 6c4691699b6863b562c036f4715849765ed5e854 Mon Sep 17 00:00:00 2001 From: gettterot Date: Wed, 6 Mar 2024 07:52:17 +0400 Subject: [PATCH 04/11] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=80=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D1=81=D0=BA=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BB=D1=8F=20entity=20liner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => Drawnings}/DirectionType.cs | 2 +- .../DrawningCommonLiner.cs} | 130 ++++++++---------- .../ProjectLiner/Drawnings/DrawningLiner.cs | 72 ++++++++++ .../Entities/EntityCommonLiner.cs | 50 +++++++ .../{ => Entities}/EntityLiner.cs | 31 +---- .../ProjectLiner/FormLiner.Designer.cs | 20 ++- ProjectLiner/ProjectLiner/FormLiner.cs | 73 +++++++--- 7 files changed, 258 insertions(+), 120 deletions(-) rename ProjectLiner/ProjectLiner/{ => Drawnings}/DirectionType.cs (91%) rename ProjectLiner/ProjectLiner/{DrawningLiner.cs => Drawnings/DrawningCommonLiner.cs} (60%) create mode 100644 ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs create mode 100644 ProjectLiner/ProjectLiner/Entities/EntityCommonLiner.cs rename ProjectLiner/ProjectLiner/{ => Entities}/EntityLiner.cs (58%) diff --git a/ProjectLiner/ProjectLiner/DirectionType.cs b/ProjectLiner/ProjectLiner/Drawnings/DirectionType.cs similarity index 91% rename from ProjectLiner/ProjectLiner/DirectionType.cs rename to ProjectLiner/ProjectLiner/Drawnings/DirectionType.cs index 12c5fb2..cc78a5a 100644 --- a/ProjectLiner/ProjectLiner/DirectionType.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DirectionType.cs @@ -1,4 +1,4 @@ -namespace ProjectLiner; +namespace ProjectLiner.Drawnings; /// /// Направление перемещения diff --git a/ProjectLiner/ProjectLiner/DrawningLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs similarity index 60% rename from ProjectLiner/ProjectLiner/DrawningLiner.cs rename to ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs index 35d42b6..2bc1885 100644 --- a/ProjectLiner/ProjectLiner/DrawningLiner.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs @@ -1,14 +1,17 @@ -namespace ProjectLiner; +using ProjectLiner.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; -/// -/// Класс, отвечающий за прорисовку и перемещение объекта-сущности -/// -public class DrawningLiner +namespace ProjectLiner.Drawnings; +public class DrawningCommonLiner { /// /// Класс-сущность /// - public EntityLiner? EntityLiner { get; private set; } + public EntityCommonLiner? EntityCommonLiner { get; protected set; } /// /// Ширина окна @@ -23,12 +26,12 @@ public class DrawningLiner /// /// Левая координата прорисовки лайнера /// - private int? _startPosX; + protected int? _startPosX; /// /// Верхняя кооридната прорисовки лайнера /// - private int? _startPosY; + protected int? _startPosY; /// /// Ширина прорисовки лайнера @@ -38,27 +41,44 @@ public class DrawningLiner /// /// Высота прорисовки лайнера /// - private readonly int _drawningLinerHeight = 125; + private readonly int _drawningLinerHeight = 90; /// - /// Инициализация свойств + /// Пустой конструктор /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия якоря - /// Признак наличия шлюпок - /// Признак наличия трубы - public void Init(EntityLiner liner) + + public DrawningCommonLiner() { - EntityLiner = liner; _pictureWidth = null; _pictureHeight = null; _startPosX = null; _startPosY = null; } + /// + /// конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + + public DrawningCommonLiner(int speed, double weight, Color bodycolor) : this() + { + EntityCommonLiner = new EntityCommonLiner(speed, weight, bodycolor); + } + + /// + /// конструктор для наследников + /// + /// Высота + /// Длина + + protected DrawningCommonLiner(int drawningLinerWight, int drawningLinerHeight) : this() + { + _drawningLinerHeight = drawningLinerHeight; + _drawningLinerWidth = drawningLinerWight; + } + /// /// Установка границ поля /// @@ -73,7 +93,7 @@ public class DrawningLiner _pictureHeight = height; if (_startPosX != null && _startPosY != null) { - if (_startPosX.Value < 0) + if (_startPosX.Value < 0) _startPosX = 0; if (_startPosY.Value < 0) _startPosY = 0; @@ -129,7 +149,7 @@ public class DrawningLiner /// true - перемещене выполнено, false - перемещение невозможно public bool MoveTransport(DirectionType direction) { - if (EntityLiner == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityCommonLiner == null || !_startPosX.HasValue || !_startPosY.HasValue) { return false; } @@ -138,30 +158,30 @@ public class DrawningLiner { //влево case DirectionType.Left: - if (_startPosX.Value - EntityLiner.Step > 0) + if (_startPosX.Value - EntityCommonLiner.Step > 0) { - _startPosX -= (int)EntityLiner.Step; + _startPosX -= (int)EntityCommonLiner.Step; } return true; //вверх case DirectionType.Up: - if (_startPosY.Value - EntityLiner.Step > 0) + if (_startPosY.Value - EntityCommonLiner.Step > 0) { - _startPosY -= (int)EntityLiner.Step; + _startPosY -= (int)EntityCommonLiner.Step; } return true; // вправо case DirectionType.Right: - if (_startPosX.Value + EntityLiner.Step < _pictureWidth-_drawningLinerWidth) + if (_startPosX.Value + EntityCommonLiner.Step < _pictureWidth - _drawningLinerWidth) { - _startPosX += (int)EntityLiner.Step; + _startPosX += (int)EntityCommonLiner.Step; } return true; //вниз case DirectionType.Down: - if (_startPosY.Value + EntityLiner.Step < _pictureHeight-_drawningLinerHeight) + if (_startPosY.Value + EntityCommonLiner.Step < _pictureHeight - _drawningLinerHeight) { - _startPosY += (int)EntityLiner.Step; + _startPosY += (int)EntityCommonLiner.Step; } return true; default: @@ -173,61 +193,33 @@ public class DrawningLiner /// Прорисовка объекта /// /// - public void DrawTransport(Graphics g) + public virtual void DrawTransport(Graphics g) { - if (EntityLiner == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityCommonLiner == null || !_startPosX.HasValue || !_startPosY.HasValue) { return; } Pen pen = new(Color.Black); - Brush additionalBrush = new SolidBrush(EntityLiner.AdditionalColor); - Brush br = new SolidBrush(EntityLiner.BodyColor); + Brush br = new SolidBrush(EntityCommonLiner.BodyColor); - // якорь - if (EntityLiner.Anchor) - { - g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 85, _startPosX.Value + 45, _startPosY.Value + 115); - g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 95, _startPosX.Value + 60, _startPosY.Value + 95); - g.DrawLine(pen, _startPosX.Value + 25, _startPosY.Value + 100, _startPosX.Value + 45, _startPosY.Value + 115); - g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 115, _startPosX.Value + 65, _startPosY.Value + 100); - } // кузов лайнера - Point point1 = new Point(_startPosX.Value, _startPosY.Value + 80); - Point point2 = new Point(_startPosX.Value + 50, _startPosY.Value + 130); - Point point3 = new Point(_startPosX.Value + 135, _startPosY.Value + 130); - Point point4 = new Point(_startPosX.Value + 155, _startPosY.Value + 80); + Point point1 = new Point(_startPosX.Value, _startPosY.Value + 40); + Point point2 = new Point(_startPosX.Value + 50, _startPosY.Value + 90); + Point point3 = new Point(_startPosX.Value + 135, _startPosY.Value + 90); + Point point4 = new Point(_startPosX.Value + 155, _startPosY.Value + 40); Point[] curvePoints = { point1, point2, point3, point4 }; g.FillPolygon(br, curvePoints); // борт лайнера - Point point5 = new Point(_startPosX.Value+40, _startPosY.Value + 40); - Point point6 = new Point(_startPosX.Value + 140, _startPosY.Value + 40); - Point point7 = new Point(_startPosX.Value + 140, _startPosY.Value + 80); - Point point8 = new Point(_startPosX.Value + 40, _startPosY.Value + 80); + Point point5 = new Point(_startPosX.Value + 40, _startPosY.Value); + Point point6 = new Point(_startPosX.Value + 140, _startPosY.Value); + Point point7 = new Point(_startPosX.Value + 140, _startPosY.Value + 40); + Point point8 = new Point(_startPosX.Value + 40, _startPosY.Value + 40); Point[] curvePoints2 = { point5, point6, point7, point8 }; - g.FillPolygon(additionalBrush, curvePoints2); + g.FillPolygon(br, curvePoints2); - // шлюпки - if (EntityLiner.Boats) - { - g.FillEllipse(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 85, 30, 15); - g.FillEllipse(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 85, 30, 15); - g.FillEllipse(additionalBrush, _startPosX.Value + 110, _startPosY.Value + 85, 30, 15); - } - - // труба - if (EntityLiner.Pipe) - { - - Point point9 = new Point(_startPosX.Value + 90, _startPosY.Value + 10); - Point point10 = new Point(_startPosX.Value + 90, _startPosY.Value + 40); - Point point11 = new Point(_startPosX.Value + 115, _startPosY.Value + 40); - Point point12 = new Point(_startPosX.Value + 115, _startPosY.Value + 10); - Point[] curvePoints3 = { point9, point10, point11, point12 }; - g.FillPolygon(br, curvePoints3); - } } } diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs new file mode 100644 index 0000000..a2ce841 --- /dev/null +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs @@ -0,0 +1,72 @@ +using ProjectLiner.Entities; + +namespace ProjectLiner.Drawnings; + +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// +public class DrawningLiner : DrawningCommonLiner +{ + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия якоря + /// Признак наличия шлюпок + /// Признак наличия трубы + public DrawningLiner(int speed, double weight, Color bodycolor, Color additionalColor, bool anchor, bool boats, bool pipe) : base(150, 125) + { + EntityCommonLiner = new EntityLiner(speed, weight, bodycolor, additionalColor, anchor, boats, pipe); + + } + + public override void DrawTransport(Graphics g) + { + if (EntityCommonLiner == null || EntityCommonLiner is not EntityLiner liner || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + Pen pen = new(Color.Black); + Brush additionalBrush = new SolidBrush(liner.AdditionalColor); + Brush br = new SolidBrush(liner.BodyColor); + + _startPosY += 40; + base.DrawTransport(g); + _startPosY -= 40; + + + // якорь + if (liner.Anchor) + { + g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 85, _startPosX.Value + 45, _startPosY.Value + 115); + g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 95, _startPosX.Value + 60, _startPosY.Value + 95); + g.DrawLine(pen, _startPosX.Value + 25, _startPosY.Value + 100, _startPosX.Value + 45, _startPosY.Value + 115); + g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 115, _startPosX.Value + 65, _startPosY.Value + 100); + } + + // шлюпки + if (liner.Boats) + { + g.FillEllipse(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 85, 30, 15); + g.FillEllipse(additionalBrush, _startPosX.Value + 75, _startPosY.Value + 85, 30, 15); + g.FillEllipse(additionalBrush, _startPosX.Value + 110, _startPosY.Value + 85, 30, 15); + } + + // труба + if (liner.Pipe) + { + + Point point9 = new Point(_startPosX.Value + 90, _startPosY.Value + 10); + Point point10 = new Point(_startPosX.Value + 90, _startPosY.Value + 40); + Point point11 = new Point(_startPosX.Value + 115, _startPosY.Value + 40); + Point point12 = new Point(_startPosX.Value + 115, _startPosY.Value + 10); + Point[] curvePoints3 = { point9, point10, point11, point12 }; + g.FillPolygon(br, curvePoints3); + } + } + +} diff --git a/ProjectLiner/ProjectLiner/Entities/EntityCommonLiner.cs b/ProjectLiner/ProjectLiner/Entities/EntityCommonLiner.cs new file mode 100644 index 0000000..bb99401 --- /dev/null +++ b/ProjectLiner/ProjectLiner/Entities/EntityCommonLiner.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +/// +/// Класс-сущность обычного "Лайнера" +/// + +namespace ProjectLiner.Entities +{ + public class EntityCommonLiner + { + /// + /// Скорость + /// + 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 EntityCommonLiner(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + + } + } +} diff --git a/ProjectLiner/ProjectLiner/EntityLiner.cs b/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs similarity index 58% rename from ProjectLiner/ProjectLiner/EntityLiner.cs rename to ProjectLiner/ProjectLiner/Entities/EntityLiner.cs index 66d27c1..18a65d3 100644 --- a/ProjectLiner/ProjectLiner/EntityLiner.cs +++ b/ProjectLiner/ProjectLiner/Entities/EntityLiner.cs @@ -1,24 +1,10 @@ -namespace ProjectLiner; +namespace ProjectLiner.Entities; /// /// Класс-сущность "Лайнер" /// -public class EntityLiner +public class EntityLiner: EntityCommonLiner { - /// - /// Скорость - /// - public int Speed { get; private set; } - - /// - /// Вес - /// - public double Weight { get; private set; } - - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } /// /// Дополнительный цвет (для опциональных элементов) @@ -40,26 +26,17 @@ public class EntityLiner /// public bool Pipe { get; private set; } - /// - /// Шаг перемещения автомобиля - /// - public double Step => Speed * 100 / Weight; /// /// Инициализация полей объекта-класса спортивного автомобиля /// - /// Скорость - /// Вес автомобиля - /// Основной цвет /// Дополнительный цвет /// Признак наличия якоря /// Признак наличия шлюпок /// Признак наличия трубы - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool anchor, bool boats, bool pipe) + public EntityLiner(int speed, double weight, Color bodyColor, Color additionalColor, bool anchor, bool boats, bool pipe) : base(speed, weight, bodyColor) { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; + new EntityCommonLiner(speed, weight, bodyColor); AdditionalColor = additionalColor; Anchor = anchor; Boats = boats; diff --git a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs index 94eb653..2806d52 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs @@ -34,6 +34,7 @@ buttonUp = new Button(); buttonLeft = new Button(); buttonRight = new Button(); + buttonCreateCommonLiner = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).BeginInit(); SuspendLayout(); // @@ -50,11 +51,11 @@ // buttonCreate // buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreate.Location = new Point(12, 520); + buttonCreate.Location = new Point(12, 544); buttonCreate.Name = "buttonCreate"; - buttonCreate.Size = new Size(150, 82); + buttonCreate.Size = new Size(203, 58); buttonCreate.TabIndex = 1; - buttonCreate.Text = "Создать"; + buttonCreate.Text = "Создать Лайнер"; buttonCreate.UseVisualStyleBackColor = true; buttonCreate.Click += buttonCreate_Click; // @@ -106,11 +107,23 @@ buttonRight.UseVisualStyleBackColor = true; buttonRight.Click += ButtonMove_Click; // + // buttonCreateCommonLiner + // + buttonCreateCommonLiner.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateCommonLiner.Location = new Point(221, 544); + buttonCreateCommonLiner.Name = "buttonCreateCommonLiner"; + buttonCreateCommonLiner.Size = new Size(240, 58); + buttonCreateCommonLiner.TabIndex = 6; + buttonCreateCommonLiner.Text = "Создать Обычный Лайнер"; + buttonCreateCommonLiner.UseVisualStyleBackColor = true; + buttonCreateCommonLiner.Click += buttonCreateCommonLiner_Click; + // // FormLiner // AutoScaleDimensions = new SizeF(11F, 25F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(948, 614); + Controls.Add(buttonCreateCommonLiner); Controls.Add(buttonRight); Controls.Add(buttonLeft); Controls.Add(buttonUp); @@ -131,5 +144,6 @@ private Button buttonUp; private Button buttonLeft; private Button buttonRight; + private Button buttonCreateCommonLiner; } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs index c72187d..8597fce 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.cs @@ -7,12 +7,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using ProjectLiner.Drawnings; namespace ProjectLiner { public partial class FormLiner : Form { - private DrawningLiner? _drawningLiner; + private DrawningCommonLiner? _drawningCommonLiner; public FormLiner() { InitializeComponent(); @@ -23,35 +24,66 @@ namespace ProjectLiner /// private void Draw() { - if (_drawningLiner == null) + if (_drawningCommonLiner == null) { return; } Bitmap bmp = new(pictureBoxLiner.Width, pictureBoxLiner.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningLiner.DrawTransport(gr); + _drawningCommonLiner.DrawTransport(gr); pictureBoxLiner.Image = bmp; } /// - /// Обработка нажатия кнопки "Создать" + /// Создание объекта класса-перемещения + /// + /// Тип создаваемого объекта + private void CreateObject(string type) + { + Random random = new(); + switch (type) + { + case nameof(DrawningCommonLiner): + _drawningCommonLiner = new DrawningCommonLiner(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(DrawningLiner): + _drawningCommonLiner = new DrawningLiner(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)), Convert.ToBoolean(random.Next(0, 2))); + break; + default: + return; + + } + + _drawningCommonLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); + _drawningCommonLiner.SetPosition(random.Next(10, 100), random.Next(10, 100)); + + Draw(); + } + + /// + /// Обработка нажатия кнопки "Создать Лайнер" /// /// /// private void buttonCreate_Click(object sender, EventArgs e) { - Random random = new(); - EntityLiner liner = new EntityLiner(); - liner.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)), Convert.ToBoolean(random.Next(0, 2))); - _drawningLiner = new DrawningLiner(); - _drawningLiner.Init(liner); - _drawningLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); - _drawningLiner.SetPosition(random.Next(10, 100), random.Next(10, 100)); - Draw(); + CreateObject(nameof(DrawningLiner)); + } + + /// + /// Обработка нажатия кнопки "Создать Обычный Лайнер" + /// + /// + /// + + private void buttonCreateCommonLiner_Click(object sender, EventArgs e) + { + CreateObject(nameof(DrawningCommonLiner)); } /// @@ -61,7 +93,7 @@ namespace ProjectLiner /// private void ButtonMove_Click(object sender, EventArgs e) { - if (_drawningLiner == null) + if (_drawningCommonLiner == null) { return; } @@ -71,16 +103,16 @@ namespace ProjectLiner switch (name) { case "buttonUp": - result = _drawningLiner.MoveTransport(DirectionType.Up); + result = _drawningCommonLiner.MoveTransport(DirectionType.Up); break; case "buttonDown": - result = _drawningLiner.MoveTransport(DirectionType.Down); + result = _drawningCommonLiner.MoveTransport(DirectionType.Down); break; case "buttonLeft": - result = _drawningLiner.MoveTransport(DirectionType.Left); + result = _drawningCommonLiner.MoveTransport(DirectionType.Left); break; case "buttonRight": - result = _drawningLiner.MoveTransport(DirectionType.Right); + result = _drawningCommonLiner.MoveTransport(DirectionType.Right); break; } @@ -89,5 +121,6 @@ namespace ProjectLiner Draw(); } } + } } From ecfe3f3131795c7eb4b6f126e3e20de3b27862a8 Mon Sep 17 00:00:00 2001 From: gettterot Date: Wed, 6 Mar 2024 09:38:21 +0400 Subject: [PATCH 05/11] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D1=82=D0=B5=D0=B3?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=20=D1=86=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D1=80=D1=83=20=D0=B8=20=D0=BA=20=D0=BA=D1=80=D0=B0?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectLiner/Drawnings/DirectionType.cs | 5 + .../Drawnings/DrawningCommonLiner.cs | 20 +++ .../ProjectLiner/Drawnings/DrawningLiner.cs | 4 +- .../ProjectLiner/FormLiner.Designer.cs | 26 ++++ ProjectLiner/ProjectLiner/FormLiner.cs | 49 +++++- .../MovementStrategy/AbstractStrategy.cs | 145 ++++++++++++++++++ .../MovementStrategy/IMoveableObjectcs.cs | 30 ++++ .../MovementStrategy/MoveToBorder.cs | 58 +++++++ .../MovementStrategy/MoveToCenter.cs | 60 ++++++++ .../MovementStrategy/MoveableLiner.cs | 69 +++++++++ .../MovementStrategy/MovementDirection.cs | 30 ++++ .../MovementStrategy/ObjectParameters.cs | 78 ++++++++++ .../MovementStrategy/StrategyStatus.cs | 27 ++++ 13 files changed, 598 insertions(+), 3 deletions(-) create mode 100644 ProjectLiner/ProjectLiner/MovementStrategy/AbstractStrategy.cs create mode 100644 ProjectLiner/ProjectLiner/MovementStrategy/IMoveableObjectcs.cs create mode 100644 ProjectLiner/ProjectLiner/MovementStrategy/MoveToBorder.cs create mode 100644 ProjectLiner/ProjectLiner/MovementStrategy/MoveToCenter.cs create mode 100644 ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs create mode 100644 ProjectLiner/ProjectLiner/MovementStrategy/MovementDirection.cs create mode 100644 ProjectLiner/ProjectLiner/MovementStrategy/ObjectParameters.cs create mode 100644 ProjectLiner/ProjectLiner/MovementStrategy/StrategyStatus.cs diff --git a/ProjectLiner/ProjectLiner/Drawnings/DirectionType.cs b/ProjectLiner/ProjectLiner/Drawnings/DirectionType.cs index cc78a5a..bca182c 100644 --- a/ProjectLiner/ProjectLiner/Drawnings/DirectionType.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DirectionType.cs @@ -5,6 +5,11 @@ /// public enum DirectionType { + /// + /// Неизвестное направление + /// + Unknow = -1, + /// /// Вверх /// diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs index 2bc1885..f3e6fe6 100644 --- a/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs @@ -43,6 +43,26 @@ public class DrawningCommonLiner /// private readonly int _drawningLinerHeight = 90; + /// + /// Координата X объекта + /// + public int? GetPosX => _startPosX; + + /// + /// Координата Y объекта + /// + public int? GetPosY => _startPosY; + + /// + /// Ширина объекта + /// + public int GetWidth => _drawningLinerWidth; + + /// + /// Высота объекта + /// + public int GetHeight => _drawningLinerHeight; + /// /// Пустой конструктор /// diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs index a2ce841..46a4021 100644 --- a/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningLiner.cs @@ -12,7 +12,7 @@ public class DrawningLiner : DrawningCommonLiner /// /// Скорость /// Вес - /// Основной цвет + /// Основной цвет /// Дополнительный цвет /// Признак наличия якоря /// Признак наличия шлюпок @@ -65,7 +65,7 @@ public class DrawningLiner : DrawningCommonLiner Point point11 = new Point(_startPosX.Value + 115, _startPosY.Value + 40); Point point12 = new Point(_startPosX.Value + 115, _startPosY.Value + 10); Point[] curvePoints3 = { point9, point10, point11, point12 }; - g.FillPolygon(br, curvePoints3); + g.FillPolygon(additionalBrush, curvePoints3); } } diff --git a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs index 2806d52..c21ee63 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs @@ -35,6 +35,8 @@ buttonLeft = new Button(); buttonRight = new Button(); buttonCreateCommonLiner = new Button(); + comboBoxStrategy = new ComboBox(); + buttonStrategyStep = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).BeginInit(); SuspendLayout(); // @@ -118,11 +120,33 @@ buttonCreateCommonLiner.UseVisualStyleBackColor = true; buttonCreateCommonLiner.Click += buttonCreateCommonLiner_Click; // + // comboBoxStrategy + // + comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStrategy.FormattingEnabled = true; + comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" }); + comboBoxStrategy.Location = new Point(742, 12); + comboBoxStrategy.Name = "comboBoxStrategy"; + comboBoxStrategy.Size = new Size(194, 33); + comboBoxStrategy.TabIndex = 11; + // + // buttonStrategyStep + // + buttonStrategyStep.Location = new Point(816, 51); + buttonStrategyStep.Name = "buttonStrategyStep"; + buttonStrategyStep.Size = new Size(120, 37); + buttonStrategyStep.TabIndex = 12; + buttonStrategyStep.Text = "Шаг"; + buttonStrategyStep.UseVisualStyleBackColor = true; + buttonStrategyStep.Click += buttonStrategyStep_Click; + // // FormLiner // AutoScaleDimensions = new SizeF(11F, 25F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(948, 614); + Controls.Add(buttonStrategyStep); + Controls.Add(comboBoxStrategy); Controls.Add(buttonCreateCommonLiner); Controls.Add(buttonRight); Controls.Add(buttonLeft); @@ -145,5 +169,7 @@ private Button buttonLeft; private Button buttonRight; private Button buttonCreateCommonLiner; + private ComboBox comboBoxStrategy; + private Button buttonStrategyStep; } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs index 8597fce..aa13498 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.cs @@ -8,15 +8,19 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ProjectLiner.Drawnings; +using ProjectLiner.MovementStrategy; namespace ProjectLiner { public partial class FormLiner : Form { private DrawningCommonLiner? _drawningCommonLiner; + + private AbstractStrategy? _strategy; public FormLiner() { InitializeComponent(); + _strategy = null; } /// @@ -61,7 +65,8 @@ namespace ProjectLiner _drawningCommonLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); _drawningCommonLiner.SetPosition(random.Next(10, 100), random.Next(10, 100)); - + _strategy = null; + comboBoxStrategy.Enabled = true; Draw(); } @@ -122,5 +127,47 @@ namespace ProjectLiner } } + /// + /// Обработка нажатия кнопки "Шаг" + /// + /// + /// + private void buttonStrategyStep_Click(object sender, EventArgs e) + { + if (_drawningCommonLiner == null) + { + return; + } + + if (comboBoxStrategy.Enabled) + { + _strategy = comboBoxStrategy.SelectedIndex switch + { + 0 => new MoveToCenter(), + 1 => new MoveToBorder(), + _ => null, + }; + if (_strategy == null) + { + return; + } + _strategy.SetData(new MoveableLiner(_drawningCommonLiner), pictureBoxLiner.Width, pictureBoxLiner.Height); + } + + if (_strategy == null) + { + return; + } + + comboBoxStrategy.Enabled = false; + _strategy.MakeStep(); + Draw(); + + if (_strategy.GetStatus() == StrategyStatus.Finish) + { + comboBoxStrategy.Enabled = true; + _strategy = null; + } + } } } diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/AbstractStrategy.cs b/ProjectLiner/ProjectLiner/MovementStrategy/AbstractStrategy.cs new file mode 100644 index 0000000..ca37c66 --- /dev/null +++ b/ProjectLiner/ProjectLiner/MovementStrategy/AbstractStrategy.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.MovementStrategy; +/// +/// Класс-стратегия перемещения объекта +/// +public abstract class AbstractStrategy +{ + /// + /// Перемещаемый объект + /// + private IMoveableObject? _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(IMoveableObject 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 (IsTargetDestination()) + { + _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 IsTargetDestination(); + + /// + /// Попытка перемещения в требуемом направлении + /// + /// Направление + /// Результат попытки (true - удалось, false - неудача) + private bool MoveTo(MovementDirection movementDirection) + { + if (_state != StrategyStatus.InProgress) + { + return false; + } + + return _moveableObject?.TryMoveObject(movementDirection) ?? false; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/IMoveableObjectcs.cs b/ProjectLiner/ProjectLiner/MovementStrategy/IMoveableObjectcs.cs new file mode 100644 index 0000000..a5ace3f --- /dev/null +++ b/ProjectLiner/ProjectLiner/MovementStrategy/IMoveableObjectcs.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.MovementStrategy; + +/// +/// Интерфейс для работы с перемещаемым объектом +/// +public interface IMoveableObject +{ + /// + /// Получение координаты объекта + /// + ObjectParameters? GetObjectPosition { get; } + + /// + /// Шаг объекта + /// + int GetStep { get; } + + /// + /// Попытка переместить объект в указанном направлении + /// + /// Направление + /// true - объект перемещен, false - перемещение невозможно + bool TryMoveObject(MovementDirection direction); +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/MoveToBorder.cs b/ProjectLiner/ProjectLiner/MovementStrategy/MoveToBorder.cs new file mode 100644 index 0000000..37eced3 --- /dev/null +++ b/ProjectLiner/ProjectLiner/MovementStrategy/MoveToBorder.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.MovementStrategy; + +/// +/// Стратегия перемещения объекта к правой нижней границы +/// +public class MoveToBorder : AbstractStrategy +{ + protected override bool IsTargetDestination() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + + return objParams.RightBorder <= FieldWidth && objParams.RightBorder + GetStep() >= FieldWidth && + objParams.DownBorder <= FieldHeight && objParams.DownBorder + GetStep() >= FieldHeight; + } + + protected override void MoveToTarget() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + int diffX = objParams.RightBorder - FieldWidth; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + int diffY = objParams.DownBorder - FieldHeight; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } +} diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/MoveToCenter.cs b/ProjectLiner/ProjectLiner/MovementStrategy/MoveToCenter.cs new file mode 100644 index 0000000..afe820c --- /dev/null +++ b/ProjectLiner/ProjectLiner/MovementStrategy/MoveToCenter.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.MovementStrategy; + +/// +/// Стратегия перемещения объекта в центр экрана +/// +public class MoveToCenter : AbstractStrategy +{ + protected override bool IsTargetDestination() + { + 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/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs b/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs new file mode 100644 index 0000000..c87517a --- /dev/null +++ b/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs @@ -0,0 +1,69 @@ +using ProjectLiner.Drawnings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.MovementStrategy; + +/// +/// Класс-реализация IMoveableObject с использованием DrawningCommonLiner +/// +public class MoveableLiner : IMoveableObject +{ + /// + /// Поле-объект класса DrawningCommonLiner или его наследника + /// + private readonly DrawningCommonLiner? _CommonLiner = null; + + /// + /// Конструктор + /// + /// Объект класса DrawningCommonLiner + public MoveableLiner(DrawningCommonLiner CommonLiner) + { + _CommonLiner = CommonLiner; + } + + public ObjectParameters? GetObjectPosition + { + get + { + if (_CommonLiner == null || _CommonLiner.EntityCommonLiner == null || !_CommonLiner.GetPosX.HasValue || !_CommonLiner.GetPosY.HasValue) + { + return null; + } + return new ObjectParameters(_CommonLiner.GetPosX.Value, _CommonLiner.GetPosY.Value, _CommonLiner.GetWidth, _CommonLiner.GetHeight); + } + } + + public int GetStep => (int)(_CommonLiner?.EntityCommonLiner?.Step ?? 0); + + public bool TryMoveObject(MovementDirection direction) + { + if (_CommonLiner == null || _CommonLiner.EntityCommonLiner == null) + { + return false; + } + + return _CommonLiner.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, + }; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/MovementDirection.cs b/ProjectLiner/ProjectLiner/MovementStrategy/MovementDirection.cs new file mode 100644 index 0000000..3981ef6 --- /dev/null +++ b/ProjectLiner/ProjectLiner/MovementStrategy/MovementDirection.cs @@ -0,0 +1,30 @@ +namespace ProjectLiner.MovementStrategy; + + + +/// +/// Направление перемещения +/// +public enum MovementDirection +{ + /// + /// Вверх + /// + Up = 1, + + /// + /// Вниз + /// + Down = 2, + + /// + /// Влево + /// + Left = 3, + + /// + /// Вправо + /// + Right = 4 +} + diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/ObjectParameters.cs b/ProjectLiner/ProjectLiner/MovementStrategy/ObjectParameters.cs new file mode 100644 index 0000000..251aa9a --- /dev/null +++ b/ProjectLiner/ProjectLiner/MovementStrategy/ObjectParameters.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.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; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/StrategyStatus.cs b/ProjectLiner/ProjectLiner/MovementStrategy/StrategyStatus.cs new file mode 100644 index 0000000..b221f83 --- /dev/null +++ b/ProjectLiner/ProjectLiner/MovementStrategy/StrategyStatus.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectLiner.MovementStrategy; +/// +/// Статус выполнения операции перемещения +/// +public enum StrategyStatus +{ + /// + /// Все готово к началу + /// + NotInit, + + /// + /// Выполняется + /// + InProgress, + + /// + /// Завершено + /// + Finish +} \ No newline at end of file From f1f6698e1fee6a2d006a12400df5b08df8cb7ae5 Mon Sep 17 00:00:00 2001 From: gettterot Date: Wed, 6 Mar 2024 09:45:25 +0400 Subject: [PATCH 06/11] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=D1=80=D0=B8=D1=8F=20=D0=B2=20DrawningCommonLiner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs index f3e6fe6..b47fb35 100644 --- a/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs @@ -6,6 +6,9 @@ using System.Text; using System.Threading.Tasks; namespace ProjectLiner.Drawnings; +/// +/// Класс, отвечающий за прорисовку и перемещение обычного объекта-сущности +/// public class DrawningCommonLiner { /// @@ -36,7 +39,7 @@ public class DrawningCommonLiner /// /// Ширина прорисовки лайнера /// - private readonly int _drawningLinerWidth = 150; + private readonly int _drawningLinerWidth = 155; /// /// Высота прорисовки лайнера From fb4cc240a19c23c1fc6d7ca4efc589d6059815e5 Mon Sep 17 00:00:00 2001 From: gettterot Date: Fri, 15 Mar 2024 09:36:48 +0400 Subject: [PATCH 07/11] Adding abstract class --- .../MovementStrategy/IMoveableObjectcs.cs | 10 ++++++++++ .../MovementStrategy/MoveableLiner.cs | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/IMoveableObjectcs.cs b/ProjectLiner/ProjectLiner/MovementStrategy/IMoveableObjectcs.cs index a5ace3f..e2b5686 100644 --- a/ProjectLiner/ProjectLiner/MovementStrategy/IMoveableObjectcs.cs +++ b/ProjectLiner/ProjectLiner/MovementStrategy/IMoveableObjectcs.cs @@ -16,6 +16,8 @@ public interface IMoveableObject /// ObjectParameters? GetObjectPosition { get; } + int AnotherStep { set; } + /// /// Шаг объекта /// @@ -27,4 +29,12 @@ public interface IMoveableObject /// Направление /// true - объект перемещен, false - перемещение невозможно bool TryMoveObject(MovementDirection direction); + + + /// + /// ненужный метод + /// + /// Первое число + + void MegaTurboStep(int value); } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs b/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs index c87517a..b067010 100644 --- a/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs +++ b/ProjectLiner/ProjectLiner/MovementStrategy/MoveableLiner.cs @@ -1,4 +1,5 @@ using ProjectLiner.Drawnings; +using ProjectLiner.Entities; using System; using System.Collections.Generic; using System.Linq; @@ -40,13 +41,20 @@ public class MoveableLiner : IMoveableObject public int GetStep => (int)(_CommonLiner?.EntityCommonLiner?.Step ?? 0); + public int AnotherStep + { + set + { + AnotherStep = value; + } + } + public bool TryMoveObject(MovementDirection direction) { if (_CommonLiner == null || _CommonLiner.EntityCommonLiner == null) { return false; } - return _CommonLiner.MoveTransport(GetDirectionType(direction)); } @@ -66,4 +74,9 @@ public class MoveableLiner : IMoveableObject _ => DirectionType.Unknow, }; } + + public void MegaTurboStep(int value) + { + AnotherStep = value; + } } \ No newline at end of file From 359c50745bfc19c79681f2cac128f312eae3bf2c Mon Sep 17 00:00:00 2001 From: gettterot Date: Tue, 19 Mar 2024 10:26:26 +0400 Subject: [PATCH 08/11] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 118 +++++++++++ .../ICollectionGenericObjects.cs | 49 +++++ .../LinerSharingService.cs | 74 +++++++ .../MassiveGenericObjects.cs | 111 +++++++++++ .../ProjectLiner/FormLiner.Designer.cs | 66 +++--- ProjectLiner/ProjectLiner/FormLiner.cs | 68 ++----- .../FormLinerCollection.Designer.cs | 173 ++++++++++++++++ .../ProjectLiner/FormLinerCollection.cs | 188 ++++++++++++++++++ .../ProjectLiner/FormLinerCollection.resx | 120 +++++++++++ ProjectLiner/ProjectLiner/Program.cs | 2 +- 10 files changed, 874 insertions(+), 95 deletions(-) create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs create mode 100644 ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs create mode 100644 ProjectLiner/ProjectLiner/FormLinerCollection.cs create mode 100644 ProjectLiner/ProjectLiner/FormLinerCollection.resx diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs new file mode 100644 index 0000000..1eb7aa1 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs @@ -0,0 +1,118 @@ +using ProjectLiner.CollectionGenericObjects; +using ProjectLiner.Drawnings; + +namespace ProjectLiner.CollectionGenericObjects +{ + /// + /// Абстракция компании, хранящий коллекцию лайнеров + /// + public abstract class AbstractCompany + { + /// + /// Размер места (ширина) + /// + protected readonly int _placeSizeWidth = 210; + + /// + /// Размер места (высота) + /// + protected readonly int _placeSizeHeight = 110; + + /// + /// Ширина окна + /// + protected readonly int _pictureWidth; + + /// + /// Высота окна + /// + protected readonly int _pictureHeight; + + /// + /// Коллекция лайнеров + /// + protected ICollectionGenericObjects? _collection = null; + + /// + /// Вычисление максимального количества элементов, который можно разместить в окне + /// + private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight); + + /// + /// Конструктор + /// + /// Ширина окна + /// Высота окна + /// Коллекция лайнеров + public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects collection) + { + _pictureWidth = picWidth; + _pictureHeight = picHeight; + _collection = collection; + _collection.SetMaxCount = GetMaxCount; + } + + /// + /// Перегрузка оператора сложения для класса + /// + /// Компания + /// Добавляемый объект + /// + public static bool operator +(AbstractCompany company, DrawningCommonLiner Liner) + { + return company._collection?.Insert(Liner) ?? false; + } + + /// + /// Перегрузка оператора удаления для класса + /// + /// Компания + /// Номер удаляемого объекта + /// + public static bool operator -(AbstractCompany company, int position) + { + return company._collection?.Remove(position) ?? false; + } + + /// + /// Получение случайного объекта из коллекции + /// + /// + public DrawningCommonLiner? GetRandomObject() + { + Random rnd = new(); + return _collection?.Get(rnd.Next(GetMaxCount)); + } + + /// + /// Вывод всей коллекции + /// + /// + public Bitmap? Show() + { + Bitmap bitmap = new(_pictureWidth, _pictureHeight); + Graphics graphics = Graphics.FromImage(bitmap); + DrawBackgound(graphics); + + SetObjectsPosition(); + for (int i = 0; i < (_collection?.Count ?? 0); ++i) + { + DrawningCommonLiner? obj = _collection?.Get(i); + obj?.DrawTransport(graphics); + } + + return bitmap; + } + + /// + /// Вывод заднего фона + /// + /// + protected abstract void DrawBackgound(Graphics g); + + /// + /// Расстановка объектов + /// + protected abstract void SetObjectsPosition(); + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs new file mode 100644 index 0000000..9e2ed2f --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -0,0 +1,49 @@ +namespace ProjectLiner.CollectionGenericObjects +{ + /// + /// Интерфейс описания действий для набора хранимых объектов + /// + /// Параметр: ограничение - ссылочный тип + public interface ICollectionGenericObjects + where T : class + { + /// + /// Количество объектов в коллекции + /// + int Count { get; } + + /// + /// Установка максимального количества элементов + /// + int SetMaxCount { set; } + + /// + /// Добавление объекта в коллекцию + /// + /// Добавляемый объект + /// true - вставка прошла удачно, false - вставка не удалась + bool Insert(T obj); + + /// + /// Добавление объекта в коллекцию на конкретную позицию + /// + /// Добавляемый объект + /// Позиция + /// true - вставка прошла удачно, false - вставка не удалась + bool Insert(T obj, int position); + + /// + /// Удаление объекта из коллекции с конкретной позиции + /// + /// Позиция + /// true - удаление прошло удачно, false - удаление не удалось + bool Remove(int position); + + /// + /// Получение объекта по позиции + /// + /// Позиция + /// Объект + T? Get(int position); + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs new file mode 100644 index 0000000..0501fa8 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs @@ -0,0 +1,74 @@ + +using ProjectLiner.Drawnings; +using ProjectLiner.CollectionGenericObjects; + +namespace ProjectLiner.CollectionGenericObjects; + +/// +/// Реализация абстрактной компании - лайнер +/// +public class LinerSharingService : AbstractCompany +{ + /// + /// Конструктор + /// + /// Ширина + /// Высота + /// Коллекция + public LinerSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) + { + } + + protected override void DrawBackgound(Graphics g) + { + + int count_width = _pictureWidth / _placeSizeWidth; // кол-во мест в ширину + int count_height = _pictureHeight / _placeSizeHeight; + Pen pen = new(Color.Black, 3); + for (int i = 0; i < count_width; i++) + { + for (int j = 0; j < count_height + 1; ++j) + { + g.DrawLine(pen, i * _placeSizeWidth + 10, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 50, j * _placeSizeHeight); // вертикаль + g.DrawLine(pen, i * _placeSizeWidth + 10, j * _placeSizeHeight, i * _placeSizeWidth + 10, j * _placeSizeHeight + _placeSizeHeight); + } + } + } + + protected override void SetObjectsPosition() + { + + int width = _pictureWidth / _placeSizeWidth; + int height = _pictureHeight / _placeSizeHeight; + int positionWidth = 0; + int positionHeight = height - 1; + + if (_collection?.Count != null) + { + for (int i = 0; i < (_collection.Count); i++) + { + if (_collection.Get(i) != null) + { + _collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight); + _collection.Get(i).SetPosition(_placeSizeWidth * positionWidth + 25, positionHeight * _placeSizeHeight + 10); + } + + if (positionWidth < width - 1) + { + positionWidth++; + } + + else + { + positionWidth = 0; + positionHeight--; + } + if (positionHeight < 0) + { + return; + } + } + } + + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs new file mode 100644 index 0000000..9865dd0 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs @@ -0,0 +1,111 @@ +using ProjectLiner.CollectionGenericObjects; + +namespace ProjectLiner.CollectionGenericObjects +{ + /// + /// Параметризованный набор объектов + /// + /// Параметр: ограничение - ссылочный тип + public class MassiveGenericObjects : ICollectionGenericObjects + where T : class + { + /// + /// Массив объектов, которые храним + /// + private T?[] _collection; + + public int Count => _collection.Length; + + public int SetMaxCount + { + set + { + if (value > 0) + { + if (_collection.Length > 0) + { + Array.Resize(ref _collection, value); + } + else + { + _collection = new T?[value]; + } + } + } + } + + /// + /// Конструктор + /// + public MassiveGenericObjects() + { + _collection = Array.Empty(); + } + + public T? Get(int position) + { + if (position < 0 || position >= Count) + return null; + return _collection[position]; + } + + public bool Insert(T obj) + { + for (int i = 0; i < Count; i++) + { + if (_collection[i] == null) + { + _collection[i] = obj; + return true; + } + } + return false; + } + + public bool Insert(T obj, int position) + { + if (position < 0 || position >= Count) + return false; + + if (_collection[position] == null) + { + _collection[position] = obj; + return true; + } + + int temp = position + 1; + while (temp < Count) + { + if (_collection[temp] == null) + { + _collection[temp] = obj; + return true; + } + temp++; + } + + temp = position - 1; + while (temp > 0) + { + if (_collection[temp] == null) + { + _collection[temp] = obj; + return true; + } + temp--; + } + + return false; + } + + public bool Remove(int position) + { + if (position < 0 || position >= Count) + return false; + + _collection[position] = null; + + return true; + } + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs index c21ee63..7dc1072 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs @@ -29,12 +29,10 @@ private void InitializeComponent() { pictureBoxLiner = new PictureBox(); - buttonCreate = new Button(); buttonDown = new Button(); buttonUp = new Button(); buttonLeft = new Button(); buttonRight = new Button(); - buttonCreateCommonLiner = new Button(); comboBoxStrategy = new ComboBox(); buttonStrategyStep = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).BeginInit(); @@ -45,30 +43,21 @@ pictureBoxLiner.BackColor = SystemColors.Control; pictureBoxLiner.Dock = DockStyle.Fill; pictureBoxLiner.Location = new Point(0, 0); + pictureBoxLiner.Margin = new Padding(5, 5, 5, 5); pictureBoxLiner.Name = "pictureBoxLiner"; - pictureBoxLiner.Size = new Size(948, 614); + pictureBoxLiner.Size = new Size(1465, 1007); pictureBoxLiner.TabIndex = 0; pictureBoxLiner.TabStop = false; // - // buttonCreate - // - buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreate.Location = new Point(12, 544); - buttonCreate.Name = "buttonCreate"; - buttonCreate.Size = new Size(203, 58); - buttonCreate.TabIndex = 1; - buttonCreate.Text = "Создать Лайнер"; - buttonCreate.UseVisualStyleBackColor = true; - buttonCreate.Click += buttonCreate_Click; - // // buttonDown // buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonDown.BackgroundImage = Properties.Resources.bottom; buttonDown.BackgroundImageLayout = ImageLayout.Stretch; - buttonDown.Location = new Point(830, 552); + buttonDown.Location = new Point(1283, 905); + buttonDown.Margin = new Padding(5, 5, 5, 5); buttonDown.Name = "buttonDown"; - buttonDown.Size = new Size(50, 50); + buttonDown.Size = new Size(77, 82); buttonDown.TabIndex = 2; buttonDown.UseVisualStyleBackColor = true; buttonDown.Click += ButtonMove_Click; @@ -78,9 +67,10 @@ buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonUp.BackgroundImage = Properties.Resources.top; buttonUp.BackgroundImageLayout = ImageLayout.Stretch; - buttonUp.Location = new Point(830, 496); + buttonUp.Location = new Point(1283, 813); + buttonUp.Margin = new Padding(5, 5, 5, 5); buttonUp.Name = "buttonUp"; - buttonUp.Size = new Size(50, 50); + buttonUp.Size = new Size(77, 82); buttonUp.TabIndex = 3; buttonUp.UseVisualStyleBackColor = true; buttonUp.Click += ButtonMove_Click; @@ -90,9 +80,10 @@ buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonLeft.BackgroundImage = Properties.Resources.left; buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; - buttonLeft.Location = new Point(774, 552); + buttonLeft.Location = new Point(1196, 905); + buttonLeft.Margin = new Padding(5, 5, 5, 5); buttonLeft.Name = "buttonLeft"; - buttonLeft.Size = new Size(50, 50); + buttonLeft.Size = new Size(77, 82); buttonLeft.TabIndex = 4; buttonLeft.UseVisualStyleBackColor = true; buttonLeft.Click += ButtonMove_Click; @@ -102,39 +93,31 @@ buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonRight.BackgroundImage = Properties.Resources.right; buttonRight.BackgroundImageLayout = ImageLayout.Stretch; - buttonRight.Location = new Point(886, 552); + buttonRight.Location = new Point(1369, 905); + buttonRight.Margin = new Padding(5, 5, 5, 5); buttonRight.Name = "buttonRight"; - buttonRight.Size = new Size(50, 50); + buttonRight.Size = new Size(77, 82); buttonRight.TabIndex = 5; buttonRight.UseVisualStyleBackColor = true; buttonRight.Click += ButtonMove_Click; // - // buttonCreateCommonLiner - // - buttonCreateCommonLiner.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreateCommonLiner.Location = new Point(221, 544); - buttonCreateCommonLiner.Name = "buttonCreateCommonLiner"; - buttonCreateCommonLiner.Size = new Size(240, 58); - buttonCreateCommonLiner.TabIndex = 6; - buttonCreateCommonLiner.Text = "Создать Обычный Лайнер"; - buttonCreateCommonLiner.UseVisualStyleBackColor = true; - buttonCreateCommonLiner.Click += buttonCreateCommonLiner_Click; - // // comboBoxStrategy // comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxStrategy.FormattingEnabled = true; comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" }); - comboBoxStrategy.Location = new Point(742, 12); + comboBoxStrategy.Location = new Point(1147, 20); + comboBoxStrategy.Margin = new Padding(5, 5, 5, 5); comboBoxStrategy.Name = "comboBoxStrategy"; - comboBoxStrategy.Size = new Size(194, 33); + comboBoxStrategy.Size = new Size(298, 49); comboBoxStrategy.TabIndex = 11; // // buttonStrategyStep // - buttonStrategyStep.Location = new Point(816, 51); + buttonStrategyStep.Location = new Point(1261, 84); + buttonStrategyStep.Margin = new Padding(5, 5, 5, 5); buttonStrategyStep.Name = "buttonStrategyStep"; - buttonStrategyStep.Size = new Size(120, 37); + buttonStrategyStep.Size = new Size(185, 61); buttonStrategyStep.TabIndex = 12; buttonStrategyStep.Text = "Шаг"; buttonStrategyStep.UseVisualStyleBackColor = true; @@ -142,18 +125,17 @@ // // FormLiner // - AutoScaleDimensions = new SizeF(11F, 25F); + AutoScaleDimensions = new SizeF(17F, 41F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(948, 614); + ClientSize = new Size(1465, 1007); Controls.Add(buttonStrategyStep); Controls.Add(comboBoxStrategy); - Controls.Add(buttonCreateCommonLiner); Controls.Add(buttonRight); Controls.Add(buttonLeft); Controls.Add(buttonUp); Controls.Add(buttonDown); - Controls.Add(buttonCreate); Controls.Add(pictureBoxLiner); + Margin = new Padding(5, 5, 5, 5); Name = "FormLiner"; Text = "Лайнер"; ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).EndInit(); @@ -163,12 +145,10 @@ #endregion private PictureBox pictureBoxLiner; - private Button buttonCreate; private Button buttonDown; private Button buttonUp; private Button buttonLeft; private Button buttonRight; - private Button buttonCreateCommonLiner; private ComboBox comboBoxStrategy; private Button buttonStrategyStep; } diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs index aa13498..683457a 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.cs @@ -23,6 +23,23 @@ namespace ProjectLiner _strategy = null; } + + /// + /// Стратегия перемещения + /// + + public DrawningLiner SetLiner + { + set + { + _drawningCommonLiner = value; + _drawningCommonLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); + comboBoxStrategy.Enabled = true; + _strategy = null; + Draw(); + } + } + /// /// Метод прорисовки лайнера /// @@ -39,57 +56,6 @@ namespace ProjectLiner pictureBoxLiner.Image = bmp; } - /// - /// Создание объекта класса-перемещения - /// - /// Тип создаваемого объекта - private void CreateObject(string type) - { - Random random = new(); - switch (type) - { - case nameof(DrawningCommonLiner): - _drawningCommonLiner = new DrawningCommonLiner(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(DrawningLiner): - _drawningCommonLiner = new DrawningLiner(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)), Convert.ToBoolean(random.Next(0, 2))); - break; - default: - return; - - } - - _drawningCommonLiner.SetPictureSize(pictureBoxLiner.Width, pictureBoxLiner.Height); - _drawningCommonLiner.SetPosition(random.Next(10, 100), random.Next(10, 100)); - _strategy = null; - comboBoxStrategy.Enabled = true; - Draw(); - } - - /// - /// Обработка нажатия кнопки "Создать Лайнер" - /// - /// - /// - private void buttonCreate_Click(object sender, EventArgs e) - { - CreateObject(nameof(DrawningLiner)); - } - - /// - /// Обработка нажатия кнопки "Создать Обычный Лайнер" - /// - /// - /// - - private void buttonCreateCommonLiner_Click(object sender, EventArgs e) - { - CreateObject(nameof(DrawningCommonLiner)); - } /// /// Перемещение объекта по форме (нажатие кнопок навигации) diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs new file mode 100644 index 0000000..1aeb63b --- /dev/null +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs @@ -0,0 +1,173 @@ +namespace ProjectLiner +{ + partial class FormLinerCollection + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + groupBoxTools = new GroupBox(); + buttonRefresh = new Button(); + buttonGoToCheck = new Button(); + buttonRemoveLiner = new Button(); + maskedTextBoxPosition = new MaskedTextBox(); + buttonAddCommonLiner = new Button(); + buttonAddLiner = new Button(); + comboBoxSelectorCompany = new ComboBox(); + pictureBox = new PictureBox(); + groupBoxTools.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); + SuspendLayout(); + // + // groupBoxTools + // + groupBoxTools.Controls.Add(buttonRefresh); + groupBoxTools.Controls.Add(buttonGoToCheck); + groupBoxTools.Controls.Add(buttonRemoveLiner); + groupBoxTools.Controls.Add(maskedTextBoxPosition); + groupBoxTools.Controls.Add(buttonAddCommonLiner); + groupBoxTools.Controls.Add(buttonAddLiner); + groupBoxTools.Controls.Add(comboBoxSelectorCompany); + groupBoxTools.Dock = DockStyle.Right; + groupBoxTools.Location = new Point(1053, 0); + groupBoxTools.Name = "groupBoxTools"; + groupBoxTools.Size = new Size(272, 845); + groupBoxTools.TabIndex = 0; + groupBoxTools.TabStop = false; + groupBoxTools.Text = "Инструменты"; + // + // buttonRefresh + // + buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRefresh.Location = new Point(33, 683); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(217, 76); + buttonRefresh.TabIndex = 6; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; + // + // buttonGoToCheck + // + buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonGoToCheck.Location = new Point(33, 562); + buttonGoToCheck.Name = "buttonGoToCheck"; + buttonGoToCheck.Size = new Size(217, 76); + buttonGoToCheck.TabIndex = 5; + buttonGoToCheck.Text = "Передать на тесты"; + buttonGoToCheck.UseVisualStyleBackColor = true; + buttonGoToCheck.Click += ButtonGoToCheck_Click; + // + // buttonRemoveLiner + // + buttonRemoveLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRemoveLiner.Location = new Point(33, 416); + buttonRemoveLiner.Name = "buttonRemoveLiner"; + buttonRemoveLiner.Size = new Size(217, 76); + buttonRemoveLiner.TabIndex = 4; + buttonRemoveLiner.Text = "Удаление Лайнера"; + buttonRemoveLiner.UseVisualStyleBackColor = true; + buttonRemoveLiner.Click += ButtonRemoveLiner_Click; + // + // maskedTextBoxPosition + // + maskedTextBoxPosition.Location = new Point(33, 363); + maskedTextBoxPosition.Mask = "00"; + maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + maskedTextBoxPosition.Size = new Size(217, 47); + maskedTextBoxPosition.TabIndex = 3; + maskedTextBoxPosition.ValidatingType = typeof(int); + // + // buttonAddCommonLiner + // + buttonAddCommonLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddCommonLiner.Location = new Point(33, 236); + buttonAddCommonLiner.Name = "buttonAddCommonLiner"; + buttonAddCommonLiner.Size = new Size(217, 76); + buttonAddCommonLiner.TabIndex = 2; + buttonAddCommonLiner.Text = "Добавление Обычного Лайнера"; + buttonAddCommonLiner.UseVisualStyleBackColor = true; + buttonAddCommonLiner.Click += ButtonAddCommonLiner_Click; + // + // buttonAddLiner + // + buttonAddLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddLiner.Location = new Point(33, 126); + buttonAddLiner.Name = "buttonAddLiner"; + buttonAddLiner.Size = new Size(217, 76); + buttonAddLiner.TabIndex = 1; + buttonAddLiner.Text = "Добавление Лайнера"; + buttonAddLiner.UseVisualStyleBackColor = true; + buttonAddLiner.Click += ButtonAddLiner_Click; + // + // comboBoxSelectorCompany + // + comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxSelectorCompany.FormattingEnabled = true; + comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); + comboBoxSelectorCompany.Location = new Point(18, 46); + comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; + comboBoxSelectorCompany.Size = new Size(242, 49); + comboBoxSelectorCompany.TabIndex = 0; + comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; + // + // pictureBox + // + pictureBox.Dock = DockStyle.Fill; + pictureBox.Location = new Point(0, 0); + pictureBox.Name = "pictureBox"; + pictureBox.Size = new Size(1053, 845); + pictureBox.TabIndex = 1; + pictureBox.TabStop = false; + // + // FormLinerCollection + // + AutoScaleDimensions = new SizeF(17F, 41F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1325, 845); + Controls.Add(pictureBox); + Controls.Add(groupBoxTools); + Name = "FormLinerCollection"; + Text = "Коллекция автомобилей"; + groupBoxTools.ResumeLayout(false); + groupBoxTools.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxTools; + private Button buttonAddLiner; + private ComboBox comboBoxSelectorCompany; + private Button buttonAddCommonLiner; + private PictureBox pictureBox; + private Button buttonGoToCheck; + private Button buttonRemoveLiner; + private MaskedTextBox maskedTextBoxPosition; + private Button buttonRefresh; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.cs new file mode 100644 index 0000000..38bb839 --- /dev/null +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.cs @@ -0,0 +1,188 @@ +using ProjectLiner.CollectionGenericObjects; +using ProjectLiner.Drawnings; +using System.Windows.Forms; + +namespace ProjectLiner +{ + /// + /// Форма работы с компанией и ее коллекцией + /// + public partial class FormLinerCollection : Form + { + /// + /// Компания + /// + private AbstractCompany? _company = null; + + /// + /// Конструктор + /// + public FormLinerCollection() + { + InitializeComponent(); + } + + /// + /// Выбор компании + /// + /// + /// + private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboBoxSelectorCompany.Text) + { + case "Хранилище": + _company = new LinerSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); + break; + } + } + + /// + /// Создание объекта класса-перемещения + /// + /// Тип создаваемого объекта + private void CreateObject(string type) + { + if (_company == null) + { + return; + } + + Random random = new(); + DrawningCommonLiner drawingLiner; + switch (type) + { + case nameof(DrawningCommonLiner): + drawingLiner = new DrawningCommonLiner(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); + break; + case nameof(DrawningLiner): + drawingLiner = new DrawningLiner(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random), + Convert.ToBoolean(random.Next(1, 2)), Convert.ToBoolean(random.Next(1, 2)), Convert.ToBoolean(random.Next(1, 2))); + break; + default: + return; + } + + if (_company + drawingLiner) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _company.Show(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + + /// + /// Получение цвета + /// + /// Генератор случайных чисел + /// + private static Color GetColor(Random random) + { + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + + return color; + } + + /// + /// Добавление обычного лайнер + /// + /// + /// + private void ButtonAddCommonLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCommonLiner)); + + /// + /// Добавление лайнера + /// + /// + /// + private void ButtonAddLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLiner)); + + /// + /// Удаление объекта + /// + /// + /// + private void ButtonRemoveLiner_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null) + { + return; + } + + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + { + return; + } + + int pos = Convert.ToInt32(maskedTextBoxPosition.Text); + if (_company - pos) + { + MessageBox.Show("Объект удален"); + pictureBox.Image = _company.Show(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + + /// + /// Передача объекта в другую форму + /// + /// + /// + private void ButtonGoToCheck_Click(object sender, EventArgs e) + { + if (_company == null) + { + return; + } + + DrawningCommonLiner? liner = null; + int counter = 100; + while (liner == null) + { + liner = _company.GetRandomObject(); + counter--; + if (counter <= 0) + { + break; + } + } + + if (liner == null) + { + return; + } + + FormLiner form = new() + { + SetLiner = (DrawningLiner)liner + }; + form.ShowDialog(); + } + + /// + /// Перерисовка коллекции + /// + /// + /// + private void ButtonRefresh_Click(object sender, EventArgs e) + { + if (_company == null) + { + return; + } + + pictureBox.Image = _company.Show(); + } + } +} diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.resx b/ProjectLiner/ProjectLiner/FormLinerCollection.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/Program.cs b/ProjectLiner/ProjectLiner/Program.cs index b3dc92e..e3f64ca 100644 --- a/ProjectLiner/ProjectLiner/Program.cs +++ b/ProjectLiner/ProjectLiner/Program.cs @@ -11,7 +11,7 @@ namespace ProjectLiner // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormLiner()); + Application.Run(new FormLinerCollection()); } } } \ No newline at end of file From dac8a3ec17177b0c4414f7b6c2a347da9f021789 Mon Sep 17 00:00:00 2001 From: gettterot Date: Wed, 20 Mar 2024 08:23:41 +0400 Subject: [PATCH 09/11] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= =?UTF-8?q?=20=D1=81=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=BE=D0=B9=20sharing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 3 +- .../LinerSharingService.cs | 64 ++++++++----------- .../MassiveGenericObjects.cs | 3 +- .../Drawnings/DrawningCommonLiner.cs | 6 +- .../ProjectLiner/FormLiner.Designer.cs | 16 ++--- ProjectLiner/ProjectLiner/FormLiner.cs | 2 +- .../ProjectLiner/FormLinerCollection.cs | 4 +- 7 files changed, 41 insertions(+), 57 deletions(-) diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs index 1eb7aa1..0e550fc 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs @@ -1,5 +1,4 @@ -using ProjectLiner.CollectionGenericObjects; -using ProjectLiner.Drawnings; +using ProjectLiner.Drawnings; namespace ProjectLiner.CollectionGenericObjects { diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs index 0501fa8..ad2d528 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs @@ -1,6 +1,4 @@ - -using ProjectLiner.Drawnings; -using ProjectLiner.CollectionGenericObjects; +using ProjectLiner.Drawnings; namespace ProjectLiner.CollectionGenericObjects; @@ -15,60 +13,52 @@ public class LinerSharingService : AbstractCompany /// Ширина /// Высота /// Коллекция - public LinerSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) + public LinerSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) { } protected override void DrawBackgound(Graphics g) { - - int count_width = _pictureWidth / _placeSizeWidth; // кол-во мест в ширину - int count_height = _pictureHeight / _placeSizeHeight; - Pen pen = new(Color.Black, 3); - for (int i = 0; i < count_width; i++) + Pen pen = new(Color.Black, 4); + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) { - for (int j = 0; j < count_height + 1; ++j) + for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) { - g.DrawLine(pen, i * _placeSizeWidth + 10, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 50, j * _placeSizeHeight); // вертикаль - g.DrawLine(pen, i * _placeSizeWidth + 10, j * _placeSizeHeight, i * _placeSizeWidth + 10, j * _placeSizeHeight + _placeSizeHeight); + g.DrawLine(pen, i * _placeSizeWidth, (int)(j * _placeSizeHeight * 1.3), + i * _placeSizeWidth + _placeSizeWidth - 40, (int)(j * _placeSizeHeight * 1.3)); } + g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); } } + protected override void SetObjectsPosition() { - int width = _pictureWidth / _placeSizeWidth; int height = _pictureHeight / _placeSizeHeight; - int positionWidth = 0; - int positionHeight = height - 1; - if (_collection?.Count != null) + int curWidth = width - 1; + int curHeight = 0; + + for (int i = 0; i < (_collection?.Count ?? 0); i++) { - for (int i = 0; i < (_collection.Count); i++) + if (_collection?.Get(i) != null) { - if (_collection.Get(i) != null) - { - _collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight); - _collection.Get(i).SetPosition(_placeSizeWidth * positionWidth + 25, positionHeight * _placeSizeHeight + 10); - } + _collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); + _collection.Get(i)?.SetPosition(_placeSizeWidth * curWidth + 10, (int)(curHeight * _placeSizeHeight * 1.3)); + } - if (positionWidth < width - 1) - { - positionWidth++; - } - - else - { - positionWidth = 0; - positionHeight--; - } - if (positionHeight < 0) - { - return; - } + if (curWidth > 0) + curWidth--; + else + { + curWidth = width - 1; + curHeight++; + } + if (curHeight > height) + { + return; } } - } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs index 9865dd0..9ed2684 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs @@ -1,5 +1,4 @@ -using ProjectLiner.CollectionGenericObjects; - + namespace ProjectLiner.CollectionGenericObjects { /// diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs index b47fb35..ef854f9 100644 --- a/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs @@ -1,9 +1,5 @@ using ProjectLiner.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + namespace ProjectLiner.Drawnings; /// diff --git a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs index 7dc1072..8b9984b 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs @@ -43,7 +43,7 @@ pictureBoxLiner.BackColor = SystemColors.Control; pictureBoxLiner.Dock = DockStyle.Fill; pictureBoxLiner.Location = new Point(0, 0); - pictureBoxLiner.Margin = new Padding(5, 5, 5, 5); + pictureBoxLiner.Margin = new Padding(5); pictureBoxLiner.Name = "pictureBoxLiner"; pictureBoxLiner.Size = new Size(1465, 1007); pictureBoxLiner.TabIndex = 0; @@ -55,7 +55,7 @@ buttonDown.BackgroundImage = Properties.Resources.bottom; buttonDown.BackgroundImageLayout = ImageLayout.Stretch; buttonDown.Location = new Point(1283, 905); - buttonDown.Margin = new Padding(5, 5, 5, 5); + buttonDown.Margin = new Padding(5); buttonDown.Name = "buttonDown"; buttonDown.Size = new Size(77, 82); buttonDown.TabIndex = 2; @@ -68,7 +68,7 @@ buttonUp.BackgroundImage = Properties.Resources.top; buttonUp.BackgroundImageLayout = ImageLayout.Stretch; buttonUp.Location = new Point(1283, 813); - buttonUp.Margin = new Padding(5, 5, 5, 5); + buttonUp.Margin = new Padding(5); buttonUp.Name = "buttonUp"; buttonUp.Size = new Size(77, 82); buttonUp.TabIndex = 3; @@ -81,7 +81,7 @@ buttonLeft.BackgroundImage = Properties.Resources.left; buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; buttonLeft.Location = new Point(1196, 905); - buttonLeft.Margin = new Padding(5, 5, 5, 5); + buttonLeft.Margin = new Padding(5); buttonLeft.Name = "buttonLeft"; buttonLeft.Size = new Size(77, 82); buttonLeft.TabIndex = 4; @@ -94,7 +94,7 @@ buttonRight.BackgroundImage = Properties.Resources.right; buttonRight.BackgroundImageLayout = ImageLayout.Stretch; buttonRight.Location = new Point(1369, 905); - buttonRight.Margin = new Padding(5, 5, 5, 5); + buttonRight.Margin = new Padding(5); buttonRight.Name = "buttonRight"; buttonRight.Size = new Size(77, 82); buttonRight.TabIndex = 5; @@ -107,7 +107,7 @@ comboBoxStrategy.FormattingEnabled = true; comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" }); comboBoxStrategy.Location = new Point(1147, 20); - comboBoxStrategy.Margin = new Padding(5, 5, 5, 5); + comboBoxStrategy.Margin = new Padding(5); comboBoxStrategy.Name = "comboBoxStrategy"; comboBoxStrategy.Size = new Size(298, 49); comboBoxStrategy.TabIndex = 11; @@ -115,7 +115,7 @@ // buttonStrategyStep // buttonStrategyStep.Location = new Point(1261, 84); - buttonStrategyStep.Margin = new Padding(5, 5, 5, 5); + buttonStrategyStep.Margin = new Padding(5); buttonStrategyStep.Name = "buttonStrategyStep"; buttonStrategyStep.Size = new Size(185, 61); buttonStrategyStep.TabIndex = 12; @@ -135,7 +135,7 @@ Controls.Add(buttonUp); Controls.Add(buttonDown); Controls.Add(pictureBoxLiner); - Margin = new Padding(5, 5, 5, 5); + Margin = new Padding(5); Name = "FormLiner"; Text = "Лайнер"; ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).EndInit(); diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs index 683457a..fbbb11d 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.cs @@ -28,7 +28,7 @@ namespace ProjectLiner /// Стратегия перемещения /// - public DrawningLiner SetLiner + public DrawningCommonLiner SetLiner { set { diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.cs index 38bb839..56b4370 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.cs @@ -32,7 +32,7 @@ namespace ProjectLiner switch (comboBoxSelectorCompany.Text) { case "Хранилище": - _company = new LinerSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); + _company = new LinerSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); break; } } @@ -165,7 +165,7 @@ namespace ProjectLiner FormLiner form = new() { - SetLiner = (DrawningLiner)liner + SetLiner = liner }; form.ShowDialog(); } From 9aec819091d6c5544d4a97e63a53877b8fc5bd63 Mon Sep 17 00:00:00 2001 From: gettterot Date: Sun, 24 Mar 2024 16:26:53 +0400 Subject: [PATCH 10/11] =?UTF-8?q?=D0=A4=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D0=BE=D0=B5=20=D0=B7=D0=B0=D0=BA=D1=80=D0=B5=D0=BF=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=B5=D1=82=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 9 +-- .../ICollectionGenericObjects.cs | 6 +- .../MassiveGenericObjects.cs | 69 +++++++++++-------- .../ProjectLiner/FormLinerCollection.cs | 4 +- 4 files changed, 50 insertions(+), 38 deletions(-) diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs index 0e550fc..5076923 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs @@ -57,9 +57,10 @@ namespace ProjectLiner.CollectionGenericObjects /// Компания /// Добавляемый объект /// - public static bool operator +(AbstractCompany company, DrawningCommonLiner Liner) + + public static int operator +(AbstractCompany company, DrawningCommonLiner airplan) { - return company._collection?.Insert(Liner) ?? false; + return company._collection.Insert(airplan); } /// @@ -68,9 +69,9 @@ namespace ProjectLiner.CollectionGenericObjects /// Компания /// Номер удаляемого объекта /// - public static bool operator -(AbstractCompany company, int position) + public static DrawningCommonLiner operator -(AbstractCompany company, int position) { - return company._collection?.Remove(position) ?? false; + return company._collection.Remove(position); } /// diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs index 9e2ed2f..776e2ad 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -22,7 +22,7 @@ /// /// Добавляемый объект /// true - вставка прошла удачно, false - вставка не удалась - bool Insert(T obj); + int Insert(T obj); /// /// Добавление объекта в коллекцию на конкретную позицию @@ -30,14 +30,14 @@ /// Добавляемый объект /// Позиция /// true - вставка прошла удачно, false - вставка не удалась - bool Insert(T obj, int position); + int Insert(T obj, int position); /// /// Удаление объекта из коллекции с конкретной позиции /// /// Позиция /// true - удаление прошло удачно, false - удаление не удалось - bool Remove(int position); + T? Remove(int position); /// /// Получение объекта по позиции diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs index 9ed2684..f668f85 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs @@ -12,7 +12,7 @@ namespace ProjectLiner.CollectionGenericObjects /// Массив объектов, которые храним /// private T?[] _collection; - + public int Count => _collection.Length; public int SetMaxCount @@ -48,63 +48,74 @@ namespace ProjectLiner.CollectionGenericObjects return _collection[position]; } - public bool Insert(T obj) + public int Insert(T obj) { for (int i = 0; i < Count; i++) { if (_collection[i] == null) { _collection[i] = obj; - return true; + return i; } } - return false; + return -1; } - public bool Insert(T obj, int position) + public int Insert(T obj, int position) { if (position < 0 || position >= Count) - return false; - - if (_collection[position] == null) { - _collection[position] = obj; - return true; + return -1; } - int temp = position + 1; - while (temp < Count) + if (_collection[position] != null) { - if (_collection[temp] == null) + bool pushed = false; + for (int index = position + 1; index < Count; index++) { - _collection[temp] = obj; - return true; + if (_collection[index] == null) + { + position = index; + pushed = true; + break; + } } - temp++; - } - temp = position - 1; - while (temp > 0) - { - if (_collection[temp] == null) + if (!pushed) { - _collection[temp] = obj; - return true; + for (int index = position - 1; index >= 0; index--) + { + if (_collection[index] == null) + { + position = index; + pushed = true; + break; + } + } + } + + if (!pushed) + { + return position; } - temp--; } - return false; + _collection[position] = obj; + return position; } - public bool Remove(int position) + public T? Remove(int position) { if (position < 0 || position >= Count) - return false; + { + return null; + } + if (_collection[position] == null) return null; + + T? temp = _collection[position]; _collection[position] = null; - - return true; + return temp; } } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.cs index 56b4370..3e759f4 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.cs @@ -63,7 +63,7 @@ namespace ProjectLiner return; } - if (_company + drawingLiner) + if (_company + drawingLiner != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); @@ -123,7 +123,7 @@ namespace ProjectLiner } int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if (_company - pos) + if (_company - pos != null) { MessageBox.Show("Объект удален"); pictureBox.Image = _company.Show(); From 10ce368f63784e829f1c73b07a5a920f6ba2b020 Mon Sep 17 00:00:00 2001 From: gettterot Date: Wed, 3 Apr 2024 08:28:54 +0400 Subject: [PATCH 11/11] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=20=D1=85=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B2=20"=D0=A1=D0=B5=D1=80=D0=B2=D0=B8=D1=81?= =?UTF-8?q?=D0=B5"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 2 +- .../CollectionType.cs | 24 + .../ListGenericObjects.cs | 52 +++ .../MassiveGenericObjects.cs | 56 +-- .../StorageCollection.cs | 68 +++ .../FormLinerCollection.Designer.cs | 305 ++++++++++--- .../ProjectLiner/FormLinerCollection.cs | 416 ++++++++++-------- 7 files changed, 641 insertions(+), 282 deletions(-) create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionType.cs create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs create mode 100644 ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs index 5076923..b5cc584 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs @@ -71,7 +71,7 @@ namespace ProjectLiner.CollectionGenericObjects /// public static DrawningCommonLiner operator -(AbstractCompany company, int position) { - return company._collection.Remove(position); + return company._collection.Remove(position) ; } /// diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionType.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionType.cs new file mode 100644 index 0000000..d5b8c2c --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/CollectionType.cs @@ -0,0 +1,24 @@ + +namespace ProjectLiner.CollectionGenericObjects; + + +/// +/// Тип коллекции +/// +public enum CollectionType +{ + /// + /// Неопределено + /// + None = 0, + + /// + /// Массив + /// + Massive = 1, + + /// + /// Список + /// + List = 2, +} diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs new file mode 100644 index 0000000..dc81bc1 --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/ListGenericObjects.cs @@ -0,0 +1,52 @@ +using ProjectLiner.CollectionGenericObjects; + +/// +/// Параметризованный набор объектов +/// +/// Параметр: ограничение - ссылочный тип +public class ListGenericObjects : ICollectionGenericObjects + where T : class +{ + /// + /// Список объектов, которые храним + /// + private readonly List _collection; + /// + /// Максимально допустимое число объектов в списке + /// + private int _maxCount; + public int Count => _collection.Count; + public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } } + /// + /// Конструктор + /// + public ListGenericObjects() + { + _collection = new(); + } + public T? Get(int position) + { + if (position >= Count || position < 0) return null; + return _collection[position]; + } + public int Insert(T obj) + { + if (Count + 1 > _maxCount) return -1; + _collection.Add(obj); + return Count; + } + public int Insert(T obj, int position) + { + if (Count + 1 > _maxCount) return -1; + if (position < 0 || position > Count) return -1; + _collection.Insert(position, obj); + return 1; + } + public T? Remove(int position) + { + if (position < 0 || position > Count) return null; + T? temp = _collection[position]; + _collection.RemoveAt(position); + return temp; + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs index f668f85..661b751 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs @@ -63,45 +63,33 @@ namespace ProjectLiner.CollectionGenericObjects public int Insert(T obj, int position) { - if (position < 0 || position >= Count) + if (position >= Count || position < 0) return -1; + if (_collection[position] == null) { - return -1; + _collection[position] = obj; + return position; } - - if (_collection[position] != null) + int temp = position + 1; + while (temp < Count) { - bool pushed = false; - for (int index = position + 1; index < Count; index++) + if (_collection[temp] == null) { - if (_collection[index] == null) - { - position = index; - pushed = true; - break; - } - } - - if (!pushed) - { - for (int index = position - 1; index >= 0; index--) - { - if (_collection[index] == null) - { - position = index; - pushed = true; - break; - } - } - } - - if (!pushed) - { - return position; + _collection[temp] = obj; + return temp; } + ++temp; } - - _collection[position] = obj; - return position; + temp = position - 1; + while (temp >= 0) + { + if (_collection[temp] == null) + { + _collection[temp] = obj; + return temp; + } + --temp; + } + return -1; } public T? Remove(int position) @@ -111,7 +99,7 @@ namespace ProjectLiner.CollectionGenericObjects return null; } - if (_collection[position] == null) return null; + //if (_collection[position] == null) return null; T? temp = _collection[position]; _collection[position] = null; diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs new file mode 100644 index 0000000..6e2ed1a --- /dev/null +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/StorageCollection.cs @@ -0,0 +1,68 @@ +using ProjectLiner.CollectionGenericObjects; + +/// +/// Класс-хранилище коллекций +/// +/// +public class StorageCollection + where T : class +{ + /// + /// Словарь (хранилище) с коллекциями + /// + readonly Dictionary> _storages; + /// + /// Возвращение списка названий коллекций + /// + public List Keys => _storages.Keys.ToList(); + /// + /// Конструктор + /// + public StorageCollection() + { + _storages = new Dictionary>(); + } + /// + /// Добавление коллекции в хранилище + /// + /// Название коллекции + /// тип коллекции + public void AddCollection(string name, CollectionType collectionType) + { + if (name == null || _storages.ContainsKey(name)) { return; } + switch (collectionType) + + { + case CollectionType.None: + return; + case CollectionType.Massive: + _storages[name] = new MassiveGenericObjects(); + return; + case CollectionType.List: + _storages[name] = new ListGenericObjects(); + return; + } + } + /// + /// Удаление коллекции + /// + /// Название коллекции + public void DelCollection(string name) + { + if (_storages.ContainsKey(name)) + _storages.Remove(name); + } + /// + /// Доступ к коллекции + /// + /// Название коллекции + /// + public ICollectionGenericObjects? this[string name] + { + get + { + if (name == null || !_storages.ContainsKey(name)) { return null; } + return _storages[name]; + } + } +} \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs index 1aeb63b..50e79a9 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.Designer.cs @@ -29,98 +29,149 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); - buttonRefresh = new Button(); - buttonGoToCheck = new Button(); - buttonRemoveLiner = new Button(); - maskedTextBoxPosition = new MaskedTextBox(); - buttonAddCommonLiner = new Button(); - buttonAddLiner = new Button(); + buttonCreateCompany = new Button(); + panelStorage = new Panel(); + buttonCollectionDel = new Button(); + listBoxCollection = new ListBox(); + buttonCollectionAdd = new Button(); + radioButtonList = new RadioButton(); + radioButtonMassive = new RadioButton(); + textBoxCollectionName = new TextBox(); + labelCollectionName = new Label(); comboBoxSelectorCompany = new ComboBox(); pictureBox = new PictureBox(); + panelCompanyTools = new Panel(); + button1 = new Button(); + button2 = new Button(); + maskedTextBox1 = new MaskedTextBox(); + button3 = new Button(); + button4 = new Button(); + button5 = new Button(); groupBoxTools.SuspendLayout(); + panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); + panelCompanyTools.SuspendLayout(); SuspendLayout(); // // groupBoxTools // - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonGoToCheck); - groupBoxTools.Controls.Add(buttonRemoveLiner); - groupBoxTools.Controls.Add(maskedTextBoxPosition); - groupBoxTools.Controls.Add(buttonAddCommonLiner); - groupBoxTools.Controls.Add(buttonAddLiner); + groupBoxTools.Controls.Add(buttonCreateCompany); + groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(1053, 0); + groupBoxTools.Location = new Point(681, 0); + groupBoxTools.Margin = new Padding(2); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(272, 845); + groupBoxTools.Padding = new Padding(2); + groupBoxTools.Size = new Size(176, 648); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // - // buttonRefresh + // buttonCreateCompany // - buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(33, 683); - buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(217, 76); - buttonRefresh.TabIndex = 6; - buttonRefresh.Text = "Обновить"; - buttonRefresh.UseVisualStyleBackColor = true; - buttonRefresh.Click += ButtonRefresh_Click; + buttonCreateCompany.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + buttonCreateCompany.Location = new Point(5, 317); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(166, 23); + buttonCreateCompany.TabIndex = 8; + buttonCreateCompany.Text = "Создать компанию"; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += ButtonCreateCompany_Click; // - // buttonGoToCheck + // panelStorage // - buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(33, 562); - buttonGoToCheck.Name = "buttonGoToCheck"; - buttonGoToCheck.Size = new Size(217, 76); - buttonGoToCheck.TabIndex = 5; - buttonGoToCheck.Text = "Передать на тесты"; - buttonGoToCheck.UseVisualStyleBackColor = true; - buttonGoToCheck.Click += ButtonGoToCheck_Click; + panelStorage.Controls.Add(buttonCollectionDel); + panelStorage.Controls.Add(listBoxCollection); + panelStorage.Controls.Add(buttonCollectionAdd); + panelStorage.Controls.Add(radioButtonList); + panelStorage.Controls.Add(radioButtonMassive); + panelStorage.Controls.Add(textBoxCollectionName); + panelStorage.Controls.Add(labelCollectionName); + panelStorage.Dock = DockStyle.Top; + panelStorage.Location = new Point(2, 28); + panelStorage.Margin = new Padding(2); + panelStorage.Name = "panelStorage"; + panelStorage.Size = new Size(172, 247); + panelStorage.TabIndex = 7; // - // buttonRemoveLiner + // buttonCollectionDel // - buttonRemoveLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRemoveLiner.Location = new Point(33, 416); - buttonRemoveLiner.Name = "buttonRemoveLiner"; - buttonRemoveLiner.Size = new Size(217, 76); - buttonRemoveLiner.TabIndex = 4; - buttonRemoveLiner.Text = "Удаление Лайнера"; - buttonRemoveLiner.UseVisualStyleBackColor = true; - buttonRemoveLiner.Click += ButtonRemoveLiner_Click; + buttonCollectionDel.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + buttonCollectionDel.Location = new Point(3, 212); + buttonCollectionDel.Name = "buttonCollectionDel"; + buttonCollectionDel.Size = new Size(166, 23); + buttonCollectionDel.TabIndex = 6; + buttonCollectionDel.Text = "Удалить Коллекцию"; + buttonCollectionDel.UseVisualStyleBackColor = true; + buttonCollectionDel.Click += ButtonCollectionDel_Click; // - // maskedTextBoxPosition + // listBoxCollection // - maskedTextBoxPosition.Location = new Point(33, 363); - maskedTextBoxPosition.Mask = "00"; - maskedTextBoxPosition.Name = "maskedTextBoxPosition"; - maskedTextBoxPosition.Size = new Size(217, 47); - maskedTextBoxPosition.TabIndex = 3; - maskedTextBoxPosition.ValidatingType = typeof(int); + listBoxCollection.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + listBoxCollection.FormattingEnabled = true; + listBoxCollection.ItemHeight = 17; + listBoxCollection.Location = new Point(3, 110); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(166, 89); + listBoxCollection.TabIndex = 5; // - // buttonAddCommonLiner + // buttonCollectionAdd // - buttonAddCommonLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddCommonLiner.Location = new Point(33, 236); - buttonAddCommonLiner.Name = "buttonAddCommonLiner"; - buttonAddCommonLiner.Size = new Size(217, 76); - buttonAddCommonLiner.TabIndex = 2; - buttonAddCommonLiner.Text = "Добавление Обычного Лайнера"; - buttonAddCommonLiner.UseVisualStyleBackColor = true; - buttonAddCommonLiner.Click += ButtonAddCommonLiner_Click; + buttonCollectionAdd.Font = new Font("Segoe UI", 7.948052F, FontStyle.Regular, GraphicsUnit.Point); + buttonCollectionAdd.Location = new Point(2, 82); + buttonCollectionAdd.Margin = new Padding(2); + buttonCollectionAdd.Name = "buttonCollectionAdd"; + buttonCollectionAdd.Size = new Size(170, 23); + buttonCollectionAdd.TabIndex = 4; + buttonCollectionAdd.Text = "Добавить коллекцию"; + buttonCollectionAdd.UseVisualStyleBackColor = true; + buttonCollectionAdd.Click += ButtonCollectionAdd_Click; // - // buttonAddLiner + // radioButtonList // - buttonAddLiner.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddLiner.Location = new Point(33, 126); - buttonAddLiner.Name = "buttonAddLiner"; - buttonAddLiner.Size = new Size(217, 76); - buttonAddLiner.TabIndex = 1; - buttonAddLiner.Text = "Добавление Лайнера"; - buttonAddLiner.UseVisualStyleBackColor = true; - buttonAddLiner.Click += ButtonAddLiner_Click; + radioButtonList.AutoSize = true; + radioButtonList.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point); + radioButtonList.Location = new Point(89, 58); + radioButtonList.Margin = new Padding(2); + radioButtonList.Name = "radioButtonList"; + radioButtonList.Size = new Size(73, 23); + radioButtonList.TabIndex = 3; + radioButtonList.TabStop = true; + radioButtonList.Text = "Список"; + radioButtonList.UseVisualStyleBackColor = true; + // + // radioButtonMassive + // + radioButtonMassive.AutoSize = true; + radioButtonMassive.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point); + radioButtonMassive.Location = new Point(2, 58); + radioButtonMassive.Margin = new Padding(2); + radioButtonMassive.Name = "radioButtonMassive"; + radioButtonMassive.Size = new Size(71, 23); + radioButtonMassive.TabIndex = 2; + radioButtonMassive.TabStop = true; + radioButtonMassive.Text = "массив"; + radioButtonMassive.UseVisualStyleBackColor = true; + // + // textBoxCollectionName + // + textBoxCollectionName.Location = new Point(0, 26); + textBoxCollectionName.Margin = new Padding(2); + textBoxCollectionName.Name = "textBoxCollectionName"; + textBoxCollectionName.Size = new Size(172, 33); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point); + labelCollectionName.Location = new Point(14, 5); + labelCollectionName.Margin = new Padding(2, 0, 2, 0); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(140, 19); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции"; // // comboBoxSelectorCompany // @@ -128,33 +179,125 @@ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(18, 46); + comboBoxSelectorCompany.Location = new Point(13, 279); + comboBoxSelectorCompany.Margin = new Padding(2); comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; - comboBoxSelectorCompany.Size = new Size(242, 49); + comboBoxSelectorCompany.Size = new Size(158, 33); comboBoxSelectorCompany.TabIndex = 0; comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged; // // pictureBox // - pictureBox.Dock = DockStyle.Fill; + pictureBox.Dock = DockStyle.Bottom; + pictureBox.Enabled = false; pictureBox.Location = new Point(0, 0); + pictureBox.Margin = new Padding(2); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(1053, 845); + pictureBox.Size = new Size(681, 648); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // + // panelCompanyTools + // + panelCompanyTools.BackColor = SystemColors.Window; + panelCompanyTools.Controls.Add(button1); + panelCompanyTools.Controls.Add(button2); + panelCompanyTools.Controls.Add(maskedTextBox1); + panelCompanyTools.Controls.Add(button5); + panelCompanyTools.Controls.Add(button3); + panelCompanyTools.Controls.Add(button4); + panelCompanyTools.Location = new Point(681, 346); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(176, 302); + panelCompanyTools.TabIndex = 9; + // + // button1 + // + button1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + button1.Location = new Point(4, 2); + button1.Margin = new Padding(2); + button1.Name = "button1"; + button1.Size = new Size(140, 46); + button1.TabIndex = 1; + button1.Text = "Добавление Лайнера"; + button1.UseVisualStyleBackColor = true; + button1.Click += ButtonAddLiner_Click; + // + // button2 + // + button2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + button2.Location = new Point(2, 52); + button2.Margin = new Padding(2); + button2.Name = "button2"; + button2.Size = new Size(140, 46); + button2.TabIndex = 2; + button2.Text = "Добавление Обычного Лайнера"; + button2.UseVisualStyleBackColor = true; + button2.Click += ButtonAddCommonLiner_Click; + // + // maskedTextBox1 + // + maskedTextBox1.Location = new Point(2, 102); + maskedTextBox1.Margin = new Padding(2); + maskedTextBox1.Mask = "00"; + maskedTextBox1.Name = "maskedTextBox1"; + maskedTextBox1.Size = new Size(142, 33); + maskedTextBox1.TabIndex = 3; + maskedTextBox1.ValidatingType = typeof(int); + // + // button3 + // + button3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + button3.Location = new Point(2, 134); + button3.Margin = new Padding(2); + button3.Name = "button3"; + button3.Size = new Size(140, 46); + button3.TabIndex = 4; + button3.Text = "Удаление Лайнера"; + button3.UseVisualStyleBackColor = true; + button3.Click += ButtonRemoveLiner_Click; + // + // button4 + // + button4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + button4.Location = new Point(2, 184); + button4.Margin = new Padding(2); + button4.Name = "button4"; + button4.Size = new Size(140, 46); + button4.TabIndex = 5; + button4.Text = "Передать на тесты"; + button4.UseVisualStyleBackColor = true; + button4.Click += ButtonGoToCheck_Click; + // + // button5 + // + button5.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + button5.Location = new Point(2, 234); + button5.Margin = new Padding(2); + button5.Name = "button5"; + button5.Size = new Size(140, 46); + button5.TabIndex = 6; + button5.Text = "Обновить"; + button5.UseVisualStyleBackColor = true; + button5.Click += ButtonRefresh_Click; + // // FormLinerCollection // - AutoScaleDimensions = new SizeF(17F, 41F); + AutoScaleDimensions = new SizeF(11F, 25F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1325, 845); + ClientSize = new Size(857, 648); + Controls.Add(panelCompanyTools); Controls.Add(pictureBox); Controls.Add(groupBoxTools); + Margin = new Padding(2); Name = "FormLinerCollection"; Text = "Коллекция автомобилей"; groupBoxTools.ResumeLayout(false); - groupBoxTools.PerformLayout(); + panelStorage.ResumeLayout(false); + panelStorage.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + panelCompanyTools.ResumeLayout(false); + panelCompanyTools.PerformLayout(); ResumeLayout(false); } @@ -169,5 +312,21 @@ private Button buttonRemoveLiner; private MaskedTextBox maskedTextBoxPosition; private Button buttonRefresh; + private Panel panelStorage; + private Label labelCollectionName; + private RadioButton radioButtonMassive; + private TextBox textBoxCollectionName; + private Button buttonCollectionAdd; + private RadioButton radioButtonList; + private Button buttonCollectionDel; + private ListBox listBoxCollection; + private Button buttonCreateCompany; + private Panel panelCompanyTools; + private Button button1; + private Button button2; + private MaskedTextBox maskedTextBox1; + private Button button5; + private Button button3; + private Button button4; } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.cs index 3e759f4..67b99b3 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.cs @@ -1,188 +1,256 @@ -using ProjectLiner.CollectionGenericObjects; + +using ProjectLiner.CollectionGenericObjects; using ProjectLiner.Drawnings; -using System.Windows.Forms; -namespace ProjectLiner +namespace ProjectLiner; +/// +/// Форма работы с компанией и ее коллекцией +/// +public partial class FormLinerCollection : Form { /// - /// Форма работы с компанией и ее коллекцией + /// Хранилише коллекций /// - public partial class FormLinerCollection : Form + private readonly StorageCollection _storageCollection; + /// + /// Компания + /// + private AbstractCompany? _company = null; + /// + /// Конструктор + /// + public FormLinerCollection() { - /// - /// Компания - /// - private AbstractCompany? _company = null; - - /// - /// Конструктор - /// - public FormLinerCollection() + InitializeComponent(); + _storageCollection = new(); + } + /// + /// Выбор компании + /// + /// + /// + private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) + { + panelCompanyTools.Enabled = false; + } + /// + /// Добавление грузовика + /// + /// + /// + private void ButtonAddCommonLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCommonLiner)); + /// + /// Добавление подметательно-уборочной машины + /// + /// + /// + private void ButtonAddLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLiner)); + /// + /// Создание объекта класса-перемещенияв + /// + /// + private void CreateObject(string type) + { + if (_company == null) { - InitializeComponent(); + return; } - - /// - /// Выбор компании - /// - /// - /// - private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) + Random random = new(); + DrawningCommonLiner drawningCommonLiner; + switch (type) { - switch (comboBoxSelectorCompany.Text) - { - case "Хранилище": - _company = new LinerSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); - break; - } + case nameof(DrawningCommonLiner): + drawningCommonLiner = new DrawningCommonLiner(random.Next(100, 300), + random.Next(1000, 3000), GetColor(random)); + break; + case nameof(DrawningLiner): + drawningCommonLiner = new DrawningLiner(random.Next(100, 300), random.Next(1000, 3000), + GetColor(random), GetColor(random), + Convert.ToBoolean(random.Next(0, 2)), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + break; + default: + return; } - - /// - /// Создание объекта класса-перемещения - /// - /// Тип создаваемого объекта - private void CreateObject(string type) + if (_company + drawningCommonLiner != -1) { - if (_company == null) - { - return; - } - - Random random = new(); - DrawningCommonLiner drawingLiner; - switch (type) - { - case nameof(DrawningCommonLiner): - drawingLiner = new DrawningCommonLiner(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); - break; - case nameof(DrawningLiner): - drawingLiner = new DrawningLiner(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random), - Convert.ToBoolean(random.Next(1, 2)), Convert.ToBoolean(random.Next(1, 2)), Convert.ToBoolean(random.Next(1, 2))); - break; - default: - return; - } - - if (_company + drawingLiner != -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _company.Show(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } - - /// - /// Получение цвета - /// - /// Генератор случайных чисел - /// - private static Color GetColor(Random random) - { - Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); - ColorDialog dialog = new(); - if (dialog.ShowDialog() == DialogResult.OK) - { - color = dialog.Color; - } - - return color; - } - - /// - /// Добавление обычного лайнер - /// - /// - /// - private void ButtonAddCommonLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCommonLiner)); - - /// - /// Добавление лайнера - /// - /// - /// - private void ButtonAddLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLiner)); - - /// - /// Удаление объекта - /// - /// - /// - private void ButtonRemoveLiner_Click(object sender, EventArgs e) - { - if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null) - { - return; - } - - if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) - { - return; - } - - int pos = Convert.ToInt32(maskedTextBoxPosition.Text); - if (_company - pos != null) - { - MessageBox.Show("Объект удален"); - pictureBox.Image = _company.Show(); - } - else - { - MessageBox.Show("Не удалось удалить объект"); - } - } - - /// - /// Передача объекта в другую форму - /// - /// - /// - private void ButtonGoToCheck_Click(object sender, EventArgs e) - { - if (_company == null) - { - return; - } - - DrawningCommonLiner? liner = null; - int counter = 100; - while (liner == null) - { - liner = _company.GetRandomObject(); - counter--; - if (counter <= 0) - { - break; - } - } - - if (liner == null) - { - return; - } - - FormLiner form = new() - { - SetLiner = liner - }; - form.ShowDialog(); - } - - /// - /// Перерисовка коллекции - /// - /// - /// - private void ButtonRefresh_Click(object sender, EventArgs e) - { - if (_company == null) - { - return; - } - + MessageBox.Show("Объект добавлен"); pictureBox.Image = _company.Show(); } + else + { + MessageBox.Show("Не удалось добавить объект"); + } } -} + /// + /// Получение цвета + /// + /// Генератор случайных чисел + /// + private static Color GetColor(Random random) + { + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, + 256), random.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + return color; + } + /// + /// Удаление объекта + /// + /// + /// + private void ButtonRemoveLiner_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null) + { + return; + } + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxPosition.Text); + if (_company - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBox.Image = _company.Show(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + + } + /// + /// Передача объекта в другую форму + /// + /// + /// + private void ButtonGoToCheck_Click(object sender, EventArgs e) + { + if (_company == null) + { + return; + } + DrawningCommonLiner? liner = null; + int counter = 100; + while (liner == null) + { + liner = _company.GetRandomObject(); + counter--; + if (counter <= 0) break; + } + if (liner == null) + { + return; + } + FormLiner form = new FormLiner(); + form.SetLiner = liner; + form.ShowDialog(); + } + /// + /// Перерисовка коллекции + /// + /// + /// + private void ButtonRefresh_Click(object sender, EventArgs e) + { + if (_company == null) + { + return; + } + + pictureBox.Image = _company.Show(); + + } + /// + /// Добавление коллекции + /// + /// + /// + private void ButtonCollectionAdd_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked)) + { + MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + CollectionType collectionType = CollectionType.None; + if (radioButtonMassive.Checked) + { + collectionType = CollectionType.Massive; + } + else if (radioButtonList.Checked) + { + collectionType = CollectionType.List; + } + _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType); + RerfreshListBoxItems(); + } + /// + /// Удаление коллекции + /// + /// + /// + private void ButtonCollectionDel_Click(object sender, EventArgs e) + { + if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null) + { + MessageBox.Show("Коллекция не выбрана"); + return; + } + if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + _storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString()); + RerfreshListBoxItems(); + } + /// + /// Обновление списка в listBoxCollection + /// + private void RerfreshListBoxItems() + { + listBoxCollection.Items.Clear(); + for (int i = 0; i < _storageCollection.Keys?.Count; ++i) + { + string? colName = _storageCollection.Keys?[i]; + if (!string.IsNullOrEmpty(colName)) + { + listBoxCollection.Items.Add(colName); + } + } + } + /// + /// Создание компании + /// + /// + /// + private void ButtonCreateCompany_Click(object sender, EventArgs e) + { + if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null) + { + MessageBox.Show("Коллекция не выбрана"); + return; + } + ICollectionGenericObjects? collection = + _storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty]; + if (collection == null) + { + MessageBox.Show("Коллекция не проинициализирована"); + return; + } + switch (comboBoxSelectorCompany.Text) + { + case "Хранилище": + _company = new LinerSharingService(pictureBox.Width, pictureBox.Height, collection); + break; + } + panelCompanyTools.Enabled = true; + RerfreshListBoxItems(); + } +} \ No newline at end of file