From ab255a4cc87dcfa597eb6793b9faeb1454e58562 Mon Sep 17 00:00:00 2001 From: Tonb73 Date: Mon, 19 Feb 2024 08:25:06 +0300 Subject: [PATCH 1/4] LabWork1 --- ProjectElectricLocomotive/DirectionType.cs | 28 +++ .../DrawningElectricLocomotive.cs | 209 ++++++++++++++++++ .../EntityElectricLocomotive.cs | 62 ++++++ ProjectElectricLocomotive/Form1.Designer.cs | 39 ---- ProjectElectricLocomotive/Form1.cs | 10 - .../FormlectricLocomotive.Designer.cs | 137 ++++++++++++ .../FormlectricLocomotive.cs | 84 +++++++ .../FormlectricLocomotive.resx | 120 ++++++++++ ProjectElectricLocomotive/Program.cs | 2 +- .../ProjectElectricLocomotive.csproj | 15 ++ .../Properties/Resources.Designer.cs | 113 ++++++++++ .../Properties/Resources.resx | 136 ++++++++++++ .../Resources/DownArrow.png | Bin 0 -> 5610 bytes .../Resources/LeftArrow.png | Bin 0 -> 5144 bytes .../Resources/RightArrow (1).png | Bin 0 -> 5107 bytes .../Resources/RightArrow.png | Bin 0 -> 5555 bytes .../Resources/UpArrow.png | Bin 0 -> 5555 bytes 17 files changed, 905 insertions(+), 50 deletions(-) create mode 100644 ProjectElectricLocomotive/DirectionType.cs create mode 100644 ProjectElectricLocomotive/DrawningElectricLocomotive.cs create mode 100644 ProjectElectricLocomotive/EntityElectricLocomotive.cs delete mode 100644 ProjectElectricLocomotive/Form1.Designer.cs delete mode 100644 ProjectElectricLocomotive/Form1.cs create mode 100644 ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs create mode 100644 ProjectElectricLocomotive/FormlectricLocomotive.cs create mode 100644 ProjectElectricLocomotive/FormlectricLocomotive.resx create mode 100644 ProjectElectricLocomotive/Properties/Resources.Designer.cs create mode 100644 ProjectElectricLocomotive/Properties/Resources.resx create mode 100644 ProjectElectricLocomotive/Resources/DownArrow.png create mode 100644 ProjectElectricLocomotive/Resources/LeftArrow.png create mode 100644 ProjectElectricLocomotive/Resources/RightArrow (1).png create mode 100644 ProjectElectricLocomotive/Resources/RightArrow.png create mode 100644 ProjectElectricLocomotive/Resources/UpArrow.png diff --git a/ProjectElectricLocomotive/DirectionType.cs b/ProjectElectricLocomotive/DirectionType.cs new file mode 100644 index 0000000..8cec3e4 --- /dev/null +++ b/ProjectElectricLocomotive/DirectionType.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive +{ + public enum DirectionType + { + /// + /// Вверх + /// + Up = 1, + /// + /// Вниз + /// + Down = 2, + /// + /// Влево + /// + Left = 3, + /// + /// Вправо + /// + Right = 4 + } +} diff --git a/ProjectElectricLocomotive/DrawningElectricLocomotive.cs b/ProjectElectricLocomotive/DrawningElectricLocomotive.cs new file mode 100644 index 0000000..9dbdb5e --- /dev/null +++ b/ProjectElectricLocomotive/DrawningElectricLocomotive.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive +{ + /// + /// Класс, отвечающий за отрисовку и перемещение обьекта-сущности + /// + public class DrawningElectricLocomotive + { + + /// + /// Класс-сущность + /// + public EntityElectricLocomotive? EntityElectricLocomotive { get; private set; } + /// + /// Ширина окна + /// + private int? _pictureWidth; + /// + /// Высота окна + /// + private int? _pictureHeight; + /// + /// Левая координата прорисовки Электровоза + /// + private int? _startPosX; + /// + /// Верхняя кооридната прорисовки Электровоза + /// + private int? _startPosY; + + /// + /// Ширина прорисовки Локомотива + /// + private readonly int _drawningElectriLocomotiveWidth = 155; + /// + /// Высота прорисовки локомотива + /// + private readonly int _drawningElectricLocomotiveHeight = 100; + + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + public void Init(int speed, double weight, Color bodyColor, Color + additionalColor, bool pantograph, bool batterystorage) + { + EntityElectricLocomotive = new EntityElectricLocomotive(); + EntityElectricLocomotive.Init(speed, weight, bodyColor, additionalColor, + pantograph, batterystorage); + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + + } + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах +public bool SetPictureSize(int width, int height) + { + + // TODO проверка, что объект "влезает" в размеры поля + if(_drawningElectriLocomotiveWidth > width || _drawningElectricLocomotiveHeight > height) + { + return false; + } + if(_startPosX.HasValue && _startPosY.HasValue) + { + if(_startPosX + _drawningElectriLocomotiveWidth > width) + { + _startPosX = width - _drawningElectriLocomotiveWidth; + } + if(_startPosY + _drawningElectricLocomotiveHeight > height) + { + _startPosY = height - _drawningElectricLocomotiveHeight; + } + } + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена + _pictureWidth = width; + _pictureHeight = height; + return true; + } + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы + if(x < 0 || x + _drawningElectriLocomotiveWidth > _pictureWidth.Value) + { + x = _pictureWidth.Value - _drawningElectriLocomotiveWidth; + } + if(y < 0 || y + _drawningElectricLocomotiveHeight > _pictureHeight.Value) + { + y = _pictureHeight.Value - _drawningElectricLocomotiveHeight; + } + // то надо изменить координаты, чтобы он оставался в этих границах + + _startPosX = x; + _startPosY = y; + } + public bool MoveTransport(DirectionType direction) + { + if (EntityElectricLocomotive == null || !_startPosX.HasValue || + !_startPosY.HasValue) + { + return false; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX.Value - EntityElectricLocomotive.Step > 0) + { + _startPosX -= (int)EntityElectricLocomotive.Step; + } + return true; + //вверх + case DirectionType.Up: + if ((_startPosY.Value) - EntityElectricLocomotive.Step > 0) + { + + _startPosY -= (int)EntityElectricLocomotive.Step; + } + return true; + // вправо + case DirectionType.Right: + if (_startPosX.Value + EntityElectricLocomotive.Step < _pictureWidth - _drawningElectriLocomotiveWidth) + { + _startPosX += (int)EntityElectricLocomotive.Step; + } + return true; + //вниз + case DirectionType.Down: + if (_startPosY.Value + EntityElectricLocomotive.Step < _pictureHeight - _drawningElectricLocomotiveHeight) + { + _startPosY += (int)EntityElectricLocomotive.Step; + } + return true; + default: + return false; + } + } + public void DrawTransport(Graphics g) + { + if (EntityElectricLocomotive == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + Pen pen = new(Color.Black); + Brush additonalBrush = new SolidBrush(EntityElectricLocomotive.AdditionalColor); + Brush bodyBrush = new SolidBrush(EntityElectricLocomotive.BodyColor); + //границы Электровоза + //колеса + g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 65, 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 65, 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 65, 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 120, _startPosY.Value + 65, 20, 20); + //кузов + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 50, 155, 40); + g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 50, _startPosX.Value + 20, _startPosY.Value + 30); + g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 30, 135,20 ); + //покраска кузова + g.FillEllipse(Brushes.Black, _startPosX.Value + 10, _startPosY.Value + 85, 20, 20); + g.FillEllipse(Brushes.Black, _startPosX.Value + 30, _startPosY.Value + 85, 20, 20); + g.FillEllipse(Brushes.Black, _startPosX.Value + 100, _startPosY.Value + 85, 20, 20); + g.FillEllipse(Brushes.Black, _startPosX.Value + 120, _startPosY.Value + 85, 20, 20); + g.FillRectangle(bodyBrush, _startPosX.Value+1, _startPosY.Value + 51, 154, 39); + g.FillRectangle(bodyBrush, _startPosX.Value + 21, _startPosY.Value + 31, 134, 19); + + g.DrawRectangle(pen, _startPosX.Value , _startPosY.Value + 50, 155, 10); + g.FillRectangle(additonalBrush, _startPosX.Value + 1, _startPosY.Value + 51, 154, 9); + //g.FillPolygon(Brushes.AliceBlue, _startPosX.Value + 1, _startPosY.Value + 31, _startPosX.Value + 19, _startPosY.Value + 9, _startPosX.Value + 19, _startPosY.Value + 1); + //Пантограф + if (EntityElectricLocomotive.Pantograph) + { + g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 30, _startPosX.Value + 70, _startPosY.Value + 10); + g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 10, _startPosX.Value + 90, _startPosY.Value + 10); + } + //Отсек для батарей + if (EntityElectricLocomotive.BatteryStorage) + { + g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value + 30, 30, 20); + g.FillRectangle(additonalBrush, _startPosX.Value + 101, _startPosY.Value + 31, 29, 19); + g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 40, _startPosX.Value + 115, _startPosY.Value + 50); + g.DrawLine(pen, _startPosX.Value + 115, _startPosY.Value + 40, _startPosX.Value + 120, _startPosY.Value + 40); + g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 30, _startPosX.Value + 115, _startPosY.Value + 40); + } + + } + + } + } + diff --git a/ProjectElectricLocomotive/EntityElectricLocomotive.cs b/ProjectElectricLocomotive/EntityElectricLocomotive.cs new file mode 100644 index 0000000..a50bb96 --- /dev/null +++ b/ProjectElectricLocomotive/EntityElectricLocomotive.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive +{ + public class EntityElectricLocomotive + { + + /// + /// Скорость + /// + 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 Pantograph{ get; private set; } + /// + /// Признак (опция) наличия отсека под батареи + /// + public bool BatteryStorage { get; private set; } + /// + /// Шаг перемещения Локомотива + /// + public double Step => Speed * 100 / Weight; + /// + /// Инициализация полей объекта-класса ЭлектроЛокомотива + /// + /// Скорость + /// Вес локомотива + /// Основной цвет + /// Дополнительный цвет + /// Признак "рогов" + /// Признак наличия отсека под батареи + public void Init(int speed, double weight, Color bodyColor, Color + additionalColor, bool pantograph, bool batterystorage) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + Pantograph = pantograph; + BatteryStorage = batterystorage; + + } + + } +} diff --git a/ProjectElectricLocomotive/Form1.Designer.cs b/ProjectElectricLocomotive/Form1.Designer.cs deleted file mode 100644 index 6cd3a18..0000000 --- a/ProjectElectricLocomotive/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ProjectElectricLocomotive -{ - 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/ProjectElectricLocomotive/Form1.cs b/ProjectElectricLocomotive/Form1.cs deleted file mode 100644 index eb6a0ea..0000000 --- a/ProjectElectricLocomotive/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ProjectElectricLocomotive -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs b/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs new file mode 100644 index 0000000..63d526c --- /dev/null +++ b/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs @@ -0,0 +1,137 @@ +namespace ProjectElectricLocomotive +{ + partial class FormlectricLocomotive + { + /// + /// 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() + { + pictureBoxElectricLocomotive = new PictureBox(); + buttonCreate = new Button(); + buttonUp = new Button(); + buttonLeft = new Button(); + buttonRight = new Button(); + buttonDown = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).BeginInit(); + SuspendLayout(); + // + // pictureBoxElectricLocomotive + // + pictureBoxElectricLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + pictureBoxElectricLocomotive.BackgroundImageLayout = ImageLayout.Stretch; + pictureBoxElectricLocomotive.Location = new Point(9, -12); + pictureBoxElectricLocomotive.Name = "pictureBoxElectricLocomotive"; + pictureBoxElectricLocomotive.Size = new Size(779, 411); + pictureBoxElectricLocomotive.TabIndex = 0; + pictureBoxElectricLocomotive.TabStop = false; + + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(12, 353); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(112, 34); + buttonCreate.TabIndex = 1; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + buttonCreate.Click += buttonCreate_Click; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.UpArrow; + buttonUp.BackgroundImageLayout = ImageLayout.Stretch; + buttonUp.Location = new Point(697, 312); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(35, 35); + buttonUp.TabIndex = 2; + buttonUp.UseVisualStyleBackColor = true; + buttonUp.Click += ButtonMove_Click; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.RightArrow__1_; + buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; + buttonLeft.Location = new Point(656, 352); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(35, 35); + buttonLeft.TabIndex = 3; + buttonLeft.UseVisualStyleBackColor = true; + buttonLeft.Click += ButtonMove_Click; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.LeftArrow; + buttonRight.BackgroundImageLayout = ImageLayout.Stretch; + buttonRight.Location = new Point(738, 352); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(35, 35); + buttonRight.TabIndex = 4; + buttonRight.UseVisualStyleBackColor = true; + buttonRight.Click += ButtonMove_Click; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.DownArrow; + buttonDown.BackgroundImageLayout = ImageLayout.Stretch; + buttonDown.Location = new Point(697, 352); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(35, 35); + buttonDown.TabIndex = 5; + buttonDown.UseVisualStyleBackColor = true; + buttonDown.Click += ButtonMove_Click; + // + // FormlectricLocomotive + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(788, 399); + Controls.Add(buttonDown); + Controls.Add(buttonRight); + Controls.Add(buttonLeft); + Controls.Add(buttonUp); + Controls.Add(buttonCreate); + Controls.Add(pictureBoxElectricLocomotive); + Name = "FormlectricLocomotive"; + Text = "ЭлектроВоз"; + + ((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).EndInit(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBoxElectricLocomotive; + private Button buttonCreate; + private Button buttonUp; + private Button buttonLeft; + private Button buttonRight; + private Button buttonDown; + } +} \ No newline at end of file diff --git a/ProjectElectricLocomotive/FormlectricLocomotive.cs b/ProjectElectricLocomotive/FormlectricLocomotive.cs new file mode 100644 index 0000000..9d821fe --- /dev/null +++ b/ProjectElectricLocomotive/FormlectricLocomotive.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ProjectElectricLocomotive +{ + public partial class FormlectricLocomotive : Form + { + private void Draw() + { + if (_drawnningElectricLocomotive == null) + { + return; + } + + Bitmap bmp = new(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawnningElectricLocomotive.DrawTransport(gr); + pictureBoxElectricLocomotive.Image = bmp; + } + + private DrawningElectricLocomotive? _drawnningElectricLocomotive; + public FormlectricLocomotive() + { + InitializeComponent(); + } + + + private void buttonCreate_Click(object sender, EventArgs e) + { + Random random = new(); + _drawnningElectricLocomotive = new DrawningElectricLocomotive(); + _drawnningElectricLocomotive.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))); + _drawnningElectricLocomotive.SetPictureSize(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); + _drawnningElectricLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); + + Draw(); + } + + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawnningElectricLocomotive == null) + { + return; + } + string name = ((Button)sender)?.Name ?? string.Empty; + bool result = false; + switch (name) + { + case "buttonUp": + result = + _drawnningElectricLocomotive.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + result = + _drawnningElectricLocomotive.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + result = + _drawnningElectricLocomotive.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + result = + _drawnningElectricLocomotive.MoveTransport(DirectionType.Right); + break; + } + if (result) + { + Draw(); + } + + } + } +} diff --git a/ProjectElectricLocomotive/FormlectricLocomotive.resx b/ProjectElectricLocomotive/FormlectricLocomotive.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ProjectElectricLocomotive/FormlectricLocomotive.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/ProjectElectricLocomotive/Program.cs b/ProjectElectricLocomotive/Program.cs index 9a38110..d71f655 100644 --- a/ProjectElectricLocomotive/Program.cs +++ b/ProjectElectricLocomotive/Program.cs @@ -11,7 +11,7 @@ namespace ProjectElectricLocomotive // 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 FormlectricLocomotive()); } } } \ No newline at end of file diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive.csproj b/ProjectElectricLocomotive/ProjectElectricLocomotive.csproj index e1a0735..244387d 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive.csproj +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/ProjectElectricLocomotive/Properties/Resources.Designer.cs b/ProjectElectricLocomotive/Properties/Resources.Designer.cs new file mode 100644 index 0000000..5ce2252 --- /dev/null +++ b/ProjectElectricLocomotive/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectElectricLocomotive.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("ProjectElectricLocomotive.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 DownArrow { + get { + object obj = ResourceManager.GetObject("DownArrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap LeftArrow { + get { + object obj = ResourceManager.GetObject("LeftArrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap RightArrow { + get { + object obj = ResourceManager.GetObject("RightArrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap RightArrow__1_ { + get { + object obj = ResourceManager.GetObject("RightArrow (1)", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap UpArrow { + get { + object obj = ResourceManager.GetObject("UpArrow", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ProjectElectricLocomotive/Properties/Resources.resx b/ProjectElectricLocomotive/Properties/Resources.resx new file mode 100644 index 0000000..2582cf4 --- /dev/null +++ b/ProjectElectricLocomotive/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\LeftArrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\RightArrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\DownArrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\UpArrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\RightArrow (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ProjectElectricLocomotive/Resources/DownArrow.png b/ProjectElectricLocomotive/Resources/DownArrow.png new file mode 100644 index 0000000000000000000000000000000000000000..1341e3564ee93ab746f2220f3a456ff578dff636 GIT binary patch literal 5610 zcmeI0`Cro8*2gzSnRSIaWSK*FPNfycY%)_*%rrGky_s{RW#p7%X{ZT8)1^tRoQJ?N z(@L$#oE43-lpK!ZQ4=yXb3}235S~rbTPd$l zTLA!2wz0N23V;Iqr~sBPgKsktZDRO_2t8_L4hkAIhT#{a?|~x+0C*L*QgUi3{H_#Y z?H&pM>Ye!DbbLL0RoxmN`xNhUFnR3}~#dFjO zBS$078J;Y&H8#y{^s$P^UA6lBFWHIPRG$8^?sqflL~HNtYnSVHdm{Nm)2RuS$?YMH zbzS`Z0z*Sxnb=Jst)scwab#j*`||)*4Gp^!Cr%KS?#c2Wq#|f$NO-qR0BC6;;Ek04 zSZ)n~nHh|R!fybqx(fh}_G`dsvTFzydcB`xw^W#*R<8gS<>;&XB5mfYwiot%0FJZE9TCf1kDt3P*9LR zzl!275)Kj+pK*}1!}Sg&6bgl~)M+DrnWpquq7q1)tx?22w!FPId!85dVyt=~)qr@? zh&1MwW*i>ebva-sB9kS=2#SJw>Q`vH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z4VEHEOq+Bm&WkLqDwi7|~h6CPT3mLR|K9&8dO7tyVoh_h3E@SjpT~z|e zc(gc&ap_s!(f%eB^#;@_1v#H`m6SwAMC@xw*_k!vtA#><1B)ZB>;OqL?E{utF$T^* bo}m`&++G-z9#w(=iUl^7_7(-^-dFwy;TVla literal 0 HcmV?d00001 diff --git a/ProjectElectricLocomotive/Resources/LeftArrow.png b/ProjectElectricLocomotive/Resources/LeftArrow.png new file mode 100644 index 0000000000000000000000000000000000000000..ecf4448ff091361cfdce3e53ab82222e66802f4a GIT binary patch literal 5144 zcmeHL`CF6M5VbakmL7EyxlODIg#OSrWDcmnzs+u$3JG zR+NAs`xdq+RB01g3P>P8D6)nCVF>|30(WwsKKGBfPk-P^zVn@#Gv}Rm<{k3jBL0lZ zwokVqgjCL*J$V_S4e)gX+PVckL}6VL_)rMGeC8`u*t(Ao51YKLan=Zx#4AhPH^Z}1 z;919Dgj9c%|0yKus%pUE-jGvQLhOiMA!PR;Pedk@^?d^Tf<4>=J@tt}-sv+ZK1FC( z?75TH--NkN4>%XU_mnlyDPB_2HttF&KF~XP`t^>DJ9nRdcA}jS(RuwSF1sZqMp-$- z=ZBoUKYenJ6yY$5 z-+?oDb#N=XrC$*$=${W)IMq{<9W{;}JYq-3>s9p!U07KiTz9p+ZN3X3^O5JtuAg%VWJ2muZ~V$!e6$OF zb`ZR&MU4D>h9zBDVCz`SJ(w4`t=Hg(+~hB67h19GBlL{RN%{mQUfA$M%w`4DzQBtR zybS8ZnI^8Stp)Y@S0&Q0hRnU;(*7@FFj5(#xo-)6I`_s>dDv1iYj#p z`Sa9tNn>9XvB<85hR{{3G>?09TzYq*CUv@kGno)@5TQNA1izSck9+Ckn+h~%TsNRw z6!BD9TP1N@M)+9j=xxRQxpp-Vz?kXZQ~WCd+n=F5E9$i692u}eC{XS(-EPxM%^7{L zw4S3|%JN{(iNn{Y1IHm#+g}XIX2{drp|Vy?{s~dLP3U?0PFQ|0#*XH2hsLv_8}R&( z!Bl%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8T$lH*LYoe;lYn=)fcB8dlH@Hb7#x oe)iA8KY08<&>_~2wXSegt{U0D*tAzW@LL literal 0 HcmV?d00001 diff --git a/ProjectElectricLocomotive/Resources/RightArrow (1).png b/ProjectElectricLocomotive/Resources/RightArrow (1).png new file mode 100644 index 0000000000000000000000000000000000000000..15d0af76b0dea362023523ff8b74af9108bbaf2d GIT binary patch literal 5107 zcmeHL`&W|b+J3-8p3)q5qfH@AjX7-_b!%p73LPeMOl`6EG^8k0d3flM~YLfJ`R4A4wq|PfSR~yOYug zC6k-J0Kg$JWZULFS#k2=P~l}fia%{F=&ae<^}MlRrJ32%kjia>N1al{^KaT&5yYv9zIy|%t^socPYRX`DvRO{gk$uohSWEY z{LKJDSkz3Ch@B;a)PAzE%eRGQ!kaY3R_Np;TFjcASA@=z`L}00V4&=CK;}Rc)g5Cf zI8%?T1=V|RzyBLh?*yuQT_wIPL<+xP`It5in8THuqIeo7mn+#c)^fvY~6VCCSkt-;_dbE(_Di^?8Mo4!$T ztE#*@5;#$iI8!zZ^+CVNeSbYO9D&nX&=VRH`GuKbil1G}2b@PHpo80g0Zwbk!x=?B z9FV>k;rX~cZ*Cm!aBS25(U2zXgdUu80jE1KAE)hz6ol*m68EcKQ!J+GC*o(VK)M~m z^CxHO)Wfv?XhIW7YnWxxU^mEukhmoau$xobq!nKH?{w|xkGraXkYmb2XvZ*ym#}1? z(i^u5h`%x##v^eU{WOC%)O17RLDPknA+aQTV4`Yi)7QrK4z7^QKal9_!VyegOM33% zpplZmoXi|53%aecM$|i!hkgu(2{!g|9A&%`x-E7E>ethJG)bh2qfY;UpMBp4v!&k( zK8!+0r7#p_8-KiRJnn;-Lcz0$a6O!g*F&rew zUWI&pE#LX5NVS2l37Y?K7aqMo=MOd{55OkPQNJV<<)icNg(K)(8+v!K_#cT+8u^+7 zz1D#Af{YM;kfJep)CV`n6aBUDXB#}bm>P8!K=hYN5Fi=!(L(f)@UWyF&s|*y5DQJeA zG9)nRi$v7JvcnGe)-iT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w|e@ z3P1YnDjvdKK9BfqdqH&+pl^?F^CPSN3~o^@TFdyBMvh_I(6nk#X1Oc#h}I{ zNc+$ZR`A^~7WC~(CuTMV*H^t)K6Wa9McNLSl4K;-((bgYIIo{OP^^))E- zl?7lRj37@vUQ^%H4piQV`bDl4)U*egS(8KerT=sYzX?YS8j168Ze-rFJSGb1>zByg5yhtGN_Ged_@4H5>|T zuHWqmdJr2x?G5vd4zR&SIe=3&x}B+z&*h0HM)$uN_1*$x8<4o4*kgf;BaEdfTX?S$ zKx+YTI)t7d;J<2WCyTQQ%Y0KHPw+ZE1MTmuyNV8|@}Zlgh?GTA)BXOKj;z61;E!U&r6Z&|~%USDOg;op^Q zn}}5ywT?fM8OqknNhHS7xVuROFb6h%ZC~22?%_* z8m-$g|MWFSBaT@UR=lSQ)Ei8(cEw)!&N^st#c@~>9?z2Q+_%DQXoV~LXkT@vd zV?GoBSz<6MW6yjg?|EgYfPk5Q3E_rVl3--3H;?`$Uxxg|Rp%|~E4$X7blX>RSY(T) z$gV*Zz6z@FHj!<>KBtuzfJFv`hT=c~b@VC$0$?o^^hPlcMSTk~pAo2re9Dwq0_a9c z;nI|TTXb5-m$OhgeFvWvCW-kdHyfeE6c|RdBMg{uxS;|LMR*g8Jy?hzD?J__-S9(5 zPR-Q0VCU#6pfW-5;vjLBB>qcO7fY0TV$t@%rXwLA)nA8-Yfg^7>Ys763@N<5UB1AW z>+!@X$9g;_L@W;@mrj_{p+E#He+~ZY+5fL+|Nnw#|Nnf8^?0pRBEA16t4Uhm0N=@h NkZ;4c)osC@{2%ZPb`Jmm literal 0 HcmV?d00001 diff --git a/ProjectElectricLocomotive/Resources/RightArrow.png b/ProjectElectricLocomotive/Resources/RightArrow.png new file mode 100644 index 0000000000000000000000000000000000000000..6aa32561092c28aed065ef9113e08eaeb22fc580 GIT binary patch literal 5555 zcmeHL`9GBF|Gozqszc?piRd_uI@VBPVy0B6L8V9tIb%td%rMrO(W%qvqbx^ggi%>4 zA=$}{l2n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({`F^<>CIVZElX*vYh>TOn=billai z!y|+E0P$&aaqr?}S6i(-#wjKvT?&*OGB7yb^Ei>s*xI?5SxscssrrkkdDG^f(6(~mfyT1-jZ*UgQ?=DjK>OS?WvjX`cJDG{q4 z<_U@(&QrPx%{f+U$gyynw$lSh91T*P1rUJMD`UCsT2Idy27{+rYgD*1h^N#z^4phq zkP%E??P6!I>D~@!o>SwaReYi~E4og1PDeq*y;V#fOGF~aLl=}CrA z1m_dz{7j{zCeYdi@X(FZ6w&I?)7@OsJN9bt(x=TWcbp^ul_~|#%D)4ks)~RoXjuSc zEC9e_;ptjp3jmwqz|U8H=H(|Cem2QZX81{m|4Sy`T5_0(_SXtmbLq!>;D4&X@`UyA J{9~>+{twK;VKo2% literal 0 HcmV?d00001 diff --git a/ProjectElectricLocomotive/Resources/UpArrow.png b/ProjectElectricLocomotive/Resources/UpArrow.png new file mode 100644 index 0000000000000000000000000000000000000000..6aa32561092c28aed065ef9113e08eaeb22fc580 GIT binary patch literal 5555 zcmeHL`9GBF|Gozqszc?piRd_uI@VBPVy0B6L8V9tIb%td%rMrO(W%qvqbx^ggi%>4 zA=$}{l2n!vN!bS3#%`>`EZ=*4KR6ec$i<{l4DUb=`C4jJ5eM>lN1n z0DiHwIDQTQ3HVh4$VkJ>e8`s-ctH@(nI8lB%}N}2BjtJ2>L>t(u^aeq>)^d?fQ17A z0J(SK4ZzHX-nj9D{O3((wXHXox7y0AlRjlwqGw+wK=%Cca=o8azSkrB;3yLD zhf{OVC5>Y2zDHQ!IG1DI|G6Twe%5Tq-y@u=RZ~{m4|#G^s=ntmYrG`s^rHC<8ewrh zl0~AMTqQP zGYU(djdsa2>S_s?un% zsWIiCkB~IW;ug$p{HG3%;Ev@MWYq%Hup(>1n;8BWZfP zYfIe(8{>%OfQ2~()uTufAdW12vF&i;7xBZn)9X@La=@V5(Z4!zm_?^I(=je6d&BDk z?}{lRA#u8T39f!T7-aNwwa6V+%bvWYO07+6W4^^Gqg(&8Rl{$&UEu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ep 17 00:00:00 2001 From: Tonb73 Date: Sun, 3 Mar 2024 15:22:55 +0300 Subject: [PATCH 2/4] =?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 --- Lab_1/Data_Structure.cpp | 1 + Lab_1/Data_Structure.h | 42 ++++ Lab_1/Lab_1.sln | 31 +++ Lab_1/Lab_1.vcxproj | 139 ++++++++++++ Lab_1/Lab_1.vcxproj.filters | 30 +++ Lab_1/Source.cpp | 199 +++++++++++++++++ .../DrawningElectricLocomotive.cs | 209 ------------------ .../{ => Drawnings}/DirectionType.cs | 2 +- .../Drawnings/DrawningElectricLocomotive.cs | 76 +++++++ .../Drawnings/DrawningLocomotive.cs | 204 +++++++++++++++++ .../Entities/EntityElectricLocomotive.cs | 45 ++++ .../Entities/EntityLocomotive.cs | 47 ++++ .../EntityElectricLocomotive.cs | 62 ------ .../FormlectricLocomotive.Designer.cs | 20 +- .../FormlectricLocomotive.cs | 69 ++++-- 15 files changed, 878 insertions(+), 298 deletions(-) create mode 100644 Lab_1/Data_Structure.cpp create mode 100644 Lab_1/Data_Structure.h create mode 100644 Lab_1/Lab_1.sln create mode 100644 Lab_1/Lab_1.vcxproj create mode 100644 Lab_1/Lab_1.vcxproj.filters create mode 100644 Lab_1/Source.cpp delete mode 100644 ProjectElectricLocomotive/DrawningElectricLocomotive.cs rename ProjectElectricLocomotive/{ => Drawnings}/DirectionType.cs (91%) create mode 100644 ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs create mode 100644 ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs create mode 100644 ProjectElectricLocomotive/Entities/EntityElectricLocomotive.cs create mode 100644 ProjectElectricLocomotive/Entities/EntityLocomotive.cs delete mode 100644 ProjectElectricLocomotive/EntityElectricLocomotive.cs diff --git a/Lab_1/Data_Structure.cpp b/Lab_1/Data_Structure.cpp new file mode 100644 index 0000000..16afe1c --- /dev/null +++ b/Lab_1/Data_Structure.cpp @@ -0,0 +1 @@ +#include "Data_Structure.h" diff --git a/Lab_1/Data_Structure.h b/Lab_1/Data_Structure.h new file mode 100644 index 0000000..68c2813 --- /dev/null +++ b/Lab_1/Data_Structure.h @@ -0,0 +1,42 @@ +//#include +//#include +// +//#pragma once +// +//struct Node { +// int data; +// Node* next; +//}; +// +//class Data_Structure +//{ +//private: +// Node* head; +// struct Node { +// int data; +// Node* next; +// }; +//public: +// Data_Structure(){ +// head = NULL; +// } +// void addNode(int val){ +// Node* newNode = new Node; +// newNode->data = val; +// newNode->next = head; +// head = newNode; +// +// +// } +// void printList() { +// Node* currentNode = head; +// while (currentNode->next != NULL) { +// printf("%d", currentNode->data); +// currentNode = currentNode->next; +// +// } +// +// +// } +//}; +// diff --git a/Lab_1/Lab_1.sln b/Lab_1/Lab_1.sln new file mode 100644 index 0000000..76a53c9 --- /dev/null +++ b/Lab_1/Lab_1.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34024.191 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lab_1", "Lab_1.vcxproj", "{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Debug|x64.ActiveCfg = Debug|x64 + {B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Debug|x64.Build.0 = Debug|x64 + {B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Debug|x86.ActiveCfg = Debug|Win32 + {B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Debug|x86.Build.0 = Debug|Win32 + {B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Release|x64.ActiveCfg = Release|x64 + {B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Release|x64.Build.0 = Release|x64 + {B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Release|x86.ActiveCfg = Release|Win32 + {B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FF15C0FB-D559-46A6-B4E8-E461B8F5C363} + EndGlobalSection +EndGlobal diff --git a/Lab_1/Lab_1.vcxproj b/Lab_1/Lab_1.vcxproj new file mode 100644 index 0000000..0d6ac74 --- /dev/null +++ b/Lab_1/Lab_1.vcxproj @@ -0,0 +1,139 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {b3b62c1b-e8d8-4038-8dfd-248406a48ee2} + Lab1 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/Lab_1/Lab_1.vcxproj.filters b/Lab_1/Lab_1.vcxproj.filters new file mode 100644 index 0000000..6d47a77 --- /dev/null +++ b/Lab_1/Lab_1.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + Исходные файлы + + + + + Файлы заголовков + + + \ No newline at end of file diff --git a/Lab_1/Source.cpp b/Lab_1/Source.cpp new file mode 100644 index 0000000..bbe0097 --- /dev/null +++ b/Lab_1/Source.cpp @@ -0,0 +1,199 @@ +/* + 4 + - + - + - , + , +*/ + +#include +#include +#include "Data_Structure.h" + +int unsorted_array[10] = { 2, 5, 1,8,3,4,7,6,9,0 }; +int arr[10] = { 2, 5, 1,8,3,4,7,6,9,0 }; +int n = 10; + +void Buble_sort() { + for (int i = 0; i < n; i++) { + for (int j = n - 1; j > i; j--) { + if (arr[j - 1] > arr[j]) { + int temp = arr[j]; + arr[j] = arr[j - 1]; + arr[j - 1] = temp; + } + } + } +} + + +void Merge(int arr[], int begin, int end) { + int mid = begin + (end - begin) / 2; + int i = begin; + int j = mid + 1; + int d[11] = { 0 }; + int k = 0; + + while (i <= mid && j <= end) { + if (arr[i] <= arr[j]) { + d[k] = arr[i]; + i++; + } + else { + d[k] = arr[j]; + j++; + } + k++; + } + while (i <= mid) { + d[k] = arr[i]; + k++; + i++; + } + while (j <= end) { + d[k] = arr[j]; + k++; + j++; + } + for (i = 0; i < k; i++) { + arr[begin + i] = d[i]; + } + +} + +void Merge_sort(int* arr, int left, int right) { + int temp = 0; + if (left < right) { + if (right - left == 1) { + if (arr[left] > arr[right]) { + temp = arr[left]; + arr[left] = arr[right]; + arr[right] = temp; + } + } + else { + Merge_sort(arr, left, (right - left) / 2); + Merge_sort(arr, left + (right - left) / 2 + 1, right); + Merge(arr, left, right); + } + } + +} + + +void Shake_sort() { + int direction = 0; + int left = arr[0]; + int left_index = 0; + int right = arr[n]; + int right_index = n; + for (int _ = 0; _ < n - 1; _++) { + if (direction == 0) { + for (int i = left_index; i < right_index - 1; i++) { + if (arr[i] > arr[i + 1]) { + int temp = arr[i]; + arr[i] = arr[i + 1]; + arr[i + 1] = temp; + } + } + if (right != arr[right_index]) { + for (int i = n; i > 0; i--) { + if (arr[i] == right) { + right_index = i; + } + } + } + direction = 1; + } + else { + for (int j = right_index; j > left_index; j--) { + if (arr[j] < arr[j - 1]) { + int temp1 = arr[j]; + arr[j] = arr[j - 1]; + arr[j - 1] = temp1; + } + } + if (left != arr[left_index]) { + for (int i = 0; i < n; i++) { + if (arr[i] == left) { + left_index = i; + } + } + } + } + direction = 0; + } + +} + +void print_list() { + for (int i = 0; i < n; i++) { + printf("%d ", arr[i]); + } + printf("\n"); +} + + + +struct Node { + int student_year; + int student_group; + struct Node* next; + + +}; + +struct Node* first = NULL; + + + +void s_addToHead(int year, int group) { + struct Node* NewNode = (struct Node*)malloc(sizeof(NewNode)); + NewNode->student_year = year; + NewNode->student_group = group; + NewNode->next = first; + + first = NewNode; + +} + +void s_deleteFromHead() { + struct Node* DelNode = first; + int val1 = DelNode->student_year; + int val2 = DelNode->student_group; + + first = first->next; + printf("****|PI-%d, %d| - Deleted\n", val2, val1); + +} + +void s_print() { + struct Node* i = first; + while (i) { + printf("|PI-%d, %d|\n", i->student_group, i->student_year); + i = i->next; + } + + +} + + +int main() { + s_addToHead(2020, 12); + s_addToHead(2021, 13); + s_addToHead(2022, 14); + s_addToHead(2024, 15); + s_print(); + printf("------------------------\n"); + s_deleteFromHead(); + s_print(); + + print_list(); + Shake_sort(); + //Merge_sort(arr, 0, n - 1); + print_list(); + //Data_structure newStructure; + + + return 0; +} \ No newline at end of file diff --git a/ProjectElectricLocomotive/DrawningElectricLocomotive.cs b/ProjectElectricLocomotive/DrawningElectricLocomotive.cs deleted file mode 100644 index 9dbdb5e..0000000 --- a/ProjectElectricLocomotive/DrawningElectricLocomotive.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectElectricLocomotive -{ - /// - /// Класс, отвечающий за отрисовку и перемещение обьекта-сущности - /// - public class DrawningElectricLocomotive - { - - /// - /// Класс-сущность - /// - public EntityElectricLocomotive? EntityElectricLocomotive { get; private set; } - /// - /// Ширина окна - /// - private int? _pictureWidth; - /// - /// Высота окна - /// - private int? _pictureHeight; - /// - /// Левая координата прорисовки Электровоза - /// - private int? _startPosX; - /// - /// Верхняя кооридната прорисовки Электровоза - /// - private int? _startPosY; - - /// - /// Ширина прорисовки Локомотива - /// - private readonly int _drawningElectriLocomotiveWidth = 155; - /// - /// Высота прорисовки локомотива - /// - private readonly int _drawningElectricLocomotiveHeight = 100; - - /// - /// Инициализация свойств - /// - /// Скорость - /// Вес - /// Основной цвет - /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла - public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool pantograph, bool batterystorage) - { - EntityElectricLocomotive = new EntityElectricLocomotive(); - EntityElectricLocomotive.Init(speed, weight, bodyColor, additionalColor, - pantograph, batterystorage); - _pictureWidth = null; - _pictureHeight = null; - _startPosX = null; - _startPosY = null; - - } - /// - /// Установка границ поля - /// - /// Ширина поля - /// Высота поля - /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах -public bool SetPictureSize(int width, int height) - { - - // TODO проверка, что объект "влезает" в размеры поля - if(_drawningElectriLocomotiveWidth > width || _drawningElectricLocomotiveHeight > height) - { - return false; - } - if(_startPosX.HasValue && _startPosY.HasValue) - { - if(_startPosX + _drawningElectriLocomotiveWidth > width) - { - _startPosX = width - _drawningElectriLocomotiveWidth; - } - if(_startPosY + _drawningElectricLocomotiveHeight > height) - { - _startPosY = height - _drawningElectricLocomotiveHeight; - } - } - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена - _pictureWidth = width; - _pictureHeight = height; - return true; - } - public void SetPosition(int x, int y) - { - if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) - { - return; - } - // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы - if(x < 0 || x + _drawningElectriLocomotiveWidth > _pictureWidth.Value) - { - x = _pictureWidth.Value - _drawningElectriLocomotiveWidth; - } - if(y < 0 || y + _drawningElectricLocomotiveHeight > _pictureHeight.Value) - { - y = _pictureHeight.Value - _drawningElectricLocomotiveHeight; - } - // то надо изменить координаты, чтобы он оставался в этих границах - - _startPosX = x; - _startPosY = y; - } - public bool MoveTransport(DirectionType direction) - { - if (EntityElectricLocomotive == null || !_startPosX.HasValue || - !_startPosY.HasValue) - { - return false; - } - switch (direction) - { - //влево - case DirectionType.Left: - if (_startPosX.Value - EntityElectricLocomotive.Step > 0) - { - _startPosX -= (int)EntityElectricLocomotive.Step; - } - return true; - //вверх - case DirectionType.Up: - if ((_startPosY.Value) - EntityElectricLocomotive.Step > 0) - { - - _startPosY -= (int)EntityElectricLocomotive.Step; - } - return true; - // вправо - case DirectionType.Right: - if (_startPosX.Value + EntityElectricLocomotive.Step < _pictureWidth - _drawningElectriLocomotiveWidth) - { - _startPosX += (int)EntityElectricLocomotive.Step; - } - return true; - //вниз - case DirectionType.Down: - if (_startPosY.Value + EntityElectricLocomotive.Step < _pictureHeight - _drawningElectricLocomotiveHeight) - { - _startPosY += (int)EntityElectricLocomotive.Step; - } - return true; - default: - return false; - } - } - public void DrawTransport(Graphics g) - { - if (EntityElectricLocomotive == null || !_startPosX.HasValue || !_startPosY.HasValue) - { - return; - } - Pen pen = new(Color.Black); - Brush additonalBrush = new SolidBrush(EntityElectricLocomotive.AdditionalColor); - Brush bodyBrush = new SolidBrush(EntityElectricLocomotive.BodyColor); - //границы Электровоза - //колеса - g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 65, 20, 20); - g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 65, 20, 20); - g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 65, 20, 20); - g.DrawEllipse(pen, _startPosX.Value + 120, _startPosY.Value + 65, 20, 20); - //кузов - g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 50, 155, 40); - g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 50, _startPosX.Value + 20, _startPosY.Value + 30); - g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 30, 135,20 ); - //покраска кузова - g.FillEllipse(Brushes.Black, _startPosX.Value + 10, _startPosY.Value + 85, 20, 20); - g.FillEllipse(Brushes.Black, _startPosX.Value + 30, _startPosY.Value + 85, 20, 20); - g.FillEllipse(Brushes.Black, _startPosX.Value + 100, _startPosY.Value + 85, 20, 20); - g.FillEllipse(Brushes.Black, _startPosX.Value + 120, _startPosY.Value + 85, 20, 20); - g.FillRectangle(bodyBrush, _startPosX.Value+1, _startPosY.Value + 51, 154, 39); - g.FillRectangle(bodyBrush, _startPosX.Value + 21, _startPosY.Value + 31, 134, 19); - - g.DrawRectangle(pen, _startPosX.Value , _startPosY.Value + 50, 155, 10); - g.FillRectangle(additonalBrush, _startPosX.Value + 1, _startPosY.Value + 51, 154, 9); - //g.FillPolygon(Brushes.AliceBlue, _startPosX.Value + 1, _startPosY.Value + 31, _startPosX.Value + 19, _startPosY.Value + 9, _startPosX.Value + 19, _startPosY.Value + 1); - //Пантограф - if (EntityElectricLocomotive.Pantograph) - { - g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 30, _startPosX.Value + 70, _startPosY.Value + 10); - g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 10, _startPosX.Value + 90, _startPosY.Value + 10); - } - //Отсек для батарей - if (EntityElectricLocomotive.BatteryStorage) - { - g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value + 30, 30, 20); - g.FillRectangle(additonalBrush, _startPosX.Value + 101, _startPosY.Value + 31, 29, 19); - g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 40, _startPosX.Value + 115, _startPosY.Value + 50); - g.DrawLine(pen, _startPosX.Value + 115, _startPosY.Value + 40, _startPosX.Value + 120, _startPosY.Value + 40); - g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 30, _startPosX.Value + 115, _startPosY.Value + 40); - } - - } - - } - } - diff --git a/ProjectElectricLocomotive/DirectionType.cs b/ProjectElectricLocomotive/Drawnings/DirectionType.cs similarity index 91% rename from ProjectElectricLocomotive/DirectionType.cs rename to ProjectElectricLocomotive/Drawnings/DirectionType.cs index 8cec3e4..db3f0e7 100644 --- a/ProjectElectricLocomotive/DirectionType.cs +++ b/ProjectElectricLocomotive/Drawnings/DirectionType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ProjectElectricLocomotive +namespace ProjectElectricLocomotive.Drawnings { public enum DirectionType { diff --git a/ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs b/ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs new file mode 100644 index 0000000..2270eb2 --- /dev/null +++ b/ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectElectricLocomotive.Entities; + +namespace ProjectElectricLocomotive.Drawnings +{ + /// + /// Класс, отвечающий за отрисовку и перемещение обьекта-сущности + /// + public class DrawningElectricLocomotive: DrawningLocomotive + { + + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия обвеса + /// Признак наличия антикрыла + /// -------------------------------------------------------------------------- + /// Требуется конструктор, вызывать надо будет у класса EntityElectricLocomotive + /// ДОДЕЛАТЬ САМИМ!!! + public DrawningElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool pantograph, bool batterystorage) : base(155, 100) + { + EntityLocomotive = new EntityElectricLocomotive(speed, weight, bodyColor, additionalColor, + pantograph, batterystorage); + } + + public override void DrawTransport(Graphics g) + { + if (EntityLocomotive == null || EntityLocomotive is not EntityElectricLocomotive electricLocomotive || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + + + _startPosX += 0; + _startPosY += 0; + base.DrawTransport(g); + _startPosX -= 0; + _startPosY -= 0; + + Pen pen = new(Color.Black); + Brush additonalBrush = new SolidBrush(electricLocomotive.AdditionalColor); + Brush bodyBrush = new SolidBrush(electricLocomotive.BodyColor); + + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 50, 155, 10); + g.FillRectangle(additonalBrush, _startPosX.Value + 1, _startPosY.Value + 51, 154, 9); + + //Пантограф + if (electricLocomotive.Pantograph) + { + g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 30, _startPosX.Value + 70, _startPosY.Value + 10); + g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 10, _startPosX.Value + 90, _startPosY.Value + 10); + } + //Отсек для батарей + if (electricLocomotive.BatteryStorage) + { + g.DrawRectangle(pen, _startPosX.Value + 100, _startPosY.Value + 30, 30, 20); + g.FillRectangle(additonalBrush, _startPosX.Value + 101, _startPosY.Value + 31, 29, 19); + g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 40, _startPosX.Value + 115, _startPosY.Value + 50); + g.DrawLine(pen, _startPosX.Value + 115, _startPosY.Value + 40, _startPosX.Value + 120, _startPosY.Value + 40); + g.DrawLine(pen, _startPosX.Value + 120, _startPosY.Value + 30, _startPosX.Value + 115, _startPosY.Value + 40); + } + + } + + } +} + diff --git a/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs b/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs new file mode 100644 index 0000000..42fce8c --- /dev/null +++ b/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs @@ -0,0 +1,204 @@ +using ProjectElectricLocomotive.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.Drawnings; + +public class DrawningLocomotive +{ + + /// + /// Класс-сущность + /// + public EntityLocomotive? EntityLocomotive { get; protected set; } + /// + /// Ширина окна + /// + private int? _pictureWidth; + /// + /// Высота окна + /// + private int? _pictureHeight; + /// + /// Левая координата прорисовки Электровоза + /// + protected int? _startPosX; + /// + /// Верхняя кооридната прорисовки Электровоза + /// + protected int? _startPosY; + + /// + /// Ширина прорисовки Локомотива + /// + private readonly int _drawningLocomotiveWidth = 155; + /// + /// Высота прорисовки локомотива + /// + private readonly int _drawningLocomotiveHeight = 90; + + /// + /// Пустой конструктор + /// + private DrawningLocomotive() + { + + _pictureWidth = null; + _pictureHeight = null; + _startPosX = null; + _startPosY = null; + } + + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + + public DrawningLocomotive(int speed, double weight, Color bodyColor) : this() + { + EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor); + + } + /// + /// Конструктор для наследников + /// + /// Ширина прорисовки локомотива + /// Высота прорисовки локомотива + protected DrawningLocomotive(int drawningLocomotiveWidtе, int drawningLocomotiveHeight) : this() + { + _drawningLocomotiveHeight = drawningLocomotiveHeight; + _drawningLocomotiveWidth = drawningLocomotiveWidtе; + + } + + /// + /// Установка границ поля + /// + /// Ширина поля + /// Высота поля + /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах + public bool SetPictureSize(int width, int height) + { + + // TODO проверка, что объект "влезает" в размеры поля + if (_drawningLocomotiveWidth > width || _drawningLocomotiveHeight > height) + { + return false; + } + if (_startPosX.HasValue && _startPosY.HasValue) + { + if (_startPosX + _drawningLocomotiveWidth > width) + { + _startPosX = width - _drawningLocomotiveWidth; + } + if (_startPosY + _drawningLocomotiveHeight > height) + { + _startPosY = height - _drawningLocomotiveHeight; + } + } + //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена + _pictureWidth = width; + _pictureHeight = height; + return true; + } + public void SetPosition(int x, int y) + { + if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + { + return; + } + // TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы + if (x < 0 || x + _drawningLocomotiveWidth > _pictureWidth.Value) + { + x = _pictureWidth.Value - _drawningLocomotiveWidth; + } + if (y < 0 || y + _drawningLocomotiveHeight > _pictureHeight.Value) + { + y = _pictureHeight.Value - _drawningLocomotiveHeight; + } + // то надо изменить координаты, чтобы он оставался в этих границах + + _startPosX = x; + _startPosY = y; + } + public bool MoveTransport(DirectionType direction) + { + if (EntityLocomotive == null || !_startPosX.HasValue || + !_startPosY.HasValue) + { + return false; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX.Value - EntityLocomotive.Step > 0) + { + _startPosX -= (int)EntityLocomotive.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntityLocomotive.Step > 0) + { + + _startPosY -= (int)EntityLocomotive.Step; + } + return true; + // вправо + case DirectionType.Right: + if (_startPosX.Value + EntityLocomotive.Step < _pictureWidth - _drawningLocomotiveWidth) + { + _startPosX += (int)EntityLocomotive.Step; + } + return true; + //вниз + case DirectionType.Down: + if (_startPosY.Value + EntityLocomotive.Step < _pictureHeight - _drawningLocomotiveHeight) + { + _startPosY += (int)EntityLocomotive.Step; + } + return true; + default: + return false; + } + } + public virtual void DrawTransport(Graphics g) + { + if (EntityLocomotive == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + Pen pen = new(Color.Black); + Brush bodyBrush = new SolidBrush(EntityLocomotive.BodyColor); + //границы Электровоза + //колеса + g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 65, 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 65, 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 65, 20, 20); + g.DrawEllipse(pen, _startPosX.Value + 120, _startPosY.Value + 65, 20, 20); + //кузов + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 50, 155, 40); + g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 50, _startPosX.Value + 20, _startPosY.Value + 30); + g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 30, 135, 20); + //покраска кузова + g.FillEllipse(Brushes.Black, _startPosX.Value + 10, _startPosY.Value + 85, 20, 20); + g.FillEllipse(Brushes.Black, _startPosX.Value + 30, _startPosY.Value + 85, 20, 20); + g.FillEllipse(Brushes.Black, _startPosX.Value + 100, _startPosY.Value + 85, 20, 20); + g.FillEllipse(Brushes.Black, _startPosX.Value + 120, _startPosY.Value + 85, 20, 20); + g.FillRectangle(bodyBrush, _startPosX.Value + 1, _startPosY.Value + 51, 154, 39); + g.FillRectangle(bodyBrush, _startPosX.Value + 21, _startPosY.Value + 31, 134, 19); + + g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 50, 155, 10); + g.FillRectangle(bodyBrush, _startPosX.Value + 1, _startPosY.Value + 51, 154, 9); + + } + + +} diff --git a/ProjectElectricLocomotive/Entities/EntityElectricLocomotive.cs b/ProjectElectricLocomotive/Entities/EntityElectricLocomotive.cs new file mode 100644 index 0000000..344ab1d --- /dev/null +++ b/ProjectElectricLocomotive/Entities/EntityElectricLocomotive.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Design; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.Entities +{ + public class EntityElectricLocomotive : EntityLocomotive + { + + + public Color AdditionalColor { get; private set; } + /// + /// Признак (опция) "рогов" + /// + public bool Pantograph { get; private set; } + /// + /// Признак (опция) наличия отсека под батареи + /// + public bool BatteryStorage { get; private set; } + /// + /// Шаг перемещения Локомотива + /// + public double Step => Speed * 100 / Weight; + /// + /// Инициализация полей объекта-класса ЭлектроЛокомотива + /// + /// Дополнительный цвет + /// Признак "рогов" + /// Признак наличия отсека под батареи + /// ------------------------------------------------------------------------------ + /// Переписать!!!!!!!!! + /// САМИМ ТО ЧТО СНИЗУ!!!!!!!!!!!!!!!!!! + public EntityElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool pantograph + , bool batteryStorage) : base(speed, weight, bodyColor) + { + AdditionalColor = additionalColor; + Pantograph = pantograph; + BatteryStorage = batteryStorage; + } + + } +} diff --git a/ProjectElectricLocomotive/Entities/EntityLocomotive.cs b/ProjectElectricLocomotive/Entities/EntityLocomotive.cs new file mode 100644 index 0000000..30336a5 --- /dev/null +++ b/ProjectElectricLocomotive/Entities/EntityLocomotive.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.Entities +{ + /// + /// Класс-сущность "Локомотив" + /// + public class EntityLocomotive + { + /// + /// Скорость + /// + 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 EntityLocomotive(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + + + } + + } +} diff --git a/ProjectElectricLocomotive/EntityElectricLocomotive.cs b/ProjectElectricLocomotive/EntityElectricLocomotive.cs deleted file mode 100644 index a50bb96..0000000 --- a/ProjectElectricLocomotive/EntityElectricLocomotive.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectElectricLocomotive -{ - public class EntityElectricLocomotive - { - - /// - /// Скорость - /// - 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 Pantograph{ get; private set; } - /// - /// Признак (опция) наличия отсека под батареи - /// - public bool BatteryStorage { get; private set; } - /// - /// Шаг перемещения Локомотива - /// - public double Step => Speed * 100 / Weight; - /// - /// Инициализация полей объекта-класса ЭлектроЛокомотива - /// - /// Скорость - /// Вес локомотива - /// Основной цвет - /// Дополнительный цвет - /// Признак "рогов" - /// Признак наличия отсека под батареи - public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool pantograph, bool batterystorage) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; - AdditionalColor = additionalColor; - Pantograph = pantograph; - BatteryStorage = batterystorage; - - } - - } -} diff --git a/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs b/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs index 63d526c..5f21c43 100644 --- a/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs +++ b/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs @@ -34,6 +34,7 @@ buttonLeft = new Button(); buttonRight = new Button(); buttonDown = new Button(); + buttonCreateLocomotive = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).BeginInit(); SuspendLayout(); // @@ -46,16 +47,15 @@ pictureBoxElectricLocomotive.Size = new Size(779, 411); pictureBoxElectricLocomotive.TabIndex = 0; pictureBoxElectricLocomotive.TabStop = false; - // // buttonCreate // buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonCreate.Location = new Point(12, 353); buttonCreate.Name = "buttonCreate"; - buttonCreate.Size = new Size(112, 34); + buttonCreate.Size = new Size(263, 34); buttonCreate.TabIndex = 1; - buttonCreate.Text = "Создать"; + buttonCreate.Text = "Создать ЭлектроЛокомотив"; buttonCreate.UseVisualStyleBackColor = true; buttonCreate.Click += buttonCreate_Click; // @@ -107,11 +107,23 @@ buttonDown.UseVisualStyleBackColor = true; buttonDown.Click += ButtonMove_Click; // + // buttonCreateLocomotive + // + buttonCreateLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateLocomotive.Location = new Point(281, 353); + buttonCreateLocomotive.Name = "buttonCreateLocomotive"; + buttonCreateLocomotive.Size = new Size(263, 34); + buttonCreateLocomotive.TabIndex = 6; + buttonCreateLocomotive.Text = "Создать Локомотив"; + buttonCreateLocomotive.UseVisualStyleBackColor = true; + buttonCreateLocomotive.Click += buttonCreateLocomotive_Click; + // // FormlectricLocomotive // AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(788, 399); + Controls.Add(buttonCreateLocomotive); Controls.Add(buttonDown); Controls.Add(buttonRight); Controls.Add(buttonLeft); @@ -120,7 +132,6 @@ Controls.Add(pictureBoxElectricLocomotive); Name = "FormlectricLocomotive"; Text = "ЭлектроВоз"; - ((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).EndInit(); ResumeLayout(false); } @@ -133,5 +144,6 @@ private Button buttonLeft; private Button buttonRight; private Button buttonDown; + private Button buttonCreateLocomotive; } } \ No newline at end of file diff --git a/ProjectElectricLocomotive/FormlectricLocomotive.cs b/ProjectElectricLocomotive/FormlectricLocomotive.cs index 9d821fe..7f2d59b 100644 --- a/ProjectElectricLocomotive/FormlectricLocomotive.cs +++ b/ProjectElectricLocomotive/FormlectricLocomotive.cs @@ -8,6 +8,7 @@ using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using ProjectElectricLocomotive.Drawnings; namespace ProjectElectricLocomotive { @@ -15,41 +16,63 @@ namespace ProjectElectricLocomotive { private void Draw() { - if (_drawnningElectricLocomotive == null) + if (_drawnningLocomotive == null) { return; } Bitmap bmp = new(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); Graphics gr = Graphics.FromImage(bmp); - _drawnningElectricLocomotive.DrawTransport(gr); + _drawnningLocomotive.DrawTransport(gr); pictureBoxElectricLocomotive.Image = bmp; } - private DrawningElectricLocomotive? _drawnningElectricLocomotive; + private void CreateObject(string type) + { + Random random = new(); + switch (type) + { + case nameof(DrawningLocomotive): + _drawnningLocomotive = new DrawningLocomotive(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(DrawningElectricLocomotive): + _drawnningLocomotive = new DrawningElectricLocomotive(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; + } + _drawnningLocomotive.SetPictureSize(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); + _drawnningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); + + Draw(); + } + + private DrawningLocomotive? _drawnningLocomotive; public FormlectricLocomotive() { InitializeComponent(); } - - private void buttonCreate_Click(object sender, EventArgs e) - { - Random random = new(); - _drawnningElectricLocomotive = new DrawningElectricLocomotive(); - _drawnningElectricLocomotive.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))); - _drawnningElectricLocomotive.SetPictureSize(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); - _drawnningElectricLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); - - Draw(); - } + /// + /// Обработка кнопки создать "ЭлектроЛокомотив" + /// + /// + /// + private void buttonCreate_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningElectricLocomotive)); + /// + /// Обработка нажатия кнопки создать "Локомотив" + /// + /// + /// + private void buttonCreateLocomotive_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLocomotive)); private void ButtonMove_Click(object sender, EventArgs e) { - if (_drawnningElectricLocomotive == null) + if (_drawnningLocomotive == null) { return; } @@ -59,19 +82,19 @@ namespace ProjectElectricLocomotive { case "buttonUp": result = - _drawnningElectricLocomotive.MoveTransport(DirectionType.Up); + _drawnningLocomotive.MoveTransport(DirectionType.Up); break; case "buttonDown": result = - _drawnningElectricLocomotive.MoveTransport(DirectionType.Down); + _drawnningLocomotive.MoveTransport(DirectionType.Down); break; case "buttonLeft": result = - _drawnningElectricLocomotive.MoveTransport(DirectionType.Left); + _drawnningLocomotive.MoveTransport(DirectionType.Left); break; case "buttonRight": result = - _drawnningElectricLocomotive.MoveTransport(DirectionType.Right); + _drawnningLocomotive.MoveTransport(DirectionType.Right); break; } if (result) @@ -80,5 +103,7 @@ namespace ProjectElectricLocomotive } } + + } } -- 2.25.1 From a8fa0803252ef5ec738e310f2475961433f48778 Mon Sep 17 00:00:00 2001 From: Tonb73 Date: Sun, 3 Mar 2024 17:28:20 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=8F=20=D1=81=D1=82=D1=80=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=B3=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drawnings/DirectionType.cs | 4 + .../Drawnings/DrawningLocomotive.cs | 19 +++ .../FormlectricLocomotive.Designer.cs | 26 ++++ .../FormlectricLocomotive.cs | 56 ++++++- .../MovementStrategy/AbstractStrategy.cs | 142 ++++++++++++++++++ .../MovementStrategy/IMovableObject.cs | 32 ++++ .../MovementStrategy/MoveToBorder.cs | 57 +++++++ .../MovementStrategy/MoveToCenter.cs | 57 +++++++ .../MovementStrategy/MoveableLocomotive.cs | 65 ++++++++ .../MovementStrategy/MovementDirection.cs | 27 ++++ .../MovementStrategy/ObjectParameters.cs | 78 ++++++++++ .../MovementStrategy/StrategyStatus.cs | 23 +++ 12 files changed, 580 insertions(+), 6 deletions(-) create mode 100644 ProjectElectricLocomotive/MovementStrategy/AbstractStrategy.cs create mode 100644 ProjectElectricLocomotive/MovementStrategy/IMovableObject.cs create mode 100644 ProjectElectricLocomotive/MovementStrategy/MoveToBorder.cs create mode 100644 ProjectElectricLocomotive/MovementStrategy/MoveToCenter.cs create mode 100644 ProjectElectricLocomotive/MovementStrategy/MoveableLocomotive.cs create mode 100644 ProjectElectricLocomotive/MovementStrategy/MovementDirection.cs create mode 100644 ProjectElectricLocomotive/MovementStrategy/ObjectParameters.cs create mode 100644 ProjectElectricLocomotive/MovementStrategy/StrategyStatus.cs diff --git a/ProjectElectricLocomotive/Drawnings/DirectionType.cs b/ProjectElectricLocomotive/Drawnings/DirectionType.cs index db3f0e7..ba08627 100644 --- a/ProjectElectricLocomotive/Drawnings/DirectionType.cs +++ b/ProjectElectricLocomotive/Drawnings/DirectionType.cs @@ -8,6 +8,10 @@ namespace ProjectElectricLocomotive.Drawnings { public enum DirectionType { + /// + /// Неизвестное направление + /// + Unknow = -1, /// /// Вверх /// diff --git a/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs b/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs index 42fce8c..e05df50 100644 --- a/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs +++ b/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs @@ -39,7 +39,26 @@ public class DrawningLocomotive /// Высота прорисовки локомотива /// private readonly int _drawningLocomotiveHeight = 90; + + /// + /// Координата X объекта + /// + public int? GetPosX => _startPosX; + + /// + /// Координата Y объекта + /// + public int? GetPosY => _startPosY; + + /// + /// Ширина объекта + /// + public int GetWidth => _drawningLocomotiveWidth; + /// + /// Высота объекта + /// + public int GetHeight => _drawningLocomotiveHeight; /// /// Пустой конструктор /// diff --git a/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs b/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs index 5f21c43..725b4ff 100644 --- a/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs +++ b/ProjectElectricLocomotive/FormlectricLocomotive.Designer.cs @@ -35,6 +35,8 @@ buttonRight = new Button(); buttonDown = new Button(); buttonCreateLocomotive = new Button(); + comboBoxStrategy = new ComboBox(); + buttonStrategyStep = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).BeginInit(); SuspendLayout(); // @@ -118,11 +120,33 @@ buttonCreateLocomotive.UseVisualStyleBackColor = true; buttonCreateLocomotive.Click += buttonCreateLocomotive_Click; // + // comboBoxStrategy + // + comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStrategy.FormattingEnabled = true; + comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" }); + comboBoxStrategy.Location = new Point(594, 12); + comboBoxStrategy.Name = "comboBoxStrategy"; + comboBoxStrategy.Size = new Size(182, 33); + comboBoxStrategy.TabIndex = 7; + // + // buttonStrategyStep + // + buttonStrategyStep.Location = new Point(664, 51); + buttonStrategyStep.Name = "buttonStrategyStep"; + buttonStrategyStep.Size = new Size(112, 34); + buttonStrategyStep.TabIndex = 8; + buttonStrategyStep.Text = "Шаг"; + buttonStrategyStep.UseVisualStyleBackColor = true; + buttonStrategyStep.Click += buttonStrategyStep_Click; + // // FormlectricLocomotive // AutoScaleDimensions = new SizeF(10F, 25F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(788, 399); + Controls.Add(buttonStrategyStep); + Controls.Add(comboBoxStrategy); Controls.Add(buttonCreateLocomotive); Controls.Add(buttonDown); Controls.Add(buttonRight); @@ -145,5 +169,7 @@ private Button buttonRight; private Button buttonDown; private Button buttonCreateLocomotive; + private ComboBox comboBoxStrategy; + private Button buttonStrategyStep; } } \ No newline at end of file diff --git a/ProjectElectricLocomotive/FormlectricLocomotive.cs b/ProjectElectricLocomotive/FormlectricLocomotive.cs index 7f2d59b..68036f4 100644 --- a/ProjectElectricLocomotive/FormlectricLocomotive.cs +++ b/ProjectElectricLocomotive/FormlectricLocomotive.cs @@ -9,11 +9,23 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ProjectElectricLocomotive.Drawnings; +using ProjectElectricLocomotive.MovementStrategy; namespace ProjectElectricLocomotive { public partial class FormlectricLocomotive : Form { + /// + /// Стратегия перемещения + /// + private AbstractStrategy? _strategy; + + public FormlectricLocomotive() + { + InitializeComponent(); + _strategy = null; + } + private void Draw() { if (_drawnningLocomotive == null) @@ -47,15 +59,13 @@ namespace ProjectElectricLocomotive } _drawnningLocomotive.SetPictureSize(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); _drawnningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); - + _strategy = null; + comboBoxStrategy.Enabled = true; Draw(); } private DrawningLocomotive? _drawnningLocomotive; - public FormlectricLocomotive() - { - InitializeComponent(); - } + /// /// Обработка кнопки создать "ЭлектроЛокомотив" @@ -104,6 +114,40 @@ namespace ProjectElectricLocomotive } - + + private void buttonStrategyStep_Click(object sender, EventArgs e) + { + if (_drawnningLocomotive == null) + { + return; + } + if (comboBoxStrategy.Enabled) + { + _strategy = comboBoxStrategy.SelectedIndex switch + { + 0 => new MoveToCenter(), + 1 => new MoveToBorder(), + _ => null, + }; + if (_strategy == null) + { + return; + } + _strategy.SetData(new MoveableLocomotive(_drawnningLocomotive), + pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); + } + if (_strategy == null) + { + return; + } + comboBoxStrategy.Enabled = false; + _strategy.MakeStep(); + Draw(); + if (_strategy.GetStatus() == StrategyStatus.Finish) + { + comboBoxStrategy.Enabled = true; + _strategy = null; + } + } } } diff --git a/ProjectElectricLocomotive/MovementStrategy/AbstractStrategy.cs b/ProjectElectricLocomotive/MovementStrategy/AbstractStrategy.cs new file mode 100644 index 0000000..c1c9b32 --- /dev/null +++ b/ProjectElectricLocomotive/MovementStrategy/AbstractStrategy.cs @@ -0,0 +1,142 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.MovementStrategy; + +public abstract class AbstractStrategy +{ + /// + /// Перемещаемый объект + /// + private IMovableObject _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(IMovableObject moveableObject, int width, int height) + { + if (moveableObject == null) + { + _state = StrategyStatus.NotInit; + return; + } + + _state = StrategyStatus.InProgress; + _moveableObject = moveableObject; + FieldWidth = width; + FieldHeight = height; + } + + /// + /// Шаг перемещения + /// + public void MakeStep() + { + if (_state != StrategyStatus.InProgress) + { + return; + } + + if (IsTargetDestinaion()) + { + _state = StrategyStatus.Finish; + return; + } + + MoveToTarget(); + } + + /// + /// Перемещение влево + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveLeft() => MoveTo(MovementDirection.Left); + + /// + /// Перемещение вправо + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveRight() => MoveTo(MovementDirection.Right); + + /// + /// Перемещение вверх + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveUp() => MoveTo(MovementDirection.Up); + + /// + /// Перемещение вниз + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveDown() => MoveTo(MovementDirection.Down); + + /// + /// Параметры объекта + /// + protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition; + + /// + /// Шаг объекта + /// + /// + protected int? GetStep() + { + if (_state != StrategyStatus.InProgress) + { + return null; + } + return _moveableObject?.GetStep; + } + + /// + /// Перемещение к цели + /// + protected abstract void MoveToTarget(); + + /// + /// Достигнута ли цель + /// + /// + protected abstract bool IsTargetDestinaion(); + + /// + /// Попытка перемещения в требуемом направлении + /// + /// Направление + /// Результат попытки (true - удалось переместиться, false - неудача) + private bool MoveTo(MovementDirection movementDirection) + { + if (_state != StrategyStatus.InProgress) + { + return false; + } + + return _moveableObject?.TryMoveObject(movementDirection) ?? false; + } +} diff --git a/ProjectElectricLocomotive/MovementStrategy/IMovableObject.cs b/ProjectElectricLocomotive/MovementStrategy/IMovableObject.cs new file mode 100644 index 0000000..f67d1b3 --- /dev/null +++ b/ProjectElectricLocomotive/MovementStrategy/IMovableObject.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.MovementStrategy; + +/// +/// Интерфейс для работы с перемещаемыми объектами +/// +public interface IMovableObject +{ + + /// + /// Получение координаты объекта + /// + ObjectParameters? GetObjectPosition { get; } + + /// + /// Шаг объекта + /// + int GetStep { get; } + + /// + /// Попытка переместить объект в указанном направлении + /// + /// направление + /// true - объект перемещен , false - перемещение невозможно + bool TryMoveObject(MovementDirection direction); + +} diff --git a/ProjectElectricLocomotive/MovementStrategy/MoveToBorder.cs b/ProjectElectricLocomotive/MovementStrategy/MoveToBorder.cs new file mode 100644 index 0000000..b03ad9e --- /dev/null +++ b/ProjectElectricLocomotive/MovementStrategy/MoveToBorder.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.MovementStrategy; + +public class MoveToBorder : AbstractStrategy +{ + protected override bool IsTargetDestinaion() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + + return objParams.RightBorder - GetStep() <= FieldWidth && objParams.RightBorder + GetStep() >= FieldWidth && + objParams.DownBorder - GetStep() <= FieldHeight && objParams.DownBorder + GetStep() >= FieldHeight; + } + + protected override void MoveToTarget() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + + int diffX = objParams.RightBorder - FieldWidth; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + + int diffY = objParams.DownBorder - FieldHeight; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } +} diff --git a/ProjectElectricLocomotive/MovementStrategy/MoveToCenter.cs b/ProjectElectricLocomotive/MovementStrategy/MoveToCenter.cs new file mode 100644 index 0000000..3203774 --- /dev/null +++ b/ProjectElectricLocomotive/MovementStrategy/MoveToCenter.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.MovementStrategy; + +public class MoveToCenter : AbstractStrategy +{ + protected override bool IsTargetDestinaion() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + + return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; + } + + protected override void MoveToTarget() + { + ObjectParameters? objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + + int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + + int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } +} diff --git a/ProjectElectricLocomotive/MovementStrategy/MoveableLocomotive.cs b/ProjectElectricLocomotive/MovementStrategy/MoveableLocomotive.cs new file mode 100644 index 0000000..fe58fb3 --- /dev/null +++ b/ProjectElectricLocomotive/MovementStrategy/MoveableLocomotive.cs @@ -0,0 +1,65 @@ +using ProjectElectricLocomotive.Drawnings; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.MovementStrategy +{ + public class MoveableLocomotive : IMovableObject + { + + private readonly DrawningLocomotive? _locomotive = null; + + public MoveableLocomotive(DrawningLocomotive locomotive) + { + _locomotive = locomotive; + } + + public ObjectParameters? GetObjectPosition + { + get + { + if (_locomotive == null || _locomotive.EntityLocomotive == null || !_locomotive.GetPosX.HasValue || !_locomotive.GetPosY.HasValue) + { + return null; + } + return new ObjectParameters(_locomotive.GetPosX.Value, _locomotive.GetPosY.Value, _locomotive.GetWidth, _locomotive.GetHeight); + } + } + + + + public int GetStep => (int)(_locomotive?.EntityLocomotive?.Step ?? 0); + + + + public bool TryMoveObject(MovementDirection direction) + { + if (_locomotive == null || _locomotive.EntityLocomotive == null) + { + return false; + } + + return _locomotive.MoveTransport(GetDirectionType(direction)); + } + + /// + /// Конвертация из MovementDirection в DirectionType + /// + /// MovementDirection + /// DirectionType + private static DirectionType GetDirectionType(MovementDirection direction) + { + return direction switch + { + MovementDirection.Left => DirectionType.Left, + MovementDirection.Right => DirectionType.Right, + MovementDirection.Up => DirectionType.Up, + MovementDirection.Down => DirectionType.Down, + _ => DirectionType.Unknow, + }; + } + } +} diff --git a/ProjectElectricLocomotive/MovementStrategy/MovementDirection.cs b/ProjectElectricLocomotive/MovementStrategy/MovementDirection.cs new file mode 100644 index 0000000..b2965ea --- /dev/null +++ b/ProjectElectricLocomotive/MovementStrategy/MovementDirection.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.MovementStrategy; + +public enum MovementDirection +{ + /// + /// Вверх + /// + Up = 1, + /// + /// Вниз + /// + Down = 2, + /// + /// Влево + /// + Left = 3, + /// + /// Вправо + /// + Right = 4 +} diff --git a/ProjectElectricLocomotive/MovementStrategy/ObjectParameters.cs b/ProjectElectricLocomotive/MovementStrategy/ObjectParameters.cs new file mode 100644 index 0000000..9a0f6eb --- /dev/null +++ b/ProjectElectricLocomotive/MovementStrategy/ObjectParameters.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.MovementStrategy +{ + public class ObjectParameters + { + /// + /// Координата X + /// + private readonly int _x; + + /// + /// Координата Y + /// + private readonly int _y; + + /// + /// Ширина обьекта + /// + private readonly int _width; + + /// + /// Высота обьекта + /// + private readonly int _height; + + /// + /// Левая граница + /// + public int LeftBorder => _x; + + /// + /// Вернхняя граница + /// + public int TopBorder => _y; + + /// + /// Правая граница + /// + public int RightBorder => _x + _width; + + /// + /// Нижняя граница + /// + public int DownBorder => _y + _height; + + /// + /// Середина обьекта + /// + public int ObjectMiddleHorizontal => _x + _width / 2; + + /// + /// Середина обьекта + /// + public int ObjectMiddleVertical => _y + _height / 2; + + /// + /// Конструктор + /// + /// Координата X + /// Координата Y + /// Ширина объекта + /// Высота объекта + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + } + + + } +} diff --git a/ProjectElectricLocomotive/MovementStrategy/StrategyStatus.cs b/ProjectElectricLocomotive/MovementStrategy/StrategyStatus.cs new file mode 100644 index 0000000..737c149 --- /dev/null +++ b/ProjectElectricLocomotive/MovementStrategy/StrategyStatus.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.MovementStrategy; + +public enum StrategyStatus +{ + /// + /// Все готово к началу + /// + NotInit, + /// + /// Выполняется + /// + InProgress, + /// + /// Завершено + /// + Finish +} -- 2.25.1 From 7fb180fd99d56f69e65fb7a66cbff088cf16511a Mon Sep 17 00:00:00 2001 From: Tonb73 Date: Mon, 4 Mar 2024 07:54:59 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=D1=8E=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Drawnings/DrawningElectricLocomotive.cs | 1 + ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs b/ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs index 2270eb2..6fb4841 100644 --- a/ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs +++ b/ProjectElectricLocomotive/Drawnings/DrawningElectricLocomotive.cs @@ -32,6 +32,7 @@ namespace ProjectElectricLocomotive.Drawnings pantograph, batterystorage); } + public override void DrawTransport(Graphics g) { if (EntityLocomotive == null || EntityLocomotive is not EntityElectricLocomotive electricLocomotive || !_startPosX.HasValue || !_startPosY.HasValue) diff --git a/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs b/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs index e05df50..605506c 100644 --- a/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs +++ b/ProjectElectricLocomotive/Drawnings/DrawningLocomotive.cs @@ -34,11 +34,11 @@ public class DrawningLocomotive /// /// Ширина прорисовки Локомотива /// - private readonly int _drawningLocomotiveWidth = 155; + public readonly int _drawningLocomotiveWidth = 155; /// /// Высота прорисовки локомотива /// - private readonly int _drawningLocomotiveHeight = 90; + public readonly int _drawningLocomotiveHeight = 90; /// /// Координата X объекта @@ -146,7 +146,7 @@ public class DrawningLocomotive _startPosX = x; _startPosY = y; } - public bool MoveTransport(DirectionType direction) + public bool MoveTransport(DirectionType direction) { if (EntityLocomotive == null || !_startPosX.HasValue || !_startPosY.HasValue) -- 2.25.1