From b05d49640882468e187fe2eac95901884707e353 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Tue, 13 Feb 2024 14:51:17 +0400 Subject: [PATCH 1/9] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D1=87=D0=B0=D1=81=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSeaplane/DirectionType.cs | 26 ++ .../ProjectSeaplane/DrawningSeaplane.cs | 268 ++++++++++++++++++ .../ProjectSeaplane/EntitySeaplane.cs | 68 +++++ .../ProjectSeaplane/Form1.Designer.cs | 39 --- ProjectSeaplane/ProjectSeaplane/Form1.cs | 10 - .../ProjectSeaplane/FormSeaplane.Designer.cs | 130 +++++++++ .../ProjectSeaplane/FormSeaplane.cs | 40 +++ .../{Form1.resx => FormSeaplane.resx} | 50 ++-- ProjectSeaplane/ProjectSeaplane/Program.cs | 2 +- .../ProjectSeaplane/ProjectSeaplane.csproj | 15 + .../Properties/Resources.Designer.cs | 103 +++++++ .../ProjectSeaplane/Properties/Resources.resx | 133 +++++++++ .../ProjectSeaplane/Resources/arrow_down.png | Bin 0 -> 7619 bytes .../ProjectSeaplane/Resources/arrow_left.png | Bin 0 -> 8208 bytes .../ProjectSeaplane/Resources/arrow_right.png | Bin 0 -> 7698 bytes .../ProjectSeaplane/Resources/arrow_up.png | Bin 0 -> 8048 bytes 16 files changed, 809 insertions(+), 75 deletions(-) create mode 100644 ProjectSeaplane/ProjectSeaplane/DirectionType.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs delete mode 100644 ProjectSeaplane/ProjectSeaplane/Form1.Designer.cs delete mode 100644 ProjectSeaplane/ProjectSeaplane/Form1.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs rename ProjectSeaplane/ProjectSeaplane/{Form1.resx => FormSeaplane.resx} (93%) create mode 100644 ProjectSeaplane/ProjectSeaplane/Properties/Resources.Designer.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/Properties/Resources.resx create mode 100644 ProjectSeaplane/ProjectSeaplane/Resources/arrow_down.png create mode 100644 ProjectSeaplane/ProjectSeaplane/Resources/arrow_left.png create mode 100644 ProjectSeaplane/ProjectSeaplane/Resources/arrow_right.png create mode 100644 ProjectSeaplane/ProjectSeaplane/Resources/arrow_up.png diff --git a/ProjectSeaplane/ProjectSeaplane/DirectionType.cs b/ProjectSeaplane/ProjectSeaplane/DirectionType.cs new file mode 100644 index 0000000..ef50542 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/DirectionType.cs @@ -0,0 +1,26 @@ +namespace ProjectSeaplane; +/// +/// Направление перемещения +/// +public enum DirectionType +{ + /// + /// Вверх + /// + Up = 1, + + /// + /// Вниз + /// + Down = 2, + + /// + /// Влево + /// + Left = 3, + + /// + /// Вправо + /// + Right = 4 +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs new file mode 100644 index 0000000..d1bd771 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs @@ -0,0 +1,268 @@ +namespace ProjectSeaplane; +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// +public class DrawningSeaplane +{ + /// + /// Класс-сущность + /// + public EntitySeaplane? EntitySportCar { get; private set; } + /// + /// Ширина окна + /// + private int? _pictureWidth; + /// + /// Высота окна + /// + private int? _pictureHeight; + /// + /// Левая координата прорисовки автомобиля + /// + private int? _startPosX; + /// + /// Верхняя кооридната прорисовки автомобиля + /// + private int? _startPosY; + /// + /// Ширина прорисовки автомобиля + /// + private readonly int _drawningCarWidth = 110; + /// + /// Высота прорисовки автомобиля + /// + private readonly int _drawningCarHeight = 60; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) + { + EntitySportCar = new EntitySeaplane(); + EntitySportCar.Init(speed, weight, bodyColor, additionalColor, + bodyKit, wing, sportLine); + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах + public bool SetPictureSize(int width, int height) + { + // TODO проверка, что объект "влезает" в размеры поля + // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена + _pictureWidth = width; + _pictureHeight = height; + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + // TODO если при установке объекта в эти координаты, он будет + "выходить" за границы формы + // то надо изменить координаты, чтобы он оставался в этих границах +12 + _startPosX = x; + _startPosY = y; + } + /// + /// Изменение направления перемещения + /// + /// Направление + /// true - перемещене выполнено, false - перемещение + невозможно +public bool MoveTransport(DirectionType direction) + { + if (EntitySportCar == null || !_startPosX.HasValue || + !_startPosY.HasValue) + { + return false; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX.Value - EntitySportCar.Step > 0) + { + _startPosX -= (int)EntitySportCar.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntitySportCar.Step > 0) + { + _startPosY -= (int)EntitySportCar.Step; + } + return true; + // вправо + case DirectionType.Right: + //TODO прописать логику сдвига в право + return true; + //вниз + case DirectionType.Down: + //TODO прописать логику сдвига в вниз + return true; + default: + return false; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntitySportCar == null || !_startPosX.HasValue || + !_startPosY.HasValue) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(EntitySportCar.AdditionalColor); + // обвесы + 13 + if (EntitySportCar.BodyKit) + { + g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value, + 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + + 40, 20, 20); + g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + + 10, 20, 40); + g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value, + 15, 15); + g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + + 45, 15, 15); + g.FillEllipse(additionalBrush, _startPosX.Value + 90, + _startPosY.Value, 20, 20); + g.FillEllipse(additionalBrush, _startPosX.Value + 90, + _startPosY.Value + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX.Value + 90, + _startPosY.Value + 10, 20, 40); + g.FillRectangle(additionalBrush, _startPosX.Value + 90, + _startPosY.Value + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 90, + _startPosY.Value + 45, 15, 15); + g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value, 20, + 20); + g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 40, + 20, 20); + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 10, + 20, 40); + g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value, + 14, 15); + g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + + 45, 14, 15); + g.FillEllipse(additionalBrush, _startPosX.Value, + _startPosY.Value, 20, 20); + g.FillEllipse(additionalBrush, _startPosX.Value, + _startPosY.Value + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX.Value + 1, + _startPosY.Value + 10, 25, 40); + g.FillRectangle(additionalBrush, _startPosX.Value + 5, + _startPosY.Value + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 5, + _startPosY.Value + 45, 15, 15); + g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value, + 39, 15); + g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + + 45, 39, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 35, + _startPosY.Value + 1, 40, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 35, + _startPosY.Value + 45, 40, 15); + } + //границы автомобиля + g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 5, 20, + 20); + g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 35, 20, + 20); + g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 5, 20, + 20); + 14 + g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 35, 20, + 20); + g.DrawRectangle(pen, _startPosX.Value + 9, _startPosY.Value + 15, 10, + 30); + g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + 15, + 10, 30); + g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 4, 70, + 52); + //задние фары + Brush brRed = new SolidBrush(Color.Red); + g.FillEllipse(brRed, _startPosX.Value + 10, _startPosY.Value + 5, 20, + 20); + g.FillEllipse(brRed, _startPosX.Value + 10, _startPosY.Value + 35, + 20, 20); + //передние фары + Brush brYellow = new SolidBrush(Color.Yellow); + g.FillEllipse(brYellow, _startPosX.Value + 80, _startPosY.Value + 5, + 20, 20); + g.FillEllipse(brYellow, _startPosX.Value + 80, _startPosY.Value + 35, + 20, 20); + //кузов + Brush br = new SolidBrush(EntitySportCar.BodyColor); + g.FillRectangle(br, _startPosX.Value + 10, _startPosY.Value + 15, 10, + 30); + g.FillRectangle(br, _startPosX.Value + 90, _startPosY.Value + 15, 10, + 30); + g.FillRectangle(br, _startPosX.Value + 20, _startPosY.Value + 5, 70, + 50); + //стекла + Brush brBlue = new SolidBrush(Color.LightBlue); + g.FillRectangle(brBlue, _startPosX.Value + 70, _startPosY.Value + 10, + 5, 40); + g.FillRectangle(brBlue, _startPosX.Value + 30, _startPosY.Value + 10, + 5, 40); + g.FillRectangle(brBlue, _startPosX.Value + 35, _startPosY.Value + 8, + 35, 2); + g.FillRectangle(brBlue, _startPosX.Value + 35, _startPosY.Value + 51, + 35, 2); + //выделяем рамкой крышу + g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 10, + 35, 40); + g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 15, + 25, 30); + g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 15, + 15, 30); + // спортивная линия + if (EntitySportCar.SportLine) + { + g.FillRectangle(additionalBrush, _startPosX.Value + 75, + _startPosY.Value + 23, 25, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 35, + _startPosY.Value + 23, 35, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 10, + _startPosY.Value + 23, 20, 15); + } + // крыло + if (EntitySportCar.Wing) + 15 + { + g.FillRectangle(additionalBrush, _startPosX.Value, + _startPosY.Value + 5, 10, 50); + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 5, + 10, 50); + } + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs new file mode 100644 index 0000000..3503966 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs @@ -0,0 +1,68 @@ +namespace ProjectSeaplane; +/// +/// Класс-сущность "Спортивный автомобиль" +/// +public class EntitySeaplane +{ + /// + /// Скорость + /// + 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 BodyKit { get; private set; } + + /// + /// Признак (опция) наличия антикрыла + /// + public bool Wing { get; private set; } + + /// + /// Признак (опция) наличия гоночной полосы + /// + public bool SportLine { get; private set; } + + /// + /// Шаг перемещения автомобиля + /// + public double Step => Speed * 100 / Weight; + + /// + /// Инициализация полей объекта-класса спортивного автомобиля + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// Признак наличия гоночной полосы + public void Init(int speed, double weight, Color bodyColor, Color + additionalColor, bool bodyKit, bool wing, bool sportLine) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + BodyKit = bodyKit; + Wing = wing; + SportLine = sportLine; + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/Form1.Designer.cs b/ProjectSeaplane/ProjectSeaplane/Form1.Designer.cs deleted file mode 100644 index 8e222d3..0000000 --- a/ProjectSeaplane/ProjectSeaplane/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectSeaplane -{ - 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/ProjectSeaplane/ProjectSeaplane/Form1.cs b/ProjectSeaplane/ProjectSeaplane/Form1.cs deleted file mode 100644 index 4a978b3..0000000 --- a/ProjectSeaplane/ProjectSeaplane/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectSeaplane -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs new file mode 100644 index 0000000..7ef955e --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs @@ -0,0 +1,130 @@ +namespace ProjectSeaplane +{ + partial class FormSeaplane + { + /// + /// 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() + { + pictureBoxSeaplane = new PictureBox(); + buttonCreate = new Button(); + buttonLeft = new Button(); + buttonUp = new Button(); + buttonDown = new Button(); + buttonRight = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).BeginInit(); + SuspendLayout(); + // + // pictureBoxSeaplane + // + pictureBoxSeaplane.Dock = DockStyle.Fill; + pictureBoxSeaplane.Location = new Point(0, 0); + pictureBoxSeaplane.Name = "pictureBoxSeaplane"; + pictureBoxSeaplane.Size = new Size(850, 539); + pictureBoxSeaplane.TabIndex = 0; + pictureBoxSeaplane.TabStop = false; + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(12, 504); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(75, 23); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.arrow_left; + buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; + buttonLeft.Location = new Point(718, 490); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(35, 35); + buttonLeft.TabIndex = 2; + buttonLeft.UseVisualStyleBackColor = true; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.arrow_up; + buttonUp.BackgroundImageLayout = ImageLayout.Stretch; + buttonUp.Location = new Point(758, 450); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(35, 35); + buttonUp.TabIndex = 3; + buttonUp.UseVisualStyleBackColor = true; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.arrow_down; + buttonDown.BackgroundImageLayout = ImageLayout.Stretch; + buttonDown.Location = new Point(758, 490); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(35, 35); + buttonDown.TabIndex = 4; + buttonDown.UseVisualStyleBackColor = true; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.arrow_right; + buttonRight.BackgroundImageLayout = ImageLayout.Stretch; + buttonRight.Location = new Point(799, 490); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(35, 35); + buttonRight.TabIndex = 5; + buttonRight.UseVisualStyleBackColor = true; + // + // FormSeaplane + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(850, 539); + Controls.Add(buttonRight); + Controls.Add(buttonDown); + Controls.Add(buttonUp); + Controls.Add(buttonLeft); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxSeaplane); + Name = "FormSeaplane"; + Text = "Гидросамолёт"; + ((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).EndInit(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBoxSeaplane; + private Button buttonCreate; + private Button buttonLeft; + private Button buttonUp; + private Button buttonDown; + private Button buttonRight; + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs new file mode 100644 index 0000000..86c3f21 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs @@ -0,0 +1,40 @@ +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 ProjectSeaplane +{ + public partial class FormSeaplane : Form + { + private DrawningSeaplane? _drawningSeaplane; + + public FormSeaplane() + { + InitializeComponent(); + } + + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningSeaplane = new DrawningSeaplane(); + _drawningSeaplane.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))); + _drawningSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); + _drawningSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100)); + + Bitmap bmp = new(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningSeaplane.DrawTransport(gr); + pictureBoxSeaplane.Image = bmp; + + } + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/Form1.resx b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.resx similarity index 93% rename from ProjectSeaplane/ProjectSeaplane/Form1.resx rename to ProjectSeaplane/ProjectSeaplane/FormSeaplane.resx index 1af7de1..af32865 100644 --- a/ProjectSeaplane/ProjectSeaplane/Form1.resx +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.resx @@ -1,17 +1,17 @@  - diff --git a/ProjectSeaplane/ProjectSeaplane/Program.cs b/ProjectSeaplane/ProjectSeaplane/Program.cs index bcf84b2..4e58da8 100644 --- a/ProjectSeaplane/ProjectSeaplane/Program.cs +++ b/ProjectSeaplane/ProjectSeaplane/Program.cs @@ -11,7 +11,7 @@ namespace ProjectSeaplane // 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 FormSeaplane()); } } } \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/ProjectSeaplane.csproj b/ProjectSeaplane/ProjectSeaplane/ProjectSeaplane.csproj index e1a0735..244387d 100644 --- a/ProjectSeaplane/ProjectSeaplane/ProjectSeaplane.csproj +++ b/ProjectSeaplane/ProjectSeaplane/ProjectSeaplane.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/Properties/Resources.Designer.cs b/ProjectSeaplane/ProjectSeaplane/Properties/Resources.Designer.cs new file mode 100644 index 0000000..ff77389 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectSeaplane.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("ProjectSeaplane.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 arrow_down { + get { + object obj = ResourceManager.GetObject("arrow_down", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrow_left { + get { + object obj = ResourceManager.GetObject("arrow_left", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrow_right { + get { + object obj = ResourceManager.GetObject("arrow_right", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrow_up { + get { + object obj = ResourceManager.GetObject("arrow_up", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/Properties/Resources.resx b/ProjectSeaplane/ProjectSeaplane/Properties/Resources.resx new file mode 100644 index 0000000..47aca23 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/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\arrow_down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrow_left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrow_right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrow_up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/Resources/arrow_down.png b/ProjectSeaplane/ProjectSeaplane/Resources/arrow_down.png new file mode 100644 index 0000000000000000000000000000000000000000..769dc0c8f55edbdb6a4e66541c0a10b2ecce1f5a GIT binary patch literal 7619 zcmdUU`9IWM*#DWa4niZ#U6z!|HbtcnWm3|RH3^k9Sy~XHgi(VmZL&m`p)6%rqQp!y z2y=%lsnFOm5oWS9wlUwM@BRGn{0YzJ_3|>G>%7l(-q$(jbI$u*C(hc^bc4ud5dgpj z{PCl<03hK{BoG#a|K>w`mf=7CKx4d}Fnn$bpT7g&5rMX*#-OZSeqz1Q>#)UP04nc` zuDS`pca;Be$3OtY8`u93DVpM208luNKYG|M)OmU^{DG%umXd$_bhb>sknWk*=800f zZMIuPPd{wW>hqOrQu|U~BtNlRJMPQLu~^ftb38eo?|ZTsxovAh<*huzVvKlk z0;^auvUZcF5<(#zsbK)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7I1d7$iw;=rzFYHErH6Dl3lpiIVSO@U7a&ktxE0|XIx z*}$Rt9}z}&Xq6=%b67BvUNhjqoR4{T9N2FP2=NBI)j1bw#g-c4#J!QW&VyaBFD%OY z>b8Hz30xNi8Z+;QOtfy;G@x@tif3Iue(;FY4vnQTzp)v=mFfm(&NX33FM=^?ZIgVxKa=eT>#-cd@sUx1P`vb|Wc_M;axP%RX_e@nq`qFaUhBvW1T4wBe>;C~$>}MSS literal 0 HcmV?d00001 diff --git a/ProjectSeaplane/ProjectSeaplane/Resources/arrow_left.png b/ProjectSeaplane/ProjectSeaplane/Resources/arrow_left.png new file mode 100644 index 0000000000000000000000000000000000000000..2460900445e78085f89dab5719af5ac4afe291c9 GIT binary patch literal 8208 zcmdsc`9IX%`~R6S)hJ~vgiKk|UDlGQ&|~vo0KGE zDQTv%R1~r|1`#IvzK(f)ujze%ACJ!upTFSa@#rD1bIx_nxz2T-*YkRw+h!&Pn>UJY zLmJTieCxKNe3_B?TMs>$yD^FF1dyp!AWP zmdN`r4JnsDS*Q^5j9&N49k(xDd^-Eg$~Ysga8Sm4*yJPA^bL+Q%yZ%D z&>mRU|A8M3-L?r~Dz4On`KqRlL}42~dT{+yPa$P()SRgvru0)A$MVU}&aNwEjL+^% z{Pd)gGlQAS>kiKDj9zhS{cM#qerq@`utySG{^(S4zcyW48cw+A`}gnvF(8G_1*v|> zNRs{NkX4$ep{X|A+bcOgTjFYUW(5`@E{mVThPS5OXi85>xme^_pLD4*#E8BR zA)lQdZ2ou&Ow?fsGbeAjwlusKjzu(}aPa3!B2_N_ES2Z)BQCJht)TEtA1O+JWGf97F(^8 z3L$GR^$M4B?nDds>F}asy_V%3%ziPpvc^QkfPeKun(7keu?8+2Ryy~()U89xy0F8x zB4lwQbjnuBulEb?xh)r}1y4b#<{=X`Aao+O(~R-{oPH?1x7x!?ksF6jcv)VQ*!CC+7&~g63~Vv0h=C}6?V+hXc_#RdwPnWSLtj)M71h$ZF>?@ z6N@RrB-oEP_w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kE`Q@CpV+zmcn;DJ%K>MsJ{n<_8n3GQ-p|ZMQ$1m0lQ+q?p1*vIQ_Q2fE-*N+ zKDj;(J4*Sova;AR`f(Xps?}`!JBVQOQu*NJgdn#EjPCZJ(ML!K`Nf)lZBOEsmZ2E2 z$H_Ck`PaXZ@{DgpaXL+k9pDotWO?H4V(`A!um k2>svxZnoA(e`Fa!(bcbAW1WDFC;V8QusdF6>VEV80IQUG-~a#s literal 0 HcmV?d00001 -- 2.25.1 From a1e7d192d88721f508ea794c1cb5bf0d33f8a1f1 Mon Sep 17 00:00:00 2001 From: ShuryginDima Date: Mon, 26 Feb 2024 22:32:27 +0300 Subject: [PATCH 2/9] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSeaplane/DrawningSeaplane.cs | 482 ++++++++---------- .../ProjectSeaplane/EntitySeaplane.cs | 30 +- .../ProjectSeaplane/FormSeaplane.Designer.cs | 40 +- .../ProjectSeaplane/FormSeaplane.cs | 111 ++-- 4 files changed, 327 insertions(+), 336 deletions(-) diff --git a/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs index d1bd771..72eba68 100644 --- a/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs @@ -1,268 +1,214 @@ -namespace ProjectSeaplane; -/// -/// Класс, отвечающий за прорисовку и перемещение объекта-сущности -/// -public class DrawningSeaplane -{ - /// - /// Класс-сущность - /// - public EntitySeaplane? EntitySportCar { get; private set; } - /// - /// Ширина окна - /// - private int? _pictureWidth; - /// - /// Высота окна - /// - private int? _pictureHeight; - /// - /// Левая координата прорисовки автомобиля - /// - private int? _startPosX; - /// - /// Верхняя кооридната прорисовки автомобиля - /// - private int? _startPosY; - /// - /// Ширина прорисовки автомобиля - /// - private readonly int _drawningCarWidth = 110; - /// - /// Высота прорисовки автомобиля - /// - private readonly int _drawningCarHeight = 60; - /// - /// Инициализация свойств - /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine) - { - EntitySportCar = new EntitySeaplane(); - EntitySportCar.Init(speed, weight, bodyColor, additionalColor, - bodyKit, wing, sportLine); - _pictureWidth = null; - _pictureHeight = null; - _startPosX = null; - _startPosY = null; - } - /// - /// Установка границ поля - /// - /// Ширина поля - /// Высота поля - /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах - public bool SetPictureSize(int width, int height) - { - // TODO проверка, что объект "влезает" в размеры поля - // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена - _pictureWidth = width; - _pictureHeight = height; - return true; - } - /// - /// Установка позиции - /// - /// Координата X - /// Координата Y - public void SetPosition(int x, int y) - { - if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) - { - return; - } - // TODO если при установке объекта в эти координаты, он будет - "выходить" за границы формы - // то надо изменить координаты, чтобы он оставался в этих границах -12 - _startPosX = x; - _startPosY = y; - } - /// - /// Изменение направления перемещения - /// - /// Направление - /// true - перемещене выполнено, false - перемещение - невозможно -public bool MoveTransport(DirectionType direction) - { - if (EntitySportCar == null || !_startPosX.HasValue || - !_startPosY.HasValue) - { - return false; - } - switch (direction) - { - //влево - case DirectionType.Left: - if (_startPosX.Value - EntitySportCar.Step > 0) - { - _startPosX -= (int)EntitySportCar.Step; - } - return true; - //вверх - case DirectionType.Up: - if (_startPosY.Value - EntitySportCar.Step > 0) - { - _startPosY -= (int)EntitySportCar.Step; - } - return true; - // вправо - case DirectionType.Right: - //TODO прописать логику сдвига в право - return true; - //вниз - case DirectionType.Down: - //TODO прописать логику сдвига в вниз - return true; - default: - return false; - } - } - /// - /// Прорисовка объекта - /// - /// - public void DrawTransport(Graphics g) - { - if (EntitySportCar == null || !_startPosX.HasValue || - !_startPosY.HasValue) - { - return; - } - Pen pen = new(Color.Black); - Brush additionalBrush = new - SolidBrush(EntitySportCar.AdditionalColor); - // обвесы - 13 - if (EntitySportCar.BodyKit) - { - g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value, - 20, 20); - g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + - 40, 20, 20); - g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + - 10, 20, 40); - g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value, - 15, 15); - g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + - 45, 15, 15); - g.FillEllipse(additionalBrush, _startPosX.Value + 90, - _startPosY.Value, 20, 20); - g.FillEllipse(additionalBrush, _startPosX.Value + 90, - _startPosY.Value + 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX.Value + 90, - _startPosY.Value + 10, 20, 40); - g.FillRectangle(additionalBrush, _startPosX.Value + 90, - _startPosY.Value + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX.Value + 90, - _startPosY.Value + 45, 15, 15); - g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value, 20, - 20); - g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 40, - 20, 20); - g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 10, - 20, 40); - g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value, - 14, 15); - g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + - 45, 14, 15); - g.FillEllipse(additionalBrush, _startPosX.Value, - _startPosY.Value, 20, 20); - g.FillEllipse(additionalBrush, _startPosX.Value, - _startPosY.Value + 40, 20, 20); - g.FillRectangle(additionalBrush, _startPosX.Value + 1, - _startPosY.Value + 10, 25, 40); - g.FillRectangle(additionalBrush, _startPosX.Value + 5, - _startPosY.Value + 1, 15, 15); - g.FillRectangle(additionalBrush, _startPosX.Value + 5, - _startPosY.Value + 45, 15, 15); - g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value, - 39, 15); - g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + - 45, 39, 15); - g.FillRectangle(additionalBrush, _startPosX.Value + 35, - _startPosY.Value + 1, 40, 15); - g.FillRectangle(additionalBrush, _startPosX.Value + 35, - _startPosY.Value + 45, 40, 15); - } - //границы автомобиля - g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 5, 20, - 20); - g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 35, 20, - 20); - g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 5, 20, - 20); - 14 - g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 35, 20, - 20); - g.DrawRectangle(pen, _startPosX.Value + 9, _startPosY.Value + 15, 10, - 30); - g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + 15, - 10, 30); - g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 4, 70, - 52); - //задние фары - Brush brRed = new SolidBrush(Color.Red); - g.FillEllipse(brRed, _startPosX.Value + 10, _startPosY.Value + 5, 20, - 20); - g.FillEllipse(brRed, _startPosX.Value + 10, _startPosY.Value + 35, - 20, 20); - //передние фары - Brush brYellow = new SolidBrush(Color.Yellow); - g.FillEllipse(brYellow, _startPosX.Value + 80, _startPosY.Value + 5, - 20, 20); - g.FillEllipse(brYellow, _startPosX.Value + 80, _startPosY.Value + 35, - 20, 20); - //кузов - Brush br = new SolidBrush(EntitySportCar.BodyColor); - g.FillRectangle(br, _startPosX.Value + 10, _startPosY.Value + 15, 10, - 30); - g.FillRectangle(br, _startPosX.Value + 90, _startPosY.Value + 15, 10, - 30); - g.FillRectangle(br, _startPosX.Value + 20, _startPosY.Value + 5, 70, - 50); - //стекла - Brush brBlue = new SolidBrush(Color.LightBlue); - g.FillRectangle(brBlue, _startPosX.Value + 70, _startPosY.Value + 10, - 5, 40); - g.FillRectangle(brBlue, _startPosX.Value + 30, _startPosY.Value + 10, - 5, 40); - g.FillRectangle(brBlue, _startPosX.Value + 35, _startPosY.Value + 8, - 35, 2); - g.FillRectangle(brBlue, _startPosX.Value + 35, _startPosY.Value + 51, - 35, 2); - //выделяем рамкой крышу - g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 10, - 35, 40); - g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 15, - 25, 30); - g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 15, - 15, 30); - // спортивная линия - if (EntitySportCar.SportLine) - { - g.FillRectangle(additionalBrush, _startPosX.Value + 75, - _startPosY.Value + 23, 25, 15); - g.FillRectangle(additionalBrush, _startPosX.Value + 35, - _startPosY.Value + 23, 35, 15); - g.FillRectangle(additionalBrush, _startPosX.Value + 10, - _startPosY.Value + 23, 20, 15); - } - // крыло - if (EntitySportCar.Wing) - 15 - { - g.FillRectangle(additionalBrush, _startPosX.Value, - _startPosY.Value + 5, 10, 50); - g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 5, - 10, 50); - } - } -} \ No newline at end of file +namespace ProjectSeaplane; +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// +public class DrawningSeaplane +{ + /// + /// Класс-сущность + /// + public EntitySeaplane? EntitySeaplane { get; private set; } + + /// + /// Ширина окна + /// + private int? _pictureWidth; + + /// + /// Высота окна + /// + private int? _pictureHeight; + + /// + /// Левая координата прорисовки гидросамолёта + /// + private int? _startPosX; + + /// + /// Верхняя кооридната прорисовки гидросамолёта + /// + private int? _startPosY; + + /// + /// Ширина прорисовки гидросамолёта + /// + private readonly int _drawningSeaplaneWidth = 130; + + /// + /// Высота прорисовки гидросамолёта + /// + private readonly int _drawningSeaplaneHeight = 50; + + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия поплавков + /// Признак наличия лодки + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool boat) + { + EntitySeaplane = new EntitySeaplane(); + EntitySeaplane.Init(speed, weight, bodyColor, additionalColor, floats, boat); + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах + public bool SetPictureSize(int width, int height) + { + // TODO проверка, что объект "влезает" в размеры поля + // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена + _pictureWidth = width; + _pictureHeight = height; + return true; + } + + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы + // то надо изменить координаты, чтобы он оставался в этих границах + + _startPosX = x; + _startPosY = y; + } + + /// + /// Изменение направления перемещения + /// + /// Направление + /// true - перемещене выполнено, false - перемещение невозможно + public bool MoveTransport(DirectionType direction) + { + if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return false; + } + + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX.Value - EntitySeaplane.Step > 0) + { + _startPosX -= (int)EntitySeaplane.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntitySeaplane.Step > 0) + { + _startPosY -= (int)EntitySeaplane.Step; + } + return true; + // вправо + case DirectionType.Right: + if (_startPosX.Value + _drawningSeaplaneWidth + EntitySeaplane.Step < _pictureWidth) + { + _startPosX += (int)EntitySeaplane.Step; + } + return true; + //вниз + case DirectionType.Down: + + if (_startPosY.Value + _drawningSeaplaneHeight + EntitySeaplane.Step < _pictureHeight) + { + _startPosY += (int)EntitySeaplane.Step; + } + return true; + default: + return false; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + Pen pen = new(Color.Black, 2); + Brush additionalBrush = new SolidBrush(EntitySeaplane.AdditionalColor); + + + + //Отрисовка основных частей самолёта + Brush br = new SolidBrush(EntitySeaplane.BodyColor); + g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 20, 20, 20); + g.FillEllipse(br, _startPosX.Value, _startPosY.Value + 20, 20, 20); + Point point1 = new Point(_startPosX.Value + 10, _startPosY.Value); + Point point2 = new Point(_startPosX.Value + 40, _startPosY.Value + 20); + Point point3 = new Point(_startPosX.Value + 100, _startPosY.Value + 20); + Point point4 = new Point(_startPosX.Value + 130, _startPosY.Value + 30); + Point point5 = new Point(_startPosX.Value + 100, _startPosY.Value + 40); + Point point6 = new Point(_startPosX.Value + 10, _startPosY.Value + 40); + Point[] points = { point1, point2, point3, point4, point5, point6 }; + g.FillPolygon(br, points); + g.DrawPolygon(pen, points); + g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 20, _startPosX.Value + 40, _startPosY.Value + 20); + g.DrawLine(pen, _startPosX.Value + 100, _startPosY.Value + 20, _startPosX.Value + 100, _startPosY.Value + 40); + g.DrawLine(pen, _startPosX.Value + 100, _startPosY.Value + 30, _startPosX.Value + 130, _startPosY.Value + 30); + + //Крылья + g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 20, 25, 5); + g.FillEllipse(br, _startPosX.Value, _startPosY.Value + 20, 25, 5); + g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 25, 40, 10); + g.FillEllipse(br, _startPosX.Value + 30, _startPosY.Value + 25, 40, 10); + + + //Шасси + g.DrawRectangle(pen, _startPosX.Value + 38, _startPosY.Value + 40, 4, 5); + g.DrawRectangle(pen, _startPosX.Value + 88, _startPosY.Value + 40, 4, 5); + g.DrawEllipse(pen, _startPosX.Value + 35, _startPosY.Value + 45, 5, 5); + g.DrawEllipse(pen, _startPosX.Value + 42, _startPosY.Value + 45, 5, 5); + g.DrawEllipse(pen, _startPosX.Value + 87, _startPosY.Value + 45, 5, 5); + + g.FillRectangle(br, _startPosX.Value + 38, _startPosY.Value + 40, 4, 5); + g.FillRectangle(br, _startPosX.Value + 88, _startPosY.Value + 40, 4, 5); + g.FillEllipse(br, _startPosX.Value + 35, _startPosY.Value + 45, 5, 5); + g.FillEllipse(br, _startPosX.Value + 42, _startPosY.Value + 45, 5, 5); + g.FillEllipse(br, _startPosX.Value + 87, _startPosY.Value + 45, 5, 5); + + + //Надувнвя лодка + if (EntitySeaplane.Boat) + { + g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 15, 30, 10); + g.FillEllipse(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 15, 30, 10); + + } + + //Поплавки + if (EntitySeaplane.Floats) + { + g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 30, 4, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 30, 4, 15); + g.DrawRectangle(pen, _startPosX.Value + 66, _startPosY.Value + 30, 4, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 66, _startPosY.Value + 30, 4, 15); + g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 40, 70, 10); + g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 40, 70, 10); + + } + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs index 3503966..625ccfc 100644 --- a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs @@ -1,6 +1,6 @@ namespace ProjectSeaplane; /// -/// Класс-сущность "Спортивный автомобиль" +/// Класс-сущность "Гидросамолёт" /// public class EntitySeaplane { @@ -24,45 +24,39 @@ public class EntitySeaplane /// public Color AdditionalColor { get; private set; } - /// - /// Признак (опция) наличия обвеса - /// - public bool BodyKit { get; private set; } /// - /// Признак (опция) наличия антикрыла + /// Признак (опция) наличия поплавков /// - public bool Wing { get; private set; } + public bool Floats { get; private set; } /// - /// Признак (опция) наличия гоночной полосы + /// Признак (опция) наличия лодки /// - public bool SportLine { get; private set; } + public bool Boat { get; private set; } /// - /// Шаг перемещения автомобиля + /// Шаг перемещения гидросамолёта /// public double Step => Speed * 100 / Weight; /// - /// Инициализация полей объекта-класса спортивного автомобиля + /// Инициализация полей объекта-класса гидросамолёта /// /// Скорость /// Вес автомобиля /// Основной цвет /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - /// Признак наличия гоночной полосы + /// Признак наличия поплавков + /// Признак наличия лодки public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bodyKit, bool wing, bool sportLine) + additionalColor, bool floats, bool boat) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; - BodyKit = bodyKit; - Wing = wing; - SportLine = sportLine; + Floats = floats; + Boat = boat; } } diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs index 7ef955e..fde1660 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs @@ -29,7 +29,7 @@ private void InitializeComponent() { pictureBoxSeaplane = new PictureBox(); - buttonCreate = new Button(); + buttonCreateSeaplane = new Button(); buttonLeft = new Button(); buttonUp = new Button(); buttonDown = new Button(); @@ -42,75 +42,79 @@ pictureBoxSeaplane.Dock = DockStyle.Fill; pictureBoxSeaplane.Location = new Point(0, 0); pictureBoxSeaplane.Name = "pictureBoxSeaplane"; - pictureBoxSeaplane.Size = new Size(850, 539); + pictureBoxSeaplane.Size = new Size(900, 500); pictureBoxSeaplane.TabIndex = 0; pictureBoxSeaplane.TabStop = false; // - // buttonCreate + // buttonCreateSeaplane // - buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreate.Location = new Point(12, 504); - buttonCreate.Name = "buttonCreate"; - buttonCreate.Size = new Size(75, 23); - buttonCreate.TabIndex = 1; - buttonCreate.Text = "Создать"; - buttonCreate.UseVisualStyleBackColor = true; - buttonCreate.Click += buttonCreate_Click; + buttonCreateSeaplane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateSeaplane.Location = new Point(12, 465); + buttonCreateSeaplane.Name = "buttonCreateSeaplane"; + buttonCreateSeaplane.Size = new Size(75, 23); + buttonCreateSeaplane.TabIndex = 1; + buttonCreateSeaplane.Text = "Создать"; + buttonCreateSeaplane.UseVisualStyleBackColor = true; + buttonCreateSeaplane.Click += ButtonCreateSeaplane_Click; // // buttonLeft // buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonLeft.BackgroundImage = Properties.Resources.arrow_left; buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; - buttonLeft.Location = new Point(718, 490); + buttonLeft.Location = new Point(768, 451); buttonLeft.Name = "buttonLeft"; buttonLeft.Size = new Size(35, 35); buttonLeft.TabIndex = 2; buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += ButtonMove_Click; // // buttonUp // buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonUp.BackgroundImage = Properties.Resources.arrow_up; buttonUp.BackgroundImageLayout = ImageLayout.Stretch; - buttonUp.Location = new Point(758, 450); + buttonUp.Location = new Point(808, 411); buttonUp.Name = "buttonUp"; buttonUp.Size = new Size(35, 35); buttonUp.TabIndex = 3; buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += ButtonMove_Click; // // buttonDown // buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonDown.BackgroundImage = Properties.Resources.arrow_down; buttonDown.BackgroundImageLayout = ImageLayout.Stretch; - buttonDown.Location = new Point(758, 490); + buttonDown.Location = new Point(808, 451); buttonDown.Name = "buttonDown"; buttonDown.Size = new Size(35, 35); buttonDown.TabIndex = 4; buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += ButtonMove_Click; // // buttonRight // buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonRight.BackgroundImage = Properties.Resources.arrow_right; buttonRight.BackgroundImageLayout = ImageLayout.Stretch; - buttonRight.Location = new Point(799, 490); + buttonRight.Location = new Point(849, 451); buttonRight.Name = "buttonRight"; buttonRight.Size = new Size(35, 35); buttonRight.TabIndex = 5; buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += ButtonMove_Click; // // FormSeaplane // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(850, 539); + ClientSize = new Size(900, 500); Controls.Add(buttonRight); Controls.Add(buttonDown); Controls.Add(buttonUp); Controls.Add(buttonLeft); - Controls.Add(buttonCreate); + Controls.Add(buttonCreateSeaplane); Controls.Add(pictureBoxSeaplane); Name = "FormSeaplane"; Text = "Гидросамолёт"; @@ -121,7 +125,7 @@ #endregion private PictureBox pictureBoxSeaplane; - private Button buttonCreate; + private Button buttonCreateSeaplane; private Button buttonLeft; private Button buttonUp; private Button buttonDown; diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs index 86c3f21..8781929 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs @@ -1,40 +1,87 @@ -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 ProjectSeaplane +namespace ProjectSeaplane; +/// +/// Форма работы с объектом "Спортивный автомобиль" +/// +public partial class FormSeaplane : Form { - public partial class FormSeaplane : Form + /// + /// Поле-объект для прорисовки объекта + /// + private DrawningSeaplane? _drawningSeaplane; + /// + /// Конструктор формы + /// + public FormSeaplane() { - private DrawningSeaplane? _drawningSeaplane; - - public FormSeaplane() + InitializeComponent(); + } + /// + /// Метод прорисовки машины + /// + private void Draw() + { + if (_drawningSeaplane == null) { - InitializeComponent(); + return; } - - private void ButtonCreate_Click(object sender, EventArgs e) + Bitmap bmp = new(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawningSeaplane.DrawTransport(gr); + pictureBoxSeaplane.Image = bmp; + } + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void ButtonCreateSeaplane_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningSeaplane = new DrawningSeaplane(); + + _drawningSeaplane.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))); + _drawningSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); + _drawningSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } + /// + /// Перемещение объекта по форме (нажатие кнопок навигации) + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawningSeaplane == null) { - Random random = new(); - _drawningSeaplane = new DrawningSeaplane(); - _drawningSeaplane.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))); - _drawningSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); - _drawningSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100)); - - Bitmap bmp = new(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); - Graphics gr = Graphics.FromImage(bmp); - _drawningSeaplane.DrawTransport(gr); - pictureBoxSeaplane.Image = bmp; - + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + bool result = false; + switch (name) + { + case "buttonUp": + result = + _drawningSeaplane.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + result = + _drawningSeaplane.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + result = + _drawningSeaplane.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + result = + _drawningSeaplane.MoveTransport(DirectionType.Right); + break; + } + if (result) + { + Draw(); } } } -- 2.25.1 From 8b930c99d4b477ba145f8f6bccd70ead95e0a14a Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Tue, 27 Feb 2024 13:55:02 +0400 Subject: [PATCH 3/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BE?= =?UTF-8?q?=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSeaplane/DrawningSeaplane.cs | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs index 72eba68..fddee39 100644 --- a/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs @@ -66,10 +66,19 @@ public class DrawningSeaplane /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах public bool SetPictureSize(int width, int height) { - // TODO проверка, что объект "влезает" в размеры поля - // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена + + + if (height < _drawningSeaplaneHeight || width < _drawningSeaplaneWidth) + { + return false; + } + + _pictureWidth = width; _pictureHeight = height; + + if (_startPosX.HasValue && _drawningSeaplaneWidth + _startPosX > width) _startPosX = _pictureWidth - _drawningSeaplaneWidth; + if (_startPosY.HasValue && _drawningSeaplaneHeight + _startPosY > height) _startPosY = _pictureHeight - _drawningSeaplaneHeight; return true; } @@ -84,8 +93,22 @@ public class DrawningSeaplane { return; } - // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы - // то надо изменить координаты, чтобы он оставался в этих границах + if (x < 0) + { + x = 0; + } + if (x + _drawningSeaplaneWidth > _pictureWidth.Value) + { + x = _pictureWidth.Value - _drawningSeaplaneWidth; + } + if (y < 0) + { + y = 0; + } + if (y + _drawningSeaplaneHeight > _pictureHeight.Value) + { + y = _pictureHeight.Value - _drawningSeaplaneHeight; + } _startPosX = x; _startPosY = y; -- 2.25.1 From fdeb174e9033eee03b91858dd35234d2d0b63883 Mon Sep 17 00:00:00 2001 From: ShuryginDima Date: Sun, 10 Mar 2024 16:04:36 +0300 Subject: [PATCH 4/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=80=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=B8=20=D0=B2=D0=B2=D0=BE=D0=B4=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => Drawnings}/DirectionType.cs | 2 +- .../DrawningPlane.cs} | 113 +++++++++--------- .../Drawnings/DrawningSeaplane.cs | 55 +++++++++ .../ProjectSeaplane/Entities/EntityPlane.cs | 49 ++++++++ .../{ => Entities}/EntitySeaplane.cs | 30 +---- .../ProjectSeaplane/FormSeaplane.Designer.cs | 18 ++- .../ProjectSeaplane/FormSeaplane.cs | 77 +++++++----- 7 files changed, 228 insertions(+), 116 deletions(-) rename ProjectSeaplane/ProjectSeaplane/{ => Drawnings}/DirectionType.cs (90%) rename ProjectSeaplane/ProjectSeaplane/{DrawningSeaplane.cs => Drawnings/DrawningPlane.cs} (70%) create mode 100644 ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningSeaplane.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/Entities/EntityPlane.cs rename ProjectSeaplane/ProjectSeaplane/{ => Entities}/EntitySeaplane.cs (66%) diff --git a/ProjectSeaplane/ProjectSeaplane/DirectionType.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs similarity index 90% rename from ProjectSeaplane/ProjectSeaplane/DirectionType.cs rename to ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs index ef50542..274b265 100644 --- a/ProjectSeaplane/ProjectSeaplane/DirectionType.cs +++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs @@ -1,4 +1,4 @@ -namespace ProjectSeaplane; +namespace ProjectSeaplane.Drawnings; /// /// Направление перемещения /// diff --git a/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningPlane.cs similarity index 70% rename from ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs rename to ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningPlane.cs index fddee39..850f600 100644 --- a/ProjectSeaplane/ProjectSeaplane/DrawningSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningPlane.cs @@ -1,13 +1,18 @@ -namespace ProjectSeaplane; -/// -/// Класс, отвечающий за прорисовку и перемещение объекта-сущности -/// -public class DrawningSeaplane +using ProjectSeaplane.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectSeaplane.Drawnings; + +public class DrawningPlane { /// /// Класс-сущность /// - public EntitySeaplane? EntitySeaplane { get; private set; } + public EntityPlane? EntityPlane { get; protected set; } /// /// Ширина окна @@ -22,42 +27,56 @@ public class DrawningSeaplane /// /// Левая координата прорисовки гидросамолёта /// - private int? _startPosX; + protected int? _startPosX; /// /// Верхняя кооридната прорисовки гидросамолёта /// - private int? _startPosY; + protected int? _startPosY; /// /// Ширина прорисовки гидросамолёта /// - private readonly int _drawningSeaplaneWidth = 130; + private readonly int _drawningPlaneWidth = 130; /// /// Высота прорисовки гидросамолёта /// - private readonly int _drawningSeaplaneHeight = 50; + private readonly int _drawningPlaneHeight = 45; /// - /// Инициализация свойств + /// Пустой конструктор /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия поплавков - /// Признак наличия лодки - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool boat) + private DrawningPlane() { - EntitySeaplane = new EntitySeaplane(); - EntitySeaplane.Init(speed, weight, bodyColor, additionalColor, floats, boat); _pictureWidth = null; _pictureHeight = null; _startPosX = null; _startPosY = null; } + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + public DrawningPlane(int speed, double weight, Color bodyColor) : this() + { + EntityPlane = new EntityPlane(speed, weight, bodyColor); + } + + /// + /// Конструктор для наследников + /// + /// Ширина прорисовки гидросамолёта + /// Высота прорисовки гидросамолёта + protected DrawningPlane(int _drawningPlaneWidth, int _drawningPlaneHeight) : this() + { + _drawningPlaneWidth = drawningPlaneWidth; + _pictureHeight = drawningPlaneHeight; + } + /// /// Установка границ поля /// @@ -66,7 +85,7 @@ public class DrawningSeaplane /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах public bool SetPictureSize(int width, int height) { - + if (height < _drawningSeaplaneHeight || width < _drawningSeaplaneWidth) { @@ -121,7 +140,7 @@ public class DrawningSeaplane /// true - перемещене выполнено, false - перемещение невозможно public bool MoveTransport(DirectionType direction) { - if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityPlane == null || !_startPosX.HasValue || !_startPosY.HasValue) { return false; } @@ -130,31 +149,31 @@ public class DrawningSeaplane { //влево case DirectionType.Left: - if (_startPosX.Value - EntitySeaplane.Step > 0) + if (_startPosX.Value - EntityPlane.Step > 0) { - _startPosX -= (int)EntitySeaplane.Step; + _startPosX -= (int)EntityPlane.Step; } return true; //вверх case DirectionType.Up: - if (_startPosY.Value - EntitySeaplane.Step > 0) + if (_startPosY.Value - EntityPlane.Step > 0) { - _startPosY -= (int)EntitySeaplane.Step; + _startPosY -= (int)EntityPlane.Step; } return true; // вправо case DirectionType.Right: - if (_startPosX.Value + _drawningSeaplaneWidth + EntitySeaplane.Step < _pictureWidth) + if (_startPosX.Value + _drawningSeaplaneWidth + EntityPlane.Step < _pictureWidth) { - _startPosX += (int)EntitySeaplane.Step; + _startPosX += (int)EntityPlane.Step; } return true; //вниз case DirectionType.Down: - if (_startPosY.Value + _drawningSeaplaneHeight + EntitySeaplane.Step < _pictureHeight) + if (_startPosY.Value + _drawningSeaplaneHeight + EntityPlane.Step < _pictureHeight) { - _startPosY += (int)EntitySeaplane.Step; + _startPosY += (int)EntityPlane.Step; } return true; default: @@ -165,19 +184,16 @@ public class DrawningSeaplane /// Прорисовка объекта /// /// - public void DrawTransport(Graphics g) + public virtual void DrawTransport(Graphics g) { - if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue) + if (EntityPlane == null || !_startPosX.HasValue || !_startPosY.HasValue) { return; } Pen pen = new(Color.Black, 2); - Brush additionalBrush = new SolidBrush(EntitySeaplane.AdditionalColor); - - //Отрисовка основных частей самолёта - Brush br = new SolidBrush(EntitySeaplane.BodyColor); + Brush br = new SolidBrush(EntityPlane.BodyColor); g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 20, 20, 20); g.FillEllipse(br, _startPosX.Value, _startPosY.Value + 20, 20, 20); Point point1 = new Point(_startPosX.Value + 10, _startPosY.Value); @@ -192,7 +208,7 @@ public class DrawningSeaplane g.DrawLine(pen, _startPosX.Value + 10, _startPosY.Value + 20, _startPosX.Value + 40, _startPosY.Value + 20); g.DrawLine(pen, _startPosX.Value + 100, _startPosY.Value + 20, _startPosX.Value + 100, _startPosY.Value + 40); g.DrawLine(pen, _startPosX.Value + 100, _startPosY.Value + 30, _startPosX.Value + 130, _startPosY.Value + 30); - + //Крылья g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 20, 25, 5); g.FillEllipse(br, _startPosX.Value, _startPosY.Value + 20, 25, 5); @@ -212,26 +228,5 @@ public class DrawningSeaplane g.FillEllipse(br, _startPosX.Value + 35, _startPosY.Value + 45, 5, 5); g.FillEllipse(br, _startPosX.Value + 42, _startPosY.Value + 45, 5, 5); g.FillEllipse(br, _startPosX.Value + 87, _startPosY.Value + 45, 5, 5); - - - //Надувнвя лодка - if (EntitySeaplane.Boat) - { - g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 15, 30, 10); - g.FillEllipse(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 15, 30, 10); - - } - - //Поплавки - if (EntitySeaplane.Floats) - { - g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 30, 4, 15); - g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 30, 4, 15); - g.DrawRectangle(pen, _startPosX.Value + 66, _startPosY.Value + 30, 4, 15); - g.FillRectangle(additionalBrush, _startPosX.Value + 66, _startPosY.Value + 30, 4, 15); - g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 40, 70, 10); - g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 40, 70, 10); - - } } -} +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningSeaplane.cs new file mode 100644 index 0000000..7a32c92 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningSeaplane.cs @@ -0,0 +1,55 @@ +using ProjectSeaplane.Entities; +using System.Drawing; + +namespace ProjectSeaplane.Drawnings; +/// +/// Класс, отвечающий за прорисовку и перемещение объекта-сущности +/// +public class DrawningSeaplane : DrawningPlane +{ + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия поплавков + /// Признак наличия лодки + public DrawningSeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool boat) : base(130, 50) + { + EntityPlane = new EntitySeaplane(speed, weight, bodyColor, additionalColor, floats, boat); + } + + public override void DrawTransport(Graphics g) + { + if (EntityPlane == null || EntityPlane is not EntitySeaplane seaplane || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + Pen pen = new(Color.Black, 2); + Brush additionalBrush = new SolidBrush(seaplane.AdditionalColor); + + base.DrawTransport(g); + + //Надувнвя лодка + if (seaplane.Boat) + { + g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 15, 30, 10); + g.FillEllipse(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 15, 30, 10); + + } + + //Поплавки + if (seaplane.Floats) + { + g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 30, 4, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 30, 4, 15); + g.DrawRectangle(pen, _startPosX.Value + 66, _startPosY.Value + 30, 4, 15); + g.FillRectangle(additionalBrush, _startPosX.Value + 66, _startPosY.Value + 30, 4, 15); + g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 40, 70, 10); + g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 40, 70, 10); + } + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntityPlane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntityPlane.cs new file mode 100644 index 0000000..3e3dac9 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntityPlane.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.NetworkInformation; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectSeaplane.Entities; + +/// +/// Класс-сущность "Самолёт" +/// + +public class EntityPlane +{ + /// + /// Скорость + /// + 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 EntityPlane(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs similarity index 66% rename from ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs rename to ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs index 625ccfc..113ec5b 100644 --- a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs @@ -1,24 +1,9 @@ -namespace ProjectSeaplane; +namespace ProjectSeaplane.Entities; /// /// Класс-сущность "Гидросамолёт" /// -public class EntitySeaplane +public class EntitySeaplane : EntityPlane { - /// - /// Скорость - /// - public int Speed { get; private set; } - - /// - /// Вес - /// - public double Weight { get; private set; } - - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } - /// /// Дополнительный цвет (для опциональных элементов) /// @@ -35,11 +20,6 @@ public class EntitySeaplane /// public bool Boat { get; private set; } - /// - /// Шаг перемещения гидросамолёта - /// - public double Step => Speed * 100 / Weight; - /// /// Инициализация полей объекта-класса гидросамолёта /// @@ -49,12 +29,8 @@ public class EntitySeaplane /// Дополнительный цвет /// Признак наличия поплавков /// Признак наличия лодки - public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool floats, bool boat) + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool boat) { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; AdditionalColor = additionalColor; Floats = floats; Boat = boat; diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs index fde1660..59c5859 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs @@ -34,6 +34,7 @@ buttonUp = new Button(); buttonDown = new Button(); buttonRight = new Button(); + buttonCreatePlane = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).BeginInit(); SuspendLayout(); // @@ -51,9 +52,9 @@ buttonCreateSeaplane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonCreateSeaplane.Location = new Point(12, 465); buttonCreateSeaplane.Name = "buttonCreateSeaplane"; - buttonCreateSeaplane.Size = new Size(75, 23); + buttonCreateSeaplane.Size = new Size(196, 23); buttonCreateSeaplane.TabIndex = 1; - buttonCreateSeaplane.Text = "Создать"; + buttonCreateSeaplane.Text = "Создать гидросамолёт"; buttonCreateSeaplane.UseVisualStyleBackColor = true; buttonCreateSeaplane.Click += ButtonCreateSeaplane_Click; // @@ -105,11 +106,23 @@ buttonRight.UseVisualStyleBackColor = true; buttonRight.Click += ButtonMove_Click; // + // buttonCreatePlane + // + buttonCreatePlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreatePlane.Location = new Point(214, 465); + buttonCreatePlane.Name = "buttonCreatePlane"; + buttonCreatePlane.Size = new Size(196, 23); + buttonCreatePlane.TabIndex = 6; + buttonCreatePlane.Text = "Создать самолёт"; + buttonCreatePlane.UseVisualStyleBackColor = true; + buttonCreatePlane.Click += buttonCreatePlane_Click; + // // FormSeaplane // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(900, 500); + Controls.Add(buttonCreatePlane); Controls.Add(buttonRight); Controls.Add(buttonDown); Controls.Add(buttonUp); @@ -130,5 +143,6 @@ private Button buttonUp; private Button buttonDown; private Button buttonRight; + private Button buttonCreatePlane; } } \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs index 8781929..cd79f6d 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs @@ -1,4 +1,6 @@ -namespace ProjectSeaplane; +using ProjectSeaplane.Drawnings; + +namespace ProjectSeaplane; /// /// Форма работы с объектом "Спортивный автомобиль" /// @@ -7,7 +9,7 @@ public partial class FormSeaplane : Form /// /// Поле-объект для прорисовки объекта /// - private DrawningSeaplane? _drawningSeaplane; + private DrawningPlane? _drawningPlane; /// /// Конструктор формы /// @@ -20,33 +22,58 @@ public partial class FormSeaplane : Form /// private void Draw() { - if (_drawningSeaplane == null) + if (_drawningPlane == null) { return; } Bitmap bmp = new(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningSeaplane.DrawTransport(gr); + _drawningPlane.DrawTransport(gr); pictureBoxSeaplane.Image = bmp; } + /// - /// Обработка нажатия кнопки "Создать" + /// Создание объекта класса-перемещения + /// + /// Тип создаваемого объекта + private void CreateObject(string type) + { + Random random = new(); + switch (type) + { + case nameof(DrawningPlane): + _drawningPlane = new DrawningPlane(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(DrawningSeaplane): + _drawningPlane = new DrawningSeaplane(random.Next(100, 300), random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + break; + default: + return; + } + _drawningPlane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); + _drawningPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } + + + /// + /// Обработка нажатия кнопки "Создать гидросамолёт" /// /// /// - private void ButtonCreateSeaplane_Click(object sender, EventArgs e) - { - Random random = new(); - _drawningSeaplane = new DrawningSeaplane(); - - _drawningSeaplane.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))); - _drawningSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); - _drawningSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100)); - Draw(); - } + private void ButtonCreateSeaplane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSeaplane)); + + /// + /// Обработка нажатия кнопки "Создать самолёт" + /// + /// + /// + private void buttonCreatePlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane)); + /// /// Перемещение объекта по форме (нажатие кнопок навигации) /// @@ -54,7 +81,7 @@ public partial class FormSeaplane : Form /// private void ButtonMove_Click(object sender, EventArgs e) { - if (_drawningSeaplane == null) + if (_drawningPlane == null) { return; } @@ -63,20 +90,16 @@ public partial class FormSeaplane : Form switch (name) { case "buttonUp": - result = - _drawningSeaplane.MoveTransport(DirectionType.Up); + result = _drawningPlane.MoveTransport(DirectionType.Up); break; case "buttonDown": - result = - _drawningSeaplane.MoveTransport(DirectionType.Down); + result = _drawningPlane.MoveTransport(DirectionType.Down); break; case "buttonLeft": - result = - _drawningSeaplane.MoveTransport(DirectionType.Left); + result = _drawningPlane.MoveTransport(DirectionType.Left); break; case "buttonRight": - result = - _drawningSeaplane.MoveTransport(DirectionType.Right); + result = _drawningPlane.MoveTransport(DirectionType.Right); break; } if (result) -- 2.25.1 From c2ae9d68b408f1df11282b718a2a469ec27b9890 Mon Sep 17 00:00:00 2001 From: ShuryginDima Date: Mon, 11 Mar 2024 21:10:39 +0300 Subject: [PATCH 5/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D1=80=D0=B0=D1=82=D0=B5=D0=B3?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drawnings/DirectionType.cs | 5 + .../Drawnings/DrawningPlane.cs | 58 +++++--- .../Drawnings/DrawningSeaplane.cs | 1 - .../ProjectSeaplane/Entities/EntityPlane.cs | 11 +- .../Entities/EntitySeaplane.cs | 4 + .../ProjectSeaplane/FormSeaplane.Designer.cs | 28 +++- .../ProjectSeaplane/FormSeaplane.cs | 55 ++++++- .../MovementStrategy/AbstractStrategy.cs | 138 ++++++++++++++++++ .../MovementStrategy/IMoveableObject.cs | 24 +++ .../MovementStrategy/MoveToBorder.cs | 51 +++++++ .../MovementStrategy/MoveToCenter.cs | 50 +++++++ .../MovementStrategy/MoveablePlane.cs | 61 ++++++++ .../MovementStrategy/MovementDirection.cs | 32 ++++ .../MovementStrategy/ObjectParameters.cs | 72 +++++++++ .../MovementStrategy/StrategyStatus.cs | 22 +++ 15 files changed, 577 insertions(+), 35 deletions(-) create mode 100644 ProjectSeaplane/ProjectSeaplane/MovementStrategy/AbstractStrategy.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/MovementStrategy/IMoveableObject.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveToBorder.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveToCenter.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveablePlane.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/MovementStrategy/MovementDirection.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/MovementStrategy/ObjectParameters.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/MovementStrategy/StrategyStatus.cs diff --git a/ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs index 274b265..81916f2 100644 --- a/ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs +++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DirectionType.cs @@ -4,6 +4,11 @@ /// public enum DirectionType { + /// + /// Неизвестное направление + /// + Unknow = -1, + /// /// Вверх /// diff --git a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningPlane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningPlane.cs index 850f600..adb5ead 100644 --- a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningPlane.cs +++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningPlane.cs @@ -1,12 +1,10 @@ using ProjectSeaplane.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ProjectSeaplane.Drawnings; +/// +/// Класс, отвечающий за прорисовку и перемещение базового объекта-сущности +/// public class DrawningPlane { /// @@ -25,25 +23,42 @@ public class DrawningPlane private int? _pictureHeight; /// - /// Левая координата прорисовки гидросамолёта + /// Левая координата прорисовки самолёта /// protected int? _startPosX; /// - /// Верхняя кооридната прорисовки гидросамолёта + /// Верхняя кооридната прорисовки самолёта /// protected int? _startPosY; /// - /// Ширина прорисовки гидросамолёта + /// Ширина прорисовки самолёта /// private readonly int _drawningPlaneWidth = 130; /// - /// Высота прорисовки гидросамолёта + /// Высота прорисовки самолёта /// private readonly int _drawningPlaneHeight = 45; + /// + /// Координата X объекта + /// + public int? GetPosX => _startPosX; + /// + /// Координата Y объекта + /// + public int? GetPosY => _startPosY; + /// + /// Ширина объекта + /// + public int GetWidth => _drawningPlaneWidth; + /// + /// Высота объекта + /// + public int GetHeight => _drawningPlaneHeight; + /// /// Пустой конструктор /// @@ -71,10 +86,10 @@ public class DrawningPlane /// /// Ширина прорисовки гидросамолёта /// Высота прорисовки гидросамолёта - protected DrawningPlane(int _drawningPlaneWidth, int _drawningPlaneHeight) : this() + protected DrawningPlane(int drawningPlaneWidth, int drawningPlaneHeight) : this() { _drawningPlaneWidth = drawningPlaneWidth; - _pictureHeight = drawningPlaneHeight; + _drawningPlaneHeight = drawningPlaneHeight; } /// @@ -86,18 +101,16 @@ public class DrawningPlane public bool SetPictureSize(int width, int height) { - - if (height < _drawningSeaplaneHeight || width < _drawningSeaplaneWidth) + if (height < _drawningPlaneHeight || width < _drawningPlaneWidth) { return false; } - _pictureWidth = width; _pictureHeight = height; - if (_startPosX.HasValue && _drawningSeaplaneWidth + _startPosX > width) _startPosX = _pictureWidth - _drawningSeaplaneWidth; - if (_startPosY.HasValue && _drawningSeaplaneHeight + _startPosY > height) _startPosY = _pictureHeight - _drawningSeaplaneHeight; + if (_startPosX.HasValue && _drawningPlaneWidth + _startPosX > width) _startPosX = _pictureWidth - _drawningPlaneWidth; + if (_startPosY.HasValue && _drawningPlaneHeight + _startPosY > height) _startPosY = _pictureHeight - _drawningPlaneHeight; return true; } @@ -116,17 +129,17 @@ public class DrawningPlane { x = 0; } - if (x + _drawningSeaplaneWidth > _pictureWidth.Value) + if (x + _drawningPlaneWidth > _pictureWidth.Value) { - x = _pictureWidth.Value - _drawningSeaplaneWidth; + x = _pictureWidth.Value - _drawningPlaneWidth; } if (y < 0) { y = 0; } - if (y + _drawningSeaplaneHeight > _pictureHeight.Value) + if (y + _drawningPlaneHeight > _pictureHeight.Value) { - y = _pictureHeight.Value - _drawningSeaplaneHeight; + y = _pictureHeight.Value - _drawningPlaneHeight; } _startPosX = x; @@ -163,7 +176,7 @@ public class DrawningPlane return true; // вправо case DirectionType.Right: - if (_startPosX.Value + _drawningSeaplaneWidth + EntityPlane.Step < _pictureWidth) + if (_startPosX.Value + _drawningPlaneWidth + EntityPlane.Step < _pictureWidth) { _startPosX += (int)EntityPlane.Step; } @@ -171,7 +184,7 @@ public class DrawningPlane //вниз case DirectionType.Down: - if (_startPosY.Value + _drawningSeaplaneHeight + EntityPlane.Step < _pictureHeight) + if (_startPosY.Value + _drawningPlaneHeight + EntityPlane.Step < _pictureHeight) { _startPosY += (int)EntityPlane.Step; } @@ -180,6 +193,7 @@ public class DrawningPlane return false; } } + /// /// Прорисовка объекта /// diff --git a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningSeaplane.cs index 7a32c92..68f7500 100644 --- a/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/Drawnings/DrawningSeaplane.cs @@ -1,5 +1,4 @@ using ProjectSeaplane.Entities; -using System.Drawing; namespace ProjectSeaplane.Drawnings; /// diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntityPlane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntityPlane.cs index 3e3dac9..f8fc121 100644 --- a/ProjectSeaplane/ProjectSeaplane/Entities/EntityPlane.cs +++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntityPlane.cs @@ -1,17 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.NetworkInformation; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectSeaplane.Entities; +namespace ProjectSeaplane.Entities; /// /// Класс-сущность "Самолёт" /// - public class EntityPlane { /// diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs index 113ec5b..de0ade8 100644 --- a/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs @@ -4,6 +4,10 @@ /// public class EntitySeaplane : EntityPlane { + public EntitySeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool boat) : base(speed, weight, bodyColor) + { + } + /// /// Дополнительный цвет (для опциональных элементов) /// diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs index 59c5859..e8589d4 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs @@ -35,6 +35,8 @@ buttonDown = new Button(); buttonRight = new Button(); buttonCreatePlane = new Button(); + comboBoxStrategy = new ComboBox(); + buttonStrategyStep = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).BeginInit(); SuspendLayout(); // @@ -115,13 +117,35 @@ buttonCreatePlane.TabIndex = 6; buttonCreatePlane.Text = "Создать самолёт"; buttonCreatePlane.UseVisualStyleBackColor = true; - buttonCreatePlane.Click += buttonCreatePlane_Click; + buttonCreatePlane.Click += ButtonCreatePlane_Click; + // + // comboBoxStrategy + // + comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStrategy.FormattingEnabled = true; + comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" }); + comboBoxStrategy.Location = new Point(763, 12); + comboBoxStrategy.Name = "comboBoxStrategy"; + comboBoxStrategy.Size = new Size(121, 23); + comboBoxStrategy.TabIndex = 7; + // + // buttonStrategyStep + // + buttonStrategyStep.Location = new Point(808, 41); + buttonStrategyStep.Name = "buttonStrategyStep"; + buttonStrategyStep.Size = new Size(75, 23); + buttonStrategyStep.TabIndex = 8; + buttonStrategyStep.Text = "Шаг"; + buttonStrategyStep.UseVisualStyleBackColor = true; + buttonStrategyStep.Click += ButtonStrategyStep_Click; // // FormSeaplane // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(900, 500); + Controls.Add(buttonStrategyStep); + Controls.Add(comboBoxStrategy); Controls.Add(buttonCreatePlane); Controls.Add(buttonRight); Controls.Add(buttonDown); @@ -144,5 +168,7 @@ private Button buttonDown; private Button buttonRight; private Button buttonCreatePlane; + private ComboBox comboBoxStrategy; + private Button buttonStrategyStep; } } \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs index cd79f6d..566db95 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs @@ -1,4 +1,5 @@ using ProjectSeaplane.Drawnings; +using ProjectSeaplane.MovementStrategy; namespace ProjectSeaplane; /// @@ -10,13 +11,21 @@ public partial class FormSeaplane : Form /// Поле-объект для прорисовки объекта /// private DrawningPlane? _drawningPlane; + + /// + /// Стратегия перемещения + /// + private AbstractStrategy? _strategy; + /// /// Конструктор формы /// public FormSeaplane() { InitializeComponent(); + _strategy = null; } + /// /// Метод прорисовки машины /// @@ -56,6 +65,9 @@ public partial class FormSeaplane : Form } _drawningPlane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); _drawningPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); + _strategy = null; + comboBoxStrategy.Enabled = true; + Draw(); } @@ -72,7 +84,7 @@ public partial class FormSeaplane : Form /// /// /// - private void buttonCreatePlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane)); + private void ButtonCreatePlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane)); /// /// Перемещение объекта по форме (нажатие кнопок навигации) @@ -107,4 +119,45 @@ public partial class FormSeaplane : Form Draw(); } } + + /// + /// Обработка нажатия кнопки "Шаг" + /// + /// + /// + private void ButtonStrategyStep_Click(object sender, EventArgs e) + { + if (_drawningPlane == null) + { + return; + } + if (comboBoxStrategy.Enabled) + { + _strategy = comboBoxStrategy.SelectedIndex switch + { + 0 => new MoveToCenter(), + 1 => new MoveToBorder(), + _ => null, + }; + if (_strategy == null) + { + return; + } + _strategy.SetData(new MoveablePlane(_drawningPlane), pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); + } + if (_strategy == null) + { + return; + } + + comboBoxStrategy.Enabled = false; + _strategy.MakeStep(); + Draw(); + + if (_strategy.GetStatus() == StrategyStatus.Finish) + { + comboBoxStrategy.Enabled = true; + _strategy = null; + } + } } diff --git a/ProjectSeaplane/ProjectSeaplane/MovementStrategy/AbstractStrategy.cs b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/AbstractStrategy.cs new file mode 100644 index 0000000..2750643 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/AbstractStrategy.cs @@ -0,0 +1,138 @@ +namespace ProjectSeaplane.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 (IsTargetDestinaion()) + { + _state = StrategyStatus.Finish; + return; + } + + MoveToTarget(); + } + + /// + /// Перемещение влево + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveLeft() => MoveTo(MovementDirection.Left); + + /// + /// Перемещение вправо + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveRight() => MoveTo(MovementDirection.Right); + + /// + /// Перемещение вверх + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveUp() => MoveTo(MovementDirection.Up); + + /// + /// Перемещение вниз + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveDown() => MoveTo(MovementDirection.Down); + + /// + /// Параметры объекта + /// + protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition; + + /// + /// Шаг объекта + /// + /// + protected int? GetStep() + { + if (_state != StrategyStatus.InProgress) + { + return null; + } + return _moveableObject?.GetStep; + } + + /// + /// Перемещение к цели + /// + protected abstract void MoveToTarget(); + + /// + /// Достигнута ли цель + /// + /// + protected abstract bool IsTargetDestinaion(); + + /// + /// Попытка перемещения в требуемом направлении + /// + /// Направление + /// Результат попытки (true - удалось переместиться, false - неудача) + private bool MoveTo(MovementDirection movementDirection) + { + if (_state != StrategyStatus.InProgress) + { + return false; + } + return _moveableObject?.TryMoveObject(movementDirection) ?? false; + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/MovementStrategy/IMoveableObject.cs b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/IMoveableObject.cs new file mode 100644 index 0000000..2e61bb1 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/IMoveableObject.cs @@ -0,0 +1,24 @@ +namespace ProjectSeaplane.MovementStrategy; + +/// +/// Интерфейс для работы с перемещаемым объектом +/// +public interface IMoveableObject +{ + /// + /// Получение координаты объекта + /// + ObjectParameters? GetObjectPosition { get; } + + /// + /// Шаг объекта + /// + int GetStep { get; } + + /// + /// Попытка переместить объект в указанном направлении + /// + /// Направление + /// true - объект перемещен, false - перемещение невозможно + bool TryMoveObject(MovementDirection direction); +} diff --git a/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveToBorder.cs b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveToBorder.cs new file mode 100644 index 0000000..2b3c748 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveToBorder.cs @@ -0,0 +1,51 @@ +namespace ProjectSeaplane.MovementStrategy; + +/// +/// Стратегия перемещения объекта в угол экрана +/// + +public class MoveToBorder : AbstractStrategy +{ + protected override bool IsTargetDestinaion() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder + GetStep() >= FieldHeight; + } + + protected override void MoveToTarget() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + int diffX = objParams.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(); + } + } + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveToCenter.cs b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveToCenter.cs new file mode 100644 index 0000000..12012c2 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveToCenter.cs @@ -0,0 +1,50 @@ +namespace ProjectSeaplane.MovementStrategy; + +/// +/// Стратегия перемещения объекта в центр экрана +/// +public class MoveToCenter : AbstractStrategy +{ + protected override bool IsTargetDestinaion() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; + } + protected override void MoveToTarget() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveablePlane.cs b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveablePlane.cs new file mode 100644 index 0000000..e9852e1 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MoveablePlane.cs @@ -0,0 +1,61 @@ +using ProjectSeaplane.Drawnings; + +namespace ProjectSeaplane.MovementStrategy; + +/// +/// Класс-реализация IMoveableObject с использованием DrawningPlane +/// +public class MoveablePlane : IMoveableObject +{ + /// + /// Поле-объект класса DrawningPlane или его наследника + /// + private readonly DrawningPlane? _plane = null; + + /// + /// Конструктор + /// + /// Объект класса DrawningPlane + public MoveablePlane(DrawningPlane plane) + { + _plane = plane; + } + public ObjectParameters? GetObjectPosition + { + get + { + if (_plane == null || _plane.EntityPlane == null || !_plane.GetPosX.HasValue || !_plane.GetPosY.HasValue) + { + return null; + } + return new ObjectParameters(_plane.GetPosX.Value, _plane.GetPosY.Value, _plane.GetWidth, _plane.GetHeight); + } + } + public int GetStep => (int)(_plane?.EntityPlane?.Step ?? 0); + public bool TryMoveObject(MovementDirection direction) + { + if (_plane == null || _plane.EntityPlane == null) + { + return false; + } + return _plane.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/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MovementDirection.cs b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MovementDirection.cs new file mode 100644 index 0000000..07ff2e8 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/MovementDirection.cs @@ -0,0 +1,32 @@ +namespace ProjectSeaplane.MovementStrategy; + +/// +/// Направление перемещения +/// +public enum MovementDirection +{ + /// + /// Неизвестное направление + /// + Unknow = -1, + + /// + /// Вверх + /// + Up = 1, + + /// + /// Вниз + /// + Down = 2, + + /// + /// Влево + /// + Left = 3, + + /// + /// Вправо + /// + Right = 4 +} diff --git a/ProjectSeaplane/ProjectSeaplane/MovementStrategy/ObjectParameters.cs b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/ObjectParameters.cs new file mode 100644 index 0000000..ba982d9 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/ObjectParameters.cs @@ -0,0 +1,72 @@ +namespace ProjectSeaplane.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/ProjectSeaplane/ProjectSeaplane/MovementStrategy/StrategyStatus.cs b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/StrategyStatus.cs new file mode 100644 index 0000000..020c989 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/MovementStrategy/StrategyStatus.cs @@ -0,0 +1,22 @@ +namespace ProjectSeaplane.MovementStrategy; + +/// +/// Статус выполнения операции перемещения +/// +public enum StrategyStatus +{ + /// + /// Все готово к началу + /// + NotInit, + + /// + /// Выполняется + /// + InProgress, + + /// + /// Завершено + /// + Finish +} -- 2.25.1 From bc3d9cac6b784b9dc58eab01997d7880407bfa0d Mon Sep 17 00:00:00 2001 From: ShuryginDima Date: Wed, 13 Mar 2024 17:43:14 +0300 Subject: [PATCH 6/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs index de0ade8..e97ba9c 100644 --- a/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/Entities/EntitySeaplane.cs @@ -4,10 +4,6 @@ /// public class EntitySeaplane : EntityPlane { - public EntitySeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool boat) : base(speed, weight, bodyColor) - { - } - /// /// Дополнительный цвет (для опциональных элементов) /// @@ -33,7 +29,7 @@ public class EntitySeaplane : EntityPlane /// Дополнительный цвет /// Признак наличия поплавков /// Признак наличия лодки - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool boat) + public EntitySeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool boat) : base(speed, weight, bodyColor) { AdditionalColor = additionalColor; Floats = floats; -- 2.25.1 From 34ea2c9158ba678f95cf7dab8dfa67f1d5aa70c5 Mon Sep 17 00:00:00 2001 From: ShuryginDima Date: Sun, 24 Mar 2024 09:38:55 +0300 Subject: [PATCH 7/9] =?UTF-8?q?=D0=9A=D0=BE=D0=BB=D0=BB=D0=B5=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ICollectionGenericObjects.cs | 48 +++++++++ .../MassiveGenericObjects.cs | 99 +++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs new file mode 100644 index 0000000..034dbfa --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -0,0 +1,48 @@ +namespace ProjectSeaplane.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/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs new file mode 100644 index 0000000..e970588 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs @@ -0,0 +1,99 @@ +namespace ProjectSeaplane.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 _collection[position]; + } + else + { + return null; + } + } + + public bool Insert(T obj) + { + for (int i = 0; i < Count; ++i) + { + if (_collection[i] == null) + { + _collection[i] = obj; + return i; + } + } + return -1; + } + + public bool Insert(T obj, int position) + { + for (int i = position; i < Count; i++) + { + if (_collection[i] == null) + { + _collection[i] = obj; + return i; + } + } + for (int i = position - 1; i >= 0; --i) + { + if (_collection[i] == null) + { + _collection[i] = obj; + return i; + } + } + return -1; + } + + public bool Remove(int position) + { + if (position < 0 || position >= _collection.Count()) return null; + if (_collection[position] != null) + { + T obj = _collection[position]; + _collection[position] = null; + return obj; + + } + return null; + } +} \ No newline at end of file -- 2.25.1 From 96ea01165a546486a16142c89e2bb7f2b3705681 Mon Sep 17 00:00:00 2001 From: ShuryginDima Date: Wed, 27 Mar 2024 15:43:21 +0300 Subject: [PATCH 8/9] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BF=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 123 ++++++++++++ .../ICollectionGenericObjects.cs | 6 +- .../MassiveGenericObjects.cs | 19 +- .../PlaneSharingService.cs | 66 +++++++ .../FormPlaneCollection.Designer.cs | 173 ++++++++++++++++ .../ProjectSeaplane/FormPlaneCollection.cs | 186 ++++++++++++++++++ .../ProjectSeaplane/FormPlaneCollection.resx | 120 +++++++++++ .../ProjectSeaplane/FormSeaplane.Designer.cs | 40 +--- .../ProjectSeaplane/FormSeaplane.cs | 65 ++---- ProjectSeaplane/ProjectSeaplane/Program.cs | 2 +- 10 files changed, 710 insertions(+), 90 deletions(-) create mode 100644 ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/PlaneSharingService.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.resx diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs new file mode 100644 index 0000000..77409f4 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs @@ -0,0 +1,123 @@ +using ProjectSeaplane.Drawnings; + +namespace ProjectSeaplane.CollectionGenericObjects; + +/// +/// Абстракция компании, хранящий коллекцию самолётов +/// +public abstract class AbstractCompany +{ + /// + /// Размер места (ширина) + /// + protected readonly int _placeSizeWidth = 140; + + /// + /// Размер места (высота) + /// + protected readonly int _placeSizeHeight = 60; + + /// + /// Ширина окна + /// + 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 int operator +(AbstractCompany company, DrawningPlane plane) + { + if (company._collection == null) + { + return -1; + } + return company._collection.Insert(plane); + } + + /// + /// Перегрузка оператора удаления для класса + /// + /// Компания + /// Номер удаляемого объекта + /// + public static DrawningPlane operator -(AbstractCompany company, int position) + { + if (company._collection == null) + { + return null; + } + return company._collection.Remove(position); + } + + /// + /// Получение случайного объекта из коллекции + /// + /// + public DrawningPlane? 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) + { + DrawningPlane? 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/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs index 034dbfa..63be330 100644 --- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -22,7 +22,7 @@ public interface ICollectionGenericObjects /// /// Добавляемый объект /// true - вставка прошла удачно, false - вставка не удалась - bool Insert(T obj); + int Insert(T obj); /// /// Добавление объекта в коллекцию на конкретную позицию @@ -30,14 +30,14 @@ public interface ICollectionGenericObjects /// Добавляемый объект /// Позиция /// 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/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs index e970588..405596c 100644 --- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs @@ -1,17 +1,21 @@ -namespace ProjectSeaplane.CollectionGenericObjects; +using ProjectSeaplane.Drawnings; + +namespace ProjectSeaplane.CollectionGenericObjects; /// /// Параметризованный набор объектов /// /// Параметр: ограничение - ссылочный тип public class MassiveGenericObjects : ICollectionGenericObjects -where T : class + where T : class { /// /// Массив объектов, которые храним /// private T?[] _collection; + public int Count => _collection.Length; + public int SetMaxCount { set @@ -50,7 +54,7 @@ where T : class } } - public bool Insert(T obj) + public int Insert(T obj) { for (int i = 0; i < Count; ++i) { @@ -63,7 +67,7 @@ where T : class return -1; } - public bool Insert(T obj, int position) + public int Insert(T obj, int position) { for (int i = position; i < Count; i++) { @@ -84,9 +88,12 @@ where T : class return -1; } - public bool Remove(int position) + public T? Remove(int position) { - if (position < 0 || position >= _collection.Count()) return null; + if (position < 0 || position >= _collection.Count()) + { + return null; + } if (_collection[position] != null) { T obj = _collection[position]; diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/PlaneSharingService.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/PlaneSharingService.cs new file mode 100644 index 0000000..6e80060 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/PlaneSharingService.cs @@ -0,0 +1,66 @@ +using ProjectSeaplane.Drawnings; + +namespace ProjectSeaplane.CollectionGenericObjects; + +/// +/// Реализация абстрактной компании - плейншеринг +/// +public class PlaneSharingService : AbstractCompany +{ + private List> locCoord = new List>(); + private int countInRow; + private int countRow; + + /// + /// Конструктор + /// + /// + /// + /// + public PlaneSharingService(int picWidth, int picHeight, ICollectionGenericObjects? collection) : base(picWidth, picHeight, collection) + { + } + + protected override void DrawBackgound(Graphics g) + { + Pen pen = new Pen(Color.Brown); + int x = 1, y = 0; + while (y + _placeSizeHeight <= _pictureHeight) + { + int count = 0; + while (x + _placeSizeWidth <= _pictureWidth) + { + count++; + g.DrawLine(pen, x, y, x + _placeSizeWidth, y); + g.DrawLine(pen, x, y, x, y + _placeSizeHeight); + g.DrawLine(pen, x, y + _placeSizeHeight, x + _placeSizeWidth, y + _placeSizeHeight); + g.DrawLine(pen, x + _placeSizeWidth, y + _placeSizeHeight, x + _placeSizeWidth, y); + locCoord.Add(new Tuple(x, y)); + x += _placeSizeWidth + 2; + } + countInRow = count; + x = 1; + y += _placeSizeHeight + 5; + countRow++; + } + } + + protected override void SetObjectsPosition() + { + if (locCoord == null || _collection == null) + { + return; + } + int row = countRow, col = 1; + for (int i = 0; i < _collection?.Count; i++, col++) + { + _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); + _collection?.Get(i)?.SetPosition(locCoord[row * countInRow - col].Item1 + 5, locCoord[row * countInRow - col].Item2 + 5); + if (col == countInRow) + { + col = 0; + row--; + } + } + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs new file mode 100644 index 0000000..c25addc --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs @@ -0,0 +1,173 @@ +namespace ProjectSeaplane +{ + partial class FormPlaneCollection + { + /// + /// 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(); + buttonRemovePlane = new Button(); + maskedTextBoxPosition = new MaskedTextBox(); + buttonAddSeaplane = new Button(); + buttonAddPlane = 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(buttonRemovePlane); + groupBoxTools.Controls.Add(maskedTextBoxPosition); + groupBoxTools.Controls.Add(buttonAddSeaplane); + groupBoxTools.Controls.Add(buttonAddPlane); + groupBoxTools.Controls.Add(comboBoxSelectorCompany); + groupBoxTools.Dock = DockStyle.Right; + groupBoxTools.Location = new Point(710, 0); + groupBoxTools.Name = "groupBoxTools"; + groupBoxTools.Size = new Size(144, 529); + groupBoxTools.TabIndex = 0; + groupBoxTools.TabStop = false; + groupBoxTools.Text = "Инструменты"; + // + // buttonRefresh + // + buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRefresh.Location = new Point(6, 429); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(126, 44); + 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(6, 346); + buttonGoToCheck.Name = "buttonGoToCheck"; + buttonGoToCheck.Size = new Size(126, 44); + buttonGoToCheck.TabIndex = 5; + buttonGoToCheck.Text = "Передать на тесты"; + buttonGoToCheck.UseVisualStyleBackColor = true; + buttonGoToCheck.Click += ButtonGoToCheck_Click; + // + // buttonRemovePlane + // + buttonRemovePlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonRemovePlane.Location = new Point(6, 265); + buttonRemovePlane.Name = "buttonRemovePlane"; + buttonRemovePlane.Size = new Size(126, 44); + buttonRemovePlane.TabIndex = 4; + buttonRemovePlane.Text = "Удалить самолёт"; + buttonRemovePlane.UseVisualStyleBackColor = true; + buttonRemovePlane.Click += ButtonRemovePlane_Click; + // + // maskedTextBoxPosition + // + maskedTextBoxPosition.Location = new Point(6, 208); + maskedTextBoxPosition.Mask = "00"; + maskedTextBoxPosition.Name = "maskedTextBoxPosition"; + maskedTextBoxPosition.Size = new Size(126, 23); + maskedTextBoxPosition.TabIndex = 3; + maskedTextBoxPosition.ValidatingType = typeof(int); + // + // buttonAddSeaplane + // + buttonAddSeaplane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddSeaplane.Location = new Point(6, 126); + buttonAddSeaplane.Name = "buttonAddSeaplane"; + buttonAddSeaplane.Size = new Size(126, 44); + buttonAddSeaplane.TabIndex = 2; + buttonAddSeaplane.Text = "Добавление гидросамолёта"; + buttonAddSeaplane.UseVisualStyleBackColor = true; + buttonAddSeaplane.Click += ButtonAddSeaplane_Click; + // + // buttonAddPlane + // + buttonAddPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonAddPlane.Location = new Point(6, 78); + buttonAddPlane.Name = "buttonAddPlane"; + buttonAddPlane.Size = new Size(126, 42); + buttonAddPlane.TabIndex = 1; + buttonAddPlane.Text = "Добавление самолёта"; + buttonAddPlane.UseVisualStyleBackColor = true; + buttonAddPlane.Click += ButtonAddPlane_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(6, 22); + comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; + comboBoxSelectorCompany.Size = new Size(126, 23); + 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(710, 529); + pictureBox.TabIndex = 1; + pictureBox.TabStop = false; + // + // FormPlaneCollection + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(854, 529); + Controls.Add(pictureBox); + Controls.Add(groupBoxTools); + Name = "FormPlaneCollection"; + Text = "Коллекция самолётов"; + groupBoxTools.ResumeLayout(false); + groupBoxTools.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxTools; + private ComboBox comboBoxSelectorCompany; + private Button buttonAddPlane; + private Button buttonAddSeaplane; + private Button buttonRemovePlane; + private MaskedTextBox maskedTextBoxPosition; + private PictureBox pictureBox; + private Button buttonRefresh; + private Button buttonGoToCheck; + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs new file mode 100644 index 0000000..d6367d8 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs @@ -0,0 +1,186 @@ +using ProjectSeaplane.CollectionGenericObjects; +using ProjectSeaplane.Drawnings; + +namespace ProjectSeaplane; + +/// +/// Форма работы с компанией и её коллекцией +/// +public partial class FormPlaneCollection : Form +{ + /// + /// Компания + /// + private AbstractCompany? _company = null; + + /// + /// Конструктор + /// + public FormPlaneCollection() + { + InitializeComponent(); + } + + /// + /// Выбор компании + /// + /// + /// + private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboBoxSelectorCompany.Text) + { + case "Хранилище": + _company = new PlaneSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); + break; + } + } + + /// + /// Добавление обычного самолёта + /// + /// + /// + private void ButtonAddPlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane)); + + /// + /// Добавление гидросамолёта + /// + /// + /// + private void ButtonAddSeaplane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSeaplane)); + + /// + /// Создание объекта класса-перемещения + /// + /// Тип создаваемого объекта + private void CreateObject(string type) + { + if (_company == null) + { + return; + } + + Random random = new(); + DrawningPlane _drawningPlane; + switch (type) + { + case nameof(DrawningPlane): + _drawningPlane = new DrawningPlane(random.Next(100, 300), random.Next(1000, 3000), GetColor(random)); + break; + case nameof(DrawningSeaplane): + _drawningPlane = new DrawningSeaplane(random.Next(100, 300), random.Next(1000, 3000), + GetColor(random), + GetColor(random), + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); + break; + default: + return; + } + + if ((_company + _drawningPlane) != -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 ButtonRemovePlane_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; + } + + DrawningPlane? plane = null; + int counter = 100; + while (plane == null) + { + plane = _company.GetRandomObject(); + counter--; + if (counter <= 0) + { + break; + } + } + + if (plane == null) + { + return; + } + + FormSeaplane form = new FormSeaplane(); + form.SetPlane = plane; + form.ShowDialog(); + } + + /// + /// Перерисовка коллекции + /// + /// + /// + private void ButtonRefresh_Click(object sender, EventArgs e) + { + if (_company == null) + { + return; + } + + pictureBox.Image = _company.Show(); + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.resx b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.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/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs index e8589d4..0015250 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.Designer.cs @@ -29,12 +29,10 @@ private void InitializeComponent() { pictureBoxSeaplane = new PictureBox(); - buttonCreateSeaplane = new Button(); buttonLeft = new Button(); buttonUp = new Button(); buttonDown = new Button(); buttonRight = new Button(); - buttonCreatePlane = new Button(); comboBoxStrategy = new ComboBox(); buttonStrategyStep = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).BeginInit(); @@ -45,27 +43,16 @@ pictureBoxSeaplane.Dock = DockStyle.Fill; pictureBoxSeaplane.Location = new Point(0, 0); pictureBoxSeaplane.Name = "pictureBoxSeaplane"; - pictureBoxSeaplane.Size = new Size(900, 500); + pictureBoxSeaplane.Size = new Size(900, 517); pictureBoxSeaplane.TabIndex = 0; pictureBoxSeaplane.TabStop = false; // - // buttonCreateSeaplane - // - buttonCreateSeaplane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreateSeaplane.Location = new Point(12, 465); - buttonCreateSeaplane.Name = "buttonCreateSeaplane"; - buttonCreateSeaplane.Size = new Size(196, 23); - buttonCreateSeaplane.TabIndex = 1; - buttonCreateSeaplane.Text = "Создать гидросамолёт"; - buttonCreateSeaplane.UseVisualStyleBackColor = true; - buttonCreateSeaplane.Click += ButtonCreateSeaplane_Click; - // // buttonLeft // buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonLeft.BackgroundImage = Properties.Resources.arrow_left; buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; - buttonLeft.Location = new Point(768, 451); + buttonLeft.Location = new Point(768, 468); buttonLeft.Name = "buttonLeft"; buttonLeft.Size = new Size(35, 35); buttonLeft.TabIndex = 2; @@ -77,7 +64,7 @@ buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonUp.BackgroundImage = Properties.Resources.arrow_up; buttonUp.BackgroundImageLayout = ImageLayout.Stretch; - buttonUp.Location = new Point(808, 411); + buttonUp.Location = new Point(808, 428); buttonUp.Name = "buttonUp"; buttonUp.Size = new Size(35, 35); buttonUp.TabIndex = 3; @@ -89,7 +76,7 @@ buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonDown.BackgroundImage = Properties.Resources.arrow_down; buttonDown.BackgroundImageLayout = ImageLayout.Stretch; - buttonDown.Location = new Point(808, 451); + buttonDown.Location = new Point(808, 468); buttonDown.Name = "buttonDown"; buttonDown.Size = new Size(35, 35); buttonDown.TabIndex = 4; @@ -101,24 +88,13 @@ buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonRight.BackgroundImage = Properties.Resources.arrow_right; buttonRight.BackgroundImageLayout = ImageLayout.Stretch; - buttonRight.Location = new Point(849, 451); + buttonRight.Location = new Point(849, 468); buttonRight.Name = "buttonRight"; buttonRight.Size = new Size(35, 35); buttonRight.TabIndex = 5; buttonRight.UseVisualStyleBackColor = true; buttonRight.Click += ButtonMove_Click; // - // buttonCreatePlane - // - buttonCreatePlane.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreatePlane.Location = new Point(214, 465); - buttonCreatePlane.Name = "buttonCreatePlane"; - buttonCreatePlane.Size = new Size(196, 23); - buttonCreatePlane.TabIndex = 6; - buttonCreatePlane.Text = "Создать самолёт"; - buttonCreatePlane.UseVisualStyleBackColor = true; - buttonCreatePlane.Click += ButtonCreatePlane_Click; - // // comboBoxStrategy // comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; @@ -143,15 +119,13 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(900, 500); + ClientSize = new Size(900, 517); Controls.Add(buttonStrategyStep); Controls.Add(comboBoxStrategy); - Controls.Add(buttonCreatePlane); Controls.Add(buttonRight); Controls.Add(buttonDown); Controls.Add(buttonUp); Controls.Add(buttonLeft); - Controls.Add(buttonCreateSeaplane); Controls.Add(pictureBoxSeaplane); Name = "FormSeaplane"; Text = "Гидросамолёт"; @@ -162,12 +136,10 @@ #endregion private PictureBox pictureBoxSeaplane; - private Button buttonCreateSeaplane; private Button buttonLeft; private Button buttonUp; private Button buttonDown; private Button buttonRight; - private Button buttonCreatePlane; private ComboBox comboBoxStrategy; private Button buttonStrategyStep; } diff --git a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs index 566db95..ff242e0 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormSeaplane.cs @@ -2,6 +2,7 @@ using ProjectSeaplane.MovementStrategy; namespace ProjectSeaplane; + /// /// Форма работы с объектом "Спортивный автомобиль" /// @@ -17,6 +18,21 @@ public partial class FormSeaplane : Form /// private AbstractStrategy? _strategy; + /// + /// Получение объекта + /// + public DrawningPlane SetPlane + { + set + { + _drawningPlane = value; + _drawningPlane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); + comboBoxStrategy.Enabled = true; + _strategy = null; + Draw(); + } + } + /// /// Конструктор формы /// @@ -27,7 +43,7 @@ public partial class FormSeaplane : Form } /// - /// Метод прорисовки машины + /// Метод прорисовки самолёта /// private void Draw() { @@ -41,51 +57,6 @@ public partial class FormSeaplane : Form pictureBoxSeaplane.Image = bmp; } - /// - /// Создание объекта класса-перемещения - /// - /// Тип создаваемого объекта - private void CreateObject(string type) - { - Random random = new(); - switch (type) - { - case nameof(DrawningPlane): - _drawningPlane = new DrawningPlane(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(DrawningSeaplane): - _drawningPlane = new DrawningSeaplane(random.Next(100, 300), random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); - break; - default: - return; - } - _drawningPlane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); - _drawningPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); - _strategy = null; - comboBoxStrategy.Enabled = true; - - Draw(); - } - - - /// - /// Обработка нажатия кнопки "Создать гидросамолёт" - /// - /// - /// - private void ButtonCreateSeaplane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSeaplane)); - - /// - /// Обработка нажатия кнопки "Создать самолёт" - /// - /// - /// - private void ButtonCreatePlane_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlane)); - /// /// Перемещение объекта по форме (нажатие кнопок навигации) /// @@ -131,6 +102,7 @@ public partial class FormSeaplane : Form { return; } + if (comboBoxStrategy.Enabled) { _strategy = comboBoxStrategy.SelectedIndex switch @@ -145,6 +117,7 @@ public partial class FormSeaplane : Form } _strategy.SetData(new MoveablePlane(_drawningPlane), pictureBoxSeaplane.Width, pictureBoxSeaplane.Height); } + if (_strategy == null) { return; diff --git a/ProjectSeaplane/ProjectSeaplane/Program.cs b/ProjectSeaplane/ProjectSeaplane/Program.cs index 4e58da8..0b08fb7 100644 --- a/ProjectSeaplane/ProjectSeaplane/Program.cs +++ b/ProjectSeaplane/ProjectSeaplane/Program.cs @@ -11,7 +11,7 @@ namespace ProjectSeaplane // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormSeaplane()); + Application.Run(new FormPlaneCollection()); } } } \ No newline at end of file -- 2.25.1 From 1a801f926fe3282fe412c7e26cb694acb78e1fde Mon Sep 17 00:00:00 2001 From: ShuryginDima Date: Mon, 8 Apr 2024 15:56:17 +0300 Subject: [PATCH 9/9] =?UTF-8?q?4=20=D0=BB=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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionType.cs | 22 +++ .../ListGenericObjects.cs | 60 ++++++ .../MassiveGenericObjects.cs | 20 +- .../StorageCollection.cs | 85 +++++++++ .../FormPlaneCollection.Designer.cs | 178 +++++++++++++++--- .../ProjectSeaplane/FormPlaneCollection.cs | 108 ++++++++++- 6 files changed, 431 insertions(+), 42 deletions(-) create mode 100644 ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/CollectionType.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/CollectionType.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/CollectionType.cs new file mode 100644 index 0000000..de79c68 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/CollectionType.cs @@ -0,0 +1,22 @@ +namespace ProjectSeaplane.CollectionGenericObjects; + +/// +/// Тип коллекции +/// +public enum CollectionType +{ + /// + /// Неопределено + /// + None = 0, + + /// + /// Массив + /// + Massive = 1, + + /// + /// Список + /// + List = 2 +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs new file mode 100644 index 0000000..3e94174 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs @@ -0,0 +1,60 @@ +namespace ProjectSeaplane.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 < 0 || position > _collection.Count) + { + return null; + } + return _collection[position]; + } + public int Insert(T obj) + { + return Insert(obj, _collection.Count); + } + public int Insert(T obj, int position) + { + if (_maxCount == _collection.Count || position < 0 || position > _collection.Count) + { + return -1; + } + _collection.Insert(position, obj); + return _collection.Count; + } + public T? Remove(int position) + { + if (position < 0 || position > _collection.Count) + { + return null; + } + T obj = _collection[position]; + _collection.RemoveAt(position); + return obj; + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs index 405596c..840ea93 100644 --- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs @@ -56,19 +56,21 @@ public class MassiveGenericObjects : ICollectionGenericObjects public int Insert(T obj) { - for (int i = 0; i < Count; ++i) - { - if (_collection[i] == null) - { - _collection[i] = obj; - return i; - } - } - return -1; + return Insert(obj, 0); } public int Insert(T obj, int position) { + if (position < 0 || position >= Count) + { + return -1; + } + if (_collection[position] == null) + { + _collection[position] = obj; + return position; + } + for (int i = position; i < Count; i++) { if (_collection[i] == null) diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs new file mode 100644 index 0000000..5950c32 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs @@ -0,0 +1,85 @@ +namespace ProjectSeaplane.CollectionGenericObjects; + +/// +/// Класс-хранилище коллекций +/// +/// +public class StorageCollection + where T : class +{ + /// + /// Словарь (хранилище) с коллекциями + /// + readonly Dictionary> _storage; + + /// + /// Возвращение списка названий коллекций + /// + public List Keys => _storage.Keys.ToList(); + + /// + /// Конструктор + /// + public StorageCollection() + { + _storage = new Dictionary>(); + } + + /// + /// Добавление коллекции в хранилище + /// + /// Название коллекции + /// тип коллекции + public void AddCollection(string name, CollectionType collectionType) + { + if (string.IsNullOrEmpty(name) || _storage.ContainsKey(name)) + { + return; + } + if (collectionType == CollectionType.None) + { + return; + } + if (collectionType == CollectionType.Massive) + { + _storage[name] = new MassiveGenericObjects(); + } + else if (collectionType == CollectionType.List) + { + _storage[name] = new ListGenericObjects(); + } + } + + /// + /// Удаление коллекции + /// + /// Название коллекции + public void DelCollection(string name) + { + if (name == null || !_storage.ContainsKey(name)) + { + return; + } + _storage.Remove(name); + } + + /// + /// Доступ к коллекции + /// + /// Название коллекции + /// + public ICollectionGenericObjects? this[string name] + { + get + { + if (_storage.ContainsKey(name)) + { + return _storage[name]; + } + else + { + return null; + } + } + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs index c25addc..cd005c1 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.Designer.cs @@ -29,6 +29,15 @@ private void InitializeComponent() { groupBoxTools = new GroupBox(); + 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(); buttonRefresh = new Button(); buttonGoToCheck = new Button(); buttonRemovePlane = new Button(); @@ -37,33 +46,126 @@ buttonAddPlane = new Button(); comboBoxSelectorCompany = new ComboBox(); pictureBox = new PictureBox(); + panelCompanyTools = new Panel(); groupBoxTools.SuspendLayout(); + panelStorage.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); + panelCompanyTools.SuspendLayout(); SuspendLayout(); // // groupBoxTools // - groupBoxTools.Controls.Add(buttonRefresh); - groupBoxTools.Controls.Add(buttonGoToCheck); - groupBoxTools.Controls.Add(buttonRemovePlane); - groupBoxTools.Controls.Add(maskedTextBoxPosition); - groupBoxTools.Controls.Add(buttonAddSeaplane); - groupBoxTools.Controls.Add(buttonAddPlane); + groupBoxTools.Controls.Add(panelCompanyTools); + groupBoxTools.Controls.Add(buttonCreateCompany); + groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(710, 0); + groupBoxTools.Location = new Point(793, 0); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(144, 529); + groupBoxTools.Size = new Size(144, 571); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; // + // buttonCreateCompany + // + buttonCreateCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonCreateCompany.Location = new Point(7, 285); + buttonCreateCompany.Name = "buttonCreateCompany"; + buttonCreateCompany.Size = new Size(126, 30); + buttonCreateCompany.TabIndex = 9; + buttonCreateCompany.Text = "Создать компанию"; + buttonCreateCompany.UseVisualStyleBackColor = true; + buttonCreateCompany.Click += ButtonCreateCompany_Click; + // + // panelStorage + // + 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(3, 19); + panelStorage.Name = "panelStorage"; + panelStorage.Size = new Size(138, 231); + panelStorage.TabIndex = 7; + // + // buttonCollectionDel + // + buttonCollectionDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + buttonCollectionDel.Location = new Point(3, 196); + buttonCollectionDel.Name = "buttonCollectionDel"; + buttonCollectionDel.Size = new Size(126, 30); + buttonCollectionDel.TabIndex = 8; + buttonCollectionDel.Text = "Удалить коллекцию"; + buttonCollectionDel.UseVisualStyleBackColor = true; + buttonCollectionDel.Click += ButtonCollectionDel_Click; + // + // listBoxCollection + // + listBoxCollection.FormattingEnabled = true; + listBoxCollection.ItemHeight = 15; + listBoxCollection.Location = new Point(3, 126); + listBoxCollection.Name = "listBoxCollection"; + listBoxCollection.Size = new Size(126, 64); + listBoxCollection.TabIndex = 5; + // + // buttonCollectionAdd + // + buttonCollectionAdd.Location = new Point(4, 81); + buttonCollectionAdd.Name = "buttonCollectionAdd"; + buttonCollectionAdd.Size = new Size(125, 39); + buttonCollectionAdd.TabIndex = 4; + buttonCollectionAdd.Text = "Добавить коллекцию"; + buttonCollectionAdd.UseVisualStyleBackColor = true; + buttonCollectionAdd.Click += ButtonCollectionAdd_Click; + // + // radioButtonList + // + radioButtonList.AutoSize = true; + radioButtonList.Location = new Point(69, 56); + radioButtonList.Name = "radioButtonList"; + radioButtonList.Size = new Size(66, 19); + radioButtonList.TabIndex = 3; + radioButtonList.TabStop = true; + radioButtonList.Text = "Список"; + radioButtonList.UseVisualStyleBackColor = true; + // + // radioButtonMassive + // + radioButtonMassive.AutoSize = true; + radioButtonMassive.Location = new Point(4, 56); + radioButtonMassive.Name = "radioButtonMassive"; + radioButtonMassive.Size = new Size(67, 19); + radioButtonMassive.TabIndex = 2; + radioButtonMassive.TabStop = true; + radioButtonMassive.Text = "Массив"; + radioButtonMassive.UseVisualStyleBackColor = true; + // + // textBoxCollectionName + // + textBoxCollectionName.Location = new Point(3, 27); + textBoxCollectionName.Name = "textBoxCollectionName"; + textBoxCollectionName.Size = new Size(126, 23); + textBoxCollectionName.TabIndex = 1; + // + // labelCollectionName + // + labelCollectionName.AutoSize = true; + labelCollectionName.Location = new Point(4, 9); + labelCollectionName.Name = "labelCollectionName"; + labelCollectionName.Size = new Size(125, 15); + labelCollectionName.TabIndex = 0; + labelCollectionName.Text = "Название коллекции:"; + // // buttonRefresh // - buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(6, 429); + buttonRefresh.Location = new Point(3, 202); buttonRefresh.Name = "buttonRefresh"; - buttonRefresh.Size = new Size(126, 44); + buttonRefresh.Size = new Size(126, 42); buttonRefresh.TabIndex = 6; buttonRefresh.Text = "Обновить"; buttonRefresh.UseVisualStyleBackColor = true; @@ -71,10 +173,9 @@ // // buttonGoToCheck // - buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(6, 346); + buttonGoToCheck.Location = new Point(4, 166); buttonGoToCheck.Name = "buttonGoToCheck"; - buttonGoToCheck.Size = new Size(126, 44); + buttonGoToCheck.Size = new Size(126, 30); buttonGoToCheck.TabIndex = 5; buttonGoToCheck.Text = "Передать на тесты"; buttonGoToCheck.UseVisualStyleBackColor = true; @@ -82,10 +183,9 @@ // // buttonRemovePlane // - buttonRemovePlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRemovePlane.Location = new Point(6, 265); + buttonRemovePlane.Location = new Point(4, 130); buttonRemovePlane.Name = "buttonRemovePlane"; - buttonRemovePlane.Size = new Size(126, 44); + buttonRemovePlane.Size = new Size(126, 30); buttonRemovePlane.TabIndex = 4; buttonRemovePlane.Text = "Удалить самолёт"; buttonRemovePlane.UseVisualStyleBackColor = true; @@ -93,7 +193,7 @@ // // maskedTextBoxPosition // - maskedTextBoxPosition.Location = new Point(6, 208); + maskedTextBoxPosition.Location = new Point(4, 101); maskedTextBoxPosition.Mask = "00"; maskedTextBoxPosition.Name = "maskedTextBoxPosition"; maskedTextBoxPosition.Size = new Size(126, 23); @@ -102,8 +202,7 @@ // // buttonAddSeaplane // - buttonAddSeaplane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddSeaplane.Location = new Point(6, 126); + buttonAddSeaplane.Location = new Point(3, 51); buttonAddSeaplane.Name = "buttonAddSeaplane"; buttonAddSeaplane.Size = new Size(126, 44); buttonAddSeaplane.TabIndex = 2; @@ -113,8 +212,7 @@ // // buttonAddPlane // - buttonAddPlane.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddPlane.Location = new Point(6, 78); + buttonAddPlane.Location = new Point(4, 3); buttonAddPlane.Name = "buttonAddPlane"; buttonAddPlane.Size = new Size(126, 42); buttonAddPlane.TabIndex = 1; @@ -128,7 +226,7 @@ comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxSelectorCompany.FormattingEnabled = true; comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" }); - comboBoxSelectorCompany.Location = new Point(6, 22); + comboBoxSelectorCompany.Location = new Point(6, 256); comboBoxSelectorCompany.Name = "comboBoxSelectorCompany"; comboBoxSelectorCompany.Size = new Size(126, 23); comboBoxSelectorCompany.TabIndex = 0; @@ -139,22 +237,40 @@ pictureBox.Dock = DockStyle.Fill; pictureBox.Location = new Point(0, 0); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(710, 529); + pictureBox.Size = new Size(793, 571); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // + // panelCompanyTools + // + panelCompanyTools.Controls.Add(buttonAddPlane); + panelCompanyTools.Controls.Add(buttonAddSeaplane); + panelCompanyTools.Controls.Add(buttonRefresh); + panelCompanyTools.Controls.Add(maskedTextBoxPosition); + panelCompanyTools.Controls.Add(buttonGoToCheck); + panelCompanyTools.Controls.Add(buttonRemovePlane); + panelCompanyTools.Dock = DockStyle.Bottom; + panelCompanyTools.Enabled = false; + panelCompanyTools.Location = new Point(3, 320); + panelCompanyTools.Name = "panelCompanyTools"; + panelCompanyTools.Size = new Size(138, 248); + panelCompanyTools.TabIndex = 10; + // // FormPlaneCollection // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(854, 529); + ClientSize = new Size(937, 571); Controls.Add(pictureBox); Controls.Add(groupBoxTools); Name = "FormPlaneCollection"; 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 +285,15 @@ private PictureBox pictureBox; private Button buttonRefresh; private Button buttonGoToCheck; + private Panel panelStorage; + private Label labelCollectionName; + private RadioButton radioButtonMassive; + private TextBox textBoxCollectionName; + private Button buttonCollectionAdd; + private RadioButton radioButtonList; + private ListBox listBoxCollection; + private Button buttonCollectionDel; + private Button buttonCreateCompany; + private Panel panelCompanyTools; } } \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs index d6367d8..a953ae7 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs @@ -8,6 +8,11 @@ namespace ProjectSeaplane; /// public partial class FormPlaneCollection : Form { + /// + /// Хранилише коллекций + /// + private readonly StorageCollection _storageCollection; + /// /// Компания /// @@ -19,6 +24,7 @@ public partial class FormPlaneCollection : Form public FormPlaneCollection() { InitializeComponent(); + _storageCollection = new(); } /// @@ -28,12 +34,7 @@ public partial class FormPlaneCollection : Form /// private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { - switch (comboBoxSelectorCompany.Text) - { - case "Хранилище": - _company = new PlaneSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); - break; - } + panelCompanyTools.Enabled = false; } /// @@ -183,4 +184,97 @@ public partial class FormPlaneCollection : Form 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); + RefreshListBoxItems(); + } + + /// + /// Удаление коллекции + /// + /// + /// + private void ButtonCollectionDel_Click(object sender, EventArgs e) + { + if (listBoxCollection.SelectedIndex < 0) + { + MessageBox.Show("Сначала выберите коллекцию"); + return; + } + if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + _storageCollection.DelCollection(listBoxCollection.SelectedItem?.ToString() ?? string.Empty); + RefreshListBoxItems(); + } + + + /// + /// Обновление списка в listBoxCollection + /// + private void RefreshListBoxItems() + { + 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 PlaneSharingService(pictureBox.Width, pictureBox.Height, collection); + break; + } + panelCompanyTools.Enabled = true; + RefreshListBoxItems(); + } +} \ No newline at end of file -- 2.25.1