From 0245de20ced3efc7240a907ba895369da3060fdb Mon Sep 17 00:00:00 2001 From: tellsense Date: Sun, 15 Oct 2023 19:44:24 +0400 Subject: [PATCH 1/5] =?UTF-8?q?(=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D0=BE=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B13)=20=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE=D0=B2=20Set?= =?UTF-8?q?Generic=20=D0=B8=20LocomotivesGenericCollection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LocomotivesGenericCollection.cs | 139 ++++++++++++++++++ .../ElectricLocomotive/SetGeneric.cs | 80 ++++++++++ 2 files changed, 219 insertions(+) create mode 100644 ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs create mode 100644 ElectricLocomotive/ElectricLocomotive/SetGeneric.cs diff --git a/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs b/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs new file mode 100644 index 0000000..509f7a3 --- /dev/null +++ b/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectElectricLocomotive.DrawingObjects; +using ProjectElectricLocomotive.MovementStrategy; + +namespace ProjectElectricLocomotive.Generics +{ + /// + /// Параметризованный класс для набора объектов DrawningCar + /// + /// + /// + internal class LocomotivesGenericCollection + where T : DrawingObjects + where U : IMoveableObject + { + /// + /// Ширина окна прорисовки + /// + private readonly int _pictureWidth; + /// + /// Высота окна прорисовки + /// + private readonly int _pictureHeight; + /// + /// Размер занимаемого объектом места (ширина) + /// + private readonly int _placeSizeWidth = 210; + /// + /// Размер занимаемого объектом места (высота) + /// + private readonly int _placeSizeHeight = 90; + /// + /// Набор объектов + /// + private readonly SetGeneric _collection; + /// + /// Конструктор + /// + /// + /// + public LocomotivesGenericCollection(int picWidth, int picHeight) + { + int width = picWidth / _placeSizeWidth; + int height = picHeight / _placeSizeHeight; + _pictureWidth = picWidth; + _pictureHeight = picHeight; + _collection = new SetGeneric(width * height); + } + /// + /// Перегрузка оператора сложения + /// + /// + /// + /// + public static bool operator +(LocomotivesGenericCollection collect, T? + obj) + { + if (obj == null) + { + return false; + } + return collect?._collection.Insert(obj) ?? false; + } + /// + /// Перегрузка оператора вычитания + /// + /// + /// + /// + public static T? operator -(LocomotivesGenericCollection collect, int + pos) + { + T? obj = collect._collection.Get(pos); + if (obj != null) + { + collect._collection.Remove(pos); + } + return obj; + } + /// + /// Получение объекта IMoveableObject + /// + /// + /// + public U? GetU(int pos) + { + return (U?)_collection.Get(pos)?.GetMoveableObject; + } + /// + /// Вывод всего набора объектов + /// + /// + public Bitmap ShowCars() + { + Bitmap bmp = new(_pictureWidth, _pictureHeight); + Graphics gr = Graphics.FromImage(bmp); + DrawBackground(gr); + DrawObjects(gr); + return bmp; + } + /// + /// Метод отрисовки фона + /// + /// + private void DrawBackground(Graphics g) + { + Pen pen = new(Color.Black, 3); + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) + { + for (int j = 0; j < _pictureHeight / _placeSizeHeight + + 1; ++j) + {//линия рамзетки места + g.DrawLine(pen, i * _placeSizeWidth, j * + _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * + _placeSizeHeight); + } + g.DrawLine(pen, i * _placeSizeWidth, 0, i * + _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); + } + } + /// + /// Метод прорисовки объектов + /// + /// + private void DrawObjects(Graphics g) + { + for (int i = 0; i < _collection.Count; i++) + { + // TODO получение объекта + // TODO установка позиции + // TODO прорисовка объекта + } + } + } +} diff --git a/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs b/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs new file mode 100644 index 0000000..7b9b45b --- /dev/null +++ b/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectElectricLocomotive.Generics +{ + /// + /// Параметризованный набор объектов + /// + /// + internal class SetGeneric + where T : class + { + /// + /// Массив объектов, которые храним + /// + private readonly T?[] _places; + /// + /// Количество объектов в массиве + /// + public int Count => _places.Length; + /// + /// Конструктор + /// + /// + public SetGeneric(int count) + { + _places = new T?[count]; + } + /// + /// Добавление объекта в набор + /// + /// Добавляемый автомобиль + /// + public bool Insert(T car) + { + // TODO вставка в начало набора + return true; + } + /// + /// Добавление объекта в набор на конкретную позицию + /// + /// Добавляемый автомобиль + /// Позиция + /// + public bool Insert(T car, int position) + { + // TODO проверка позиции + // TODO проверка, что элемент массива по этой позиции пустой, если нет, то + // проверка, что после вставляемого элемента в массиве есть пустой элемент + // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента + // TODO вставка по позиции + _places[position] = car; + return true; + } + /// + /// Удаление объекта из набора с конкретной позиции + /// + /// + /// + public bool Remove(int position) + { + // TODO проверка позиции + // TODO удаление объекта из массива, присвоив элементу массива значение null + return true; + } + /// + /// Получение объекта из набора по позиции + /// + /// + /// + public T? Get(int position) + { + // TODO проверка позиции + return _places[position]; + } + } +} -- 2.25.1 From f7feca445e9b58f36db37a6beab591223dab5302 Mon Sep 17 00:00:00 2001 From: tellsense Date: Sun, 15 Oct 2023 23:04:50 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=97=D0=B0=D0=B2=D0=B5=D1=80=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=203=20=D0=BB=D0=B0=D0=B1=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...motive.cs => DrawingElectricLocomotive.cs} | 0 ...ningLocomotive.cs => DrawingLocomotive.cs} | 6 + ...comotive.cs => DrawingObjectLocomotive.cs} | 0 .../FormElectricLocomotive.Designer.cs | 22 ++- .../FormElectricLocomotive.cs | 69 +++++---- .../FormLocomotiveCollection.Designer.cs | 140 ++++++++++++++++++ .../FormLocomotiveCollection.cs | 75 ++++++++++ .../FormLocomotiveCollection.resx | 120 +++++++++++++++ .../LocomotivesGenericCollection.cs | 96 +++--------- .../ElectricLocomotive/ObjectParameters.cs | 3 - .../ElectricLocomotive/Program.cs | 10 +- .../ElectricLocomotive/SetGeneric.cs | 85 +++++------ 12 files changed, 464 insertions(+), 162 deletions(-) rename ElectricLocomotive/ElectricLocomotive/{DrawningElectricLocomotive.cs => DrawingElectricLocomotive.cs} (100%) rename ElectricLocomotive/ElectricLocomotive/{DrawningLocomotive.cs => DrawingLocomotive.cs} (96%) rename ElectricLocomotive/ElectricLocomotive/{DrawningObjectLocomotive.cs => DrawingObjectLocomotive.cs} (100%) create mode 100644 ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.Designer.cs create mode 100644 ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs create mode 100644 ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.resx diff --git a/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawingElectricLocomotive.cs similarity index 100% rename from ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs rename to ElectricLocomotive/ElectricLocomotive/DrawingElectricLocomotive.cs diff --git a/ElectricLocomotive/ElectricLocomotive/DrawningLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs similarity index 96% rename from ElectricLocomotive/ElectricLocomotive/DrawningLocomotive.cs rename to ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs index 49bcf18..cb7949e 100644 --- a/ElectricLocomotive/ElectricLocomotive/DrawningLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using ElectricLocomotive; using ProjectElectricLocomotive.Entities; +using ProjectElectricLocomotive.MovementStrategy; using ProjectElectricLocomotive.Properties; using static System.Windows.Forms.VisualStyles.VisualStyleElement; @@ -180,5 +181,10 @@ namespace ProjectElectricLocomotive.DrawingObjects Direction.Down => _startPosY + EntityLocomotive.Step < _pictureHeight, }; } + /// + /// Получение объекта IMoveableObject из объекта DrawningCar + /// + public IMoveableObject GetMoveableObject => new + DrawingObjectLocomotive(this); } } diff --git a/ElectricLocomotive/ElectricLocomotive/DrawningObjectLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawingObjectLocomotive.cs similarity index 100% rename from ElectricLocomotive/ElectricLocomotive/DrawningObjectLocomotive.cs rename to ElectricLocomotive/ElectricLocomotive/DrawingObjectLocomotive.cs diff --git a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.Designer.cs b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.Designer.cs index a828c5b..a44ff89 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.Designer.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.Designer.cs @@ -2,7 +2,7 @@ namespace ElectricLocomotive { - partial class ElectricLocomotive + partial class FormElectricLocomotive { /// /// Required designer variable. @@ -39,6 +39,7 @@ namespace ElectricLocomotive comboBoxStrategy = new ComboBox(); buttonCreateLocomotive = new Button(); buttonStep = new Button(); + button1 = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).BeginInit(); SuspendLayout(); // @@ -157,13 +158,24 @@ namespace ElectricLocomotive buttonStep.TabIndex = 8; buttonStep.Text = "Шаг"; buttonStep.UseVisualStyleBackColor = true; - buttonStep.Click += buttonStep_Click; + buttonStep.Click += buttonStrategyStep_Click; // - // ElectricLocomotive + // button1 + // + button1.Location = new Point(256, 365); + button1.Name = "button1"; + button1.Size = new Size(206, 64); + button1.TabIndex = 9; + button1.Text = "Выбрать локомотив"; + button1.UseVisualStyleBackColor = true; + button1.Click += ButtonSelectLocomotive_Click; + // + // FormElectricLocomotive // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(847, 441); + Controls.Add(button1); Controls.Add(buttonStep); Controls.Add(buttonCreateLocomotive); Controls.Add(comboBoxStrategy); @@ -174,9 +186,10 @@ namespace ElectricLocomotive Controls.Add(buttonCreateElectricLocomotive); Controls.Add(pictureBoxElectricLocomotive); Margin = new Padding(2); - Name = "ElectricLocomotive"; + Name = "FormElectricLocomotive"; StartPosition = FormStartPosition.CenterScreen; Text = "ElectricLocomotive"; + Load += ElectricLocomotive_Load; ((System.ComponentModel.ISupportInitialize)pictureBoxElectricLocomotive).EndInit(); ResumeLayout(false); PerformLayout(); @@ -193,5 +206,6 @@ namespace ElectricLocomotive private ComboBox comboBoxStrategy; private Button buttonCreateLocomotive; private Button buttonStep; + private Button button1; } } \ No newline at end of file diff --git a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs index a7d53ce..c869db9 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs @@ -1,24 +1,22 @@ - -using ProjectElectricLocomotive; using ProjectElectricLocomotive.DrawingObjects; using ProjectElectricLocomotive.MovementStrategy; +using ProjectElectricLocomotive; using System; namespace ElectricLocomotive { - public partial class ElectricLocomotive : Form + public partial class FormElectricLocomotive : Form { - private DrawingLocomotive? _drawningLocomotive; - private AbstractStrategy? _abstractStrategy; - - public ElectricLocomotive() + public DrawingLocomotive? SelectedLocomotive { get; private set; } + public FormElectricLocomotive() { InitializeComponent(); + _abstractStrategy = null; + SelectedLocomotive = null; } - private void Draw() { if (_drawningLocomotive == null) @@ -30,29 +28,44 @@ namespace ElectricLocomotive _drawningLocomotive.DrawTransport(gr); pictureBoxElectricLocomotive.Image = bmp; } - private void buttonCreateElectricLocomotive_Click(object sender, EventArgs e) { Random random = new Random(); - _drawningLocomotive = new DrawingElectricLocomotive(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)), + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + ColorDialog colorDialog = new ColorDialog(); + if (colorDialog.ShowDialog() == DialogResult.OK) + { + color = colorDialog.Color; + } + Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + if (colorDialog.ShowDialog() == DialogResult.OK) + { + dopColor = colorDialog.Color; + } + _drawningLocomotive = new DrawingElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); _drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } - private void buttonCreateLocomotive_Click(object sender, EventArgs e) { - Random rnd = new Random(); - _drawningLocomotive = new DrawingLocomotive(rnd.Next(100, 300), rnd.Next(1000, 3000), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), - pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); - _drawningLocomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100)); + Random random = new(); + 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; + } + _drawningLocomotive = new DrawingLocomotive(random.Next(100, 300), + random.Next(1000, 3000), color, + pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); + _drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, + 100)); Draw(); - } + } private void buttonMove_Click(object sender, EventArgs e) { if (_drawningLocomotive == null) @@ -77,8 +90,7 @@ namespace ElectricLocomotive } Draw(); } - - private void buttonStep_Click(object sender, EventArgs e) + private void buttonStrategyStep_Click(object sender, EventArgs e) { if (_drawningLocomotive == null) { @@ -96,9 +108,7 @@ namespace ElectricLocomotive { return; } - _abstractStrategy.SetData(new - DrawingObjectLocomotive(_drawningLocomotive), pictureBoxElectricLocomotive.Width, - pictureBoxElectricLocomotive.Height); + _abstractStrategy.SetData(new DrawingObjectLocomotive(_drawningLocomotive), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); comboBoxStrategy.Enabled = false; } if (_abstractStrategy == null) @@ -113,15 +123,22 @@ namespace ElectricLocomotive _abstractStrategy = null; } } - private void comboBoxStrategy_SelectedIndexChanged(object sender, EventArgs e) { } - private void pictureBoxElectricLocomotive_Click(object sender, EventArgs e) { } + private void ElectricLocomotive_Load(object sender, EventArgs e) + { + + } + private void ButtonSelectLocomotive_Click(object sender, EventArgs e) + { + SelectedLocomotive = _drawningLocomotive; + DialogResult = DialogResult.OK; + } } } \ No newline at end of file diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.Designer.cs b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.Designer.cs new file mode 100644 index 0000000..e829010 --- /dev/null +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.Designer.cs @@ -0,0 +1,140 @@ +namespace ProjectElectricLocomotive +{ + partial class FormLocomotiveCollection + { + /// + /// 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() + { + panelLocomotiveCollection = new Panel(); + maskedTextBoxNumber = new MaskedTextBox(); + ButtonRefreshCollection = new Button(); + ButtonRemoveLocomotive = new Button(); + ButtonAddLocomotive = new Button(); + pictureBoxCollection = new PictureBox(); + LabelOnPanel = new Label(); + panelLocomotiveCollection.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); + SuspendLayout(); + // + // panelLocomotiveCollection + // + panelLocomotiveCollection.AccessibleDescription = ""; + panelLocomotiveCollection.AccessibleName = ""; + panelLocomotiveCollection.Controls.Add(LabelOnPanel); + panelLocomotiveCollection.Controls.Add(maskedTextBoxNumber); + panelLocomotiveCollection.Controls.Add(ButtonRefreshCollection); + panelLocomotiveCollection.Controls.Add(ButtonRemoveLocomotive); + panelLocomotiveCollection.Controls.Add(ButtonAddLocomotive); + panelLocomotiveCollection.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); + panelLocomotiveCollection.Location = new Point(594, 2); + panelLocomotiveCollection.Name = "panelLocomotiveCollection"; + panelLocomotiveCollection.Size = new Size(208, 448); + panelLocomotiveCollection.TabIndex = 0; + panelLocomotiveCollection.Tag = "Инструменты"; + panelLocomotiveCollection.Paint += panelLocomotiveCollection_Paint; + // + // maskedTextBoxNumber + // + maskedTextBoxNumber.Location = new Point(40, 74); + maskedTextBoxNumber.Name = "maskedTextBoxNumber"; + maskedTextBoxNumber.Size = new Size(123, 23); + maskedTextBoxNumber.TabIndex = 3; + // + // ButtonRefreshCollection + // + ButtonRefreshCollection.Location = new Point(3, 194); + ButtonRefreshCollection.Name = "ButtonRefreshCollection"; + ButtonRefreshCollection.Size = new Size(194, 43); + ButtonRefreshCollection.TabIndex = 2; + ButtonRefreshCollection.Text = " Обновить коллекцию"; + ButtonRefreshCollection.UseVisualStyleBackColor = true; + ButtonRefreshCollection.Click += ButtonRefreshCollection_Click; + // + // ButtonRemoveLocomotive + // + ButtonRemoveLocomotive.Location = new Point(3, 138); + ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive"; + ButtonRemoveLocomotive.Size = new Size(194, 39); + ButtonRemoveLocomotive.TabIndex = 1; + ButtonRemoveLocomotive.Text = "Удалить локомотив"; + ButtonRemoveLocomotive.UseVisualStyleBackColor = true; + ButtonRemoveLocomotive.Click += ButtonRemoveLocomotive_Click; + // + // ButtonAddLocomotive + // + ButtonAddLocomotive.Location = new Point(3, 15); + ButtonAddLocomotive.Name = "ButtonAddLocomotive"; + ButtonAddLocomotive.Size = new Size(194, 39); + ButtonAddLocomotive.TabIndex = 0; + ButtonAddLocomotive.Text = "Добавить локомотив"; + ButtonAddLocomotive.UseVisualStyleBackColor = true; + ButtonAddLocomotive.Click += ButtonAddLocomotive_Click; + // + // pictureBoxCollection + // + pictureBoxCollection.Location = new Point(2, 2); + pictureBoxCollection.Name = "pictureBoxCollection"; + pictureBoxCollection.Size = new Size(589, 448); + pictureBoxCollection.TabIndex = 1; + pictureBoxCollection.TabStop = false; + // + // LabelOnPanel + // + LabelOnPanel.AutoSize = true; + LabelOnPanel.Location = new Point(3, -3); + LabelOnPanel.Name = "LabelOnPanel"; + LabelOnPanel.Size = new Size(83, 15); + LabelOnPanel.TabIndex = 4; + LabelOnPanel.Text = "Инструменты"; + LabelOnPanel.Click += LabelOnPanel_Click; + // + // FormLocomotiveCollection + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(pictureBoxCollection); + Controls.Add(panelLocomotiveCollection); + Name = "FormLocomotiveCollection"; + Text = "Набор локомотивов"; + Load += FormLocomotiveCollection_Load; + panelLocomotiveCollection.ResumeLayout(false); + panelLocomotiveCollection.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panelLocomotiveCollection; + private Button ButtonAddLocomotive; + private Button ButtonRemoveLocomotive; + private Button ButtonRefreshCollection; + private PictureBox pictureBoxCollection; + private MaskedTextBox maskedTextBoxNumber; + private Label LabelOnPanel; + } +} \ No newline at end of file diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs new file mode 100644 index 0000000..cda95cd --- /dev/null +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.cs @@ -0,0 +1,75 @@ +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; +using ElectricLocomotive; +using ProjectElectricLocomotive.DrawingObjects; +using ProjectElectricLocomotive.Generics; +using ProjectElectricLocomotive.MovementStrategy; + +namespace ProjectElectricLocomotive +{ + public partial class FormLocomotiveCollection : Form + { + private readonly LocomotivesGenericCollection _locomotives; + public FormLocomotiveCollection() + { + InitializeComponent(); + _locomotives = new LocomotivesGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height); + } + private void ButtonAddLocomotive_Click(object sender, EventArgs e) + { + FormElectricLocomotive form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + if (_locomotives + form.SelectedLocomotive != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = _locomotives.ShowLocomotives(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + private void ButtonRemoveLocomotive_Click(object sender, EventArgs e) + { + if (MessageBox.Show("Удалить объект?", "Удаление", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxNumber.Text); + if (_locomotives - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBoxCollection.Image = _locomotives.ShowLocomotives(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + private void ButtonRefreshCollection_Click(object sender, EventArgs e) + { + pictureBoxCollection.Image = _locomotives.ShowLocomotives(); + } + private void FormLocomotiveCollection_Load(object sender, EventArgs e) + { + } + private void LabelOnPanel_Click(object sender, EventArgs e) + { + + } + private void panelLocomotiveCollection_Paint(object sender, PaintEventArgs e) + { + + } + } +} diff --git a/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.resx b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/ElectricLocomotive/ElectricLocomotive/FormLocomotiveCollection.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/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs b/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs index 509f7a3..2e3ee3e 100644 --- a/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs +++ b/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs @@ -8,40 +8,15 @@ using ProjectElectricLocomotive.MovementStrategy; namespace ProjectElectricLocomotive.Generics { - /// - /// Параметризованный класс для набора объектов DrawningCar - /// - /// - /// internal class LocomotivesGenericCollection - where T : DrawingObjects + where T : DrawingLocomotive where U : IMoveableObject { - /// - /// Ширина окна прорисовки - /// private readonly int _pictureWidth; - /// - /// Высота окна прорисовки - /// private readonly int _pictureHeight; - /// - /// Размер занимаемого объектом места (ширина) - /// - private readonly int _placeSizeWidth = 210; - /// - /// Размер занимаемого объектом места (высота) - /// + private readonly int _placeSizeWidth = 200; private readonly int _placeSizeHeight = 90; - /// - /// Набор объектов - /// private readonly SetGeneric _collection; - /// - /// Конструктор - /// - /// - /// public LocomotivesGenericCollection(int picWidth, int picHeight) { int width = picWidth / _placeSizeWidth; @@ -50,51 +25,26 @@ namespace ProjectElectricLocomotive.Generics _pictureHeight = picHeight; _collection = new SetGeneric(width * height); } - /// - /// Перегрузка оператора сложения - /// - /// - /// - /// - public static bool operator +(LocomotivesGenericCollection collect, T? - obj) + public static int operator + (LocomotivesGenericCollection collect, T? locomotive) { - if (obj == null) + if (locomotive == null) { - return false; + return -1; } - return collect?._collection.Insert(obj) ?? false; + return collect?._collection.Insert(locomotive) ?? -1; } - /// - /// Перегрузка оператора вычитания - /// - /// - /// - /// - public static T? operator -(LocomotivesGenericCollection collect, int - pos) + public static bool operator - (LocomotivesGenericCollection collect, int pos) { - T? obj = collect._collection.Get(pos); - if (obj != null) - { - collect._collection.Remove(pos); - } - return obj; + T? locomotive = collect._collection.Get(pos); + if (locomotive != null) + return collect._collection.Remove(pos); + return false; } - /// - /// Получение объекта IMoveableObject - /// - /// - /// public U? GetU(int pos) { return (U?)_collection.Get(pos)?.GetMoveableObject; } - /// - /// Вывод всего набора объектов - /// - /// - public Bitmap ShowCars() + public Bitmap ShowLocomotives() { Bitmap bmp = new(_pictureWidth, _pictureHeight); Graphics gr = Graphics.FromImage(bmp); @@ -102,10 +52,6 @@ namespace ProjectElectricLocomotive.Generics DrawObjects(gr); return bmp; } - /// - /// Метод отрисовки фона - /// - /// private void DrawBackground(Graphics g) { Pen pen = new(Color.Black, 3); @@ -122,17 +68,21 @@ namespace ProjectElectricLocomotive.Generics _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); } } - /// - /// Метод прорисовки объектов - /// - /// private void DrawObjects(Graphics g) { + int HLoco = _pictureHeight / _placeSizeHeight; + int Wloco = _pictureWidth / _placeSizeWidth; for (int i = 0; i < _collection.Count; i++) { - // TODO получение объекта - // TODO установка позиции - // TODO прорисовка объекта + T? type = _collection.Get(i); + if (type != null) + { + type.SetPosition( + (int)(i / HLoco * _placeSizeWidth), + (HLoco - 1) * _placeSizeHeight - (int)(i % HLoco * _placeSizeHeight) + ); + type?.DrawTransport(g); + } } } } diff --git a/ElectricLocomotive/ElectricLocomotive/ObjectParameters.cs b/ElectricLocomotive/ElectricLocomotive/ObjectParameters.cs index 8fca35b..b0f4d6b 100644 --- a/ElectricLocomotive/ElectricLocomotive/ObjectParameters.cs +++ b/ElectricLocomotive/ElectricLocomotive/ObjectParameters.cs @@ -12,9 +12,6 @@ namespace ProjectElectricLocomotive.MovementStrategy private readonly int _y; private readonly int _width; private readonly int _height; - /// - /// Левая граница - /// public int LeftBorder => _x; /// /// Верхняя граница diff --git a/ElectricLocomotive/ElectricLocomotive/Program.cs b/ElectricLocomotive/ElectricLocomotive/Program.cs index cfc9721..e7d6cc3 100644 --- a/ElectricLocomotive/ElectricLocomotive/Program.cs +++ b/ElectricLocomotive/ElectricLocomotive/Program.cs @@ -1,17 +1,15 @@ +using ProjectElectricLocomotive; +using System.Drawing; + namespace ElectricLocomotive { internal static class Program { - /// - /// The main entry point for the application. - /// [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new ElectricLocomotive()); + Application.Run(new FormLocomotiveCollection()); } } } \ No newline at end of file diff --git a/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs b/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs index 7b9b45b..9d02fdc 100644 --- a/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs +++ b/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs @@ -6,74 +6,59 @@ using System.Threading.Tasks; namespace ProjectElectricLocomotive.Generics { - /// - /// Параметризованный набор объектов - /// - /// internal class SetGeneric where T : class { - /// - /// Массив объектов, которые храним - /// private readonly T?[] _places; - /// - /// Количество объектов в массиве - /// public int Count => _places.Length; - /// - /// Конструктор - /// - /// public SetGeneric(int count) { _places = new T?[count]; } - /// - /// Добавление объекта в набор - /// - /// Добавляемый автомобиль - /// - public bool Insert(T car) + public int Insert(T locomotive) { - // TODO вставка в начало набора - return true; + return Insert(locomotive, 0); } - /// - /// Добавление объекта в набор на конкретную позицию - /// - /// Добавляемый автомобиль - /// Позиция - /// - public bool Insert(T car, int position) + public int Insert(T locomotive, int position) { - // TODO проверка позиции - // TODO проверка, что элемент массива по этой позиции пустой, если нет, то - // проверка, что после вставляемого элемента в массиве есть пустой элемент - // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента - // TODO вставка по позиции - _places[position] = car; - return true; + int Full = 0; + int temp = 0; + for (int i = position; i < Count; i++) + { + if (_places[i] != null) Full++; + } + if (Full == Count - position - 1) + return -1; + if (position < Count && position >= 0) + { + for (int j = position; j < Count; j++) + { + if (_places[j] == null) + { + temp = j; + break; + } + } + for (int i = temp; i > position; i--) + { + _places[i] = _places[i - 1]; + } + _places[position] = locomotive; + return position; + } + return -1; } - /// - /// Удаление объекта из набора с конкретной позиции - /// - /// - /// public bool Remove(int position) { - // TODO проверка позиции - // TODO удаление объекта из массива, присвоив элементу массива значение null + if (position >= Count || position < 0) + if (!(position >= 0 && position < Count) || _places[position] == null) + return false; + _places[position] = null; return true; } - /// - /// Получение объекта из набора по позиции - /// - /// - /// - public T? Get(int position) + public T Get(int position) { - // TODO проверка позиции + if (position < 0 || position >= Count) return null; return _places[position]; } } -- 2.25.1 From 144100d479dec5f2fd4b7d9bf43cc4d713f82003 Mon Sep 17 00:00:00 2001 From: tellsense Date: Sun, 15 Oct 2023 23:07:02 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=BF=D0=B5=D1=87=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawingObjectLocomotive.cs | 18 +++++------ .../FormElectricLocomotive.cs | 30 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ElectricLocomotive/ElectricLocomotive/DrawingObjectLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawingObjectLocomotive.cs index 8660f4c..f6e1d99 100644 --- a/ElectricLocomotive/ElectricLocomotive/DrawingObjectLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/DrawingObjectLocomotive.cs @@ -10,26 +10,26 @@ namespace ProjectElectricLocomotive.MovementStrategy { public class DrawingObjectLocomotive : IMoveableObject { - private readonly DrawingLocomotive? _drawningLocomotive = null; + private readonly DrawingLocomotive? _drawingLocomotive = null; - public DrawingObjectLocomotive(DrawingLocomotive drawningLocomotive) + public DrawingObjectLocomotive(DrawingLocomotive drawingLocomotive) { - _drawningLocomotive = drawningLocomotive; + _drawingLocomotive = drawingLocomotive; } public ObjectParameters? GetObjectPosition { get { - if (_drawningLocomotive == null || _drawningLocomotive.EntityLocomotive == null) + if (_drawingLocomotive == null || _drawingLocomotive.EntityLocomotive == null) { return null; } - return new ObjectParameters(_drawningLocomotive.GetPosX, - _drawningLocomotive.GetPosY, _drawningLocomotive.GetWidth, _drawningLocomotive.GetHeight); + return new ObjectParameters(_drawingLocomotive.GetPosX, + _drawingLocomotive.GetPosY, _drawingLocomotive.GetWidth, _drawingLocomotive.GetHeight); } } - public int GetStep => (int)(_drawningLocomotive?.EntityLocomotive?.Step ?? 0); - public bool CheckCanMove(Direction direction) => _drawningLocomotive?.CanMove(direction) ?? false; - public void MoveObject(Direction direction) => _drawningLocomotive?.MoveTransport(direction); + public int GetStep => (int)(_drawingLocomotive?.EntityLocomotive?.Step ?? 0); + public bool CheckCanMove(Direction direction) => _drawingLocomotive?.CanMove(direction) ?? false; + public void MoveObject(Direction direction) => _drawingLocomotive?.MoveTransport(direction); } } diff --git a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs index c869db9..bbc6eff 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs @@ -8,7 +8,7 @@ namespace ElectricLocomotive { public partial class FormElectricLocomotive : Form { - private DrawingLocomotive? _drawningLocomotive; + private DrawingLocomotive? _drawingLocomotive; private AbstractStrategy? _abstractStrategy; public DrawingLocomotive? SelectedLocomotive { get; private set; } public FormElectricLocomotive() @@ -19,13 +19,13 @@ namespace ElectricLocomotive } private void Draw() { - if (_drawningLocomotive == null) + if (_drawingLocomotive == null) { return; } Bitmap bmp = new(pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); Graphics gr = Graphics.FromImage(bmp); - _drawningLocomotive.DrawTransport(gr); + _drawingLocomotive.DrawTransport(gr); pictureBoxElectricLocomotive.Image = bmp; } private void buttonCreateElectricLocomotive_Click(object sender, EventArgs e) @@ -42,10 +42,10 @@ namespace ElectricLocomotive { dopColor = colorDialog.Color; } - _drawningLocomotive = new DrawingElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, + _drawingLocomotive = new DrawingElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); - _drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); + _drawingLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } private void buttonCreateLocomotive_Click(object sender, EventArgs e) @@ -58,17 +58,17 @@ namespace ElectricLocomotive { color = dialog.Color; } - _drawningLocomotive = new DrawingLocomotive(random.Next(100, 300), + _drawingLocomotive = new DrawingLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); - _drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, + _drawingLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } private void buttonMove_Click(object sender, EventArgs e) { - if (_drawningLocomotive == null) + if (_drawingLocomotive == null) { return; } @@ -76,23 +76,23 @@ namespace ElectricLocomotive switch (name) { case "buttonUp": - _drawningLocomotive.MoveTransport(Direction.Up); + _drawingLocomotive.MoveTransport(Direction.Up); break; case "buttonDown": - _drawningLocomotive.MoveTransport(Direction.Down); + _drawingLocomotive.MoveTransport(Direction.Down); break; case "buttonLeft": - _drawningLocomotive.MoveTransport(Direction.Left); + _drawingLocomotive.MoveTransport(Direction.Left); break; case "buttonRight": - _drawningLocomotive.MoveTransport(Direction.Right); + _drawingLocomotive.MoveTransport(Direction.Right); break; } Draw(); } private void buttonStrategyStep_Click(object sender, EventArgs e) { - if (_drawningLocomotive == null) + if (_drawingLocomotive == null) { return; } @@ -108,7 +108,7 @@ namespace ElectricLocomotive { return; } - _abstractStrategy.SetData(new DrawingObjectLocomotive(_drawningLocomotive), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); + _abstractStrategy.SetData(new DrawingObjectLocomotive(_drawingLocomotive), pictureBoxElectricLocomotive.Width, pictureBoxElectricLocomotive.Height); comboBoxStrategy.Enabled = false; } if (_abstractStrategy == null) @@ -137,7 +137,7 @@ namespace ElectricLocomotive } private void ButtonSelectLocomotive_Click(object sender, EventArgs e) { - SelectedLocomotive = _drawningLocomotive; + SelectedLocomotive = _drawingLocomotive; DialogResult = DialogResult.OK; } } -- 2.25.1 From dea236e60848335274bd68782f29b00078f7888b Mon Sep 17 00:00:00 2001 From: tellsense Date: Sun, 15 Oct 2023 23:24:11 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ElectricLocomotive/DrawingLocomotive.cs | 20 ------------------- .../FormElectricLocomotive.cs | 1 - .../ProjectElectricLocomotive.csproj | 2 +- .../ElectricLocomotive/SetGeneric.cs | 2 +- 4 files changed, 2 insertions(+), 23 deletions(-) diff --git a/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs index cb7949e..946417c 100644 --- a/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/DrawingLocomotive.cs @@ -25,12 +25,6 @@ namespace ProjectElectricLocomotive.DrawingObjects public int GetPosY => _startPosY; public int GetWidth => _locomWidth; public int GetHeight => _locomHeight; - /// Скорость - /// Вес - /// Цвет кузова - /// Ширина картинки - /// Высота картинки - public DrawingLocomotive(int speed, double weight, Color bodyColor, int width, int heigth) { if (width < _locomWidth || heigth < _locomHeight) @@ -41,13 +35,6 @@ namespace ProjectElectricLocomotive.DrawingObjects _pictureHeight = heigth; EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor); } - /// Скорость - /// Вес - /// Цвет кузова - /// Ширина картинки - /// Высота картинки - /// Ширина картинки - /// Высота картинки protected DrawingLocomotive(int speed, double weight, Color bodyColor, int width, int height, int locomWidth, int locomHeight) { @@ -61,8 +48,6 @@ namespace ProjectElectricLocomotive.DrawingObjects _locomHeight = locomHeight; EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor); } - /// Координата X - /// Координата Y public void SetPosition(int x, int y) { if (x < 0 || x + _locomWidth > _pictureWidth) @@ -76,7 +61,6 @@ namespace ProjectElectricLocomotive.DrawingObjects _startPosX = x; _startPosY = y; } - /// Направление public void MoveTransport(Direction direction) { if (EntityLocomotive == null) @@ -111,7 +95,6 @@ namespace ProjectElectricLocomotive.DrawingObjects break; } } - /// public virtual void DrawTransport(Graphics g) { { @@ -181,9 +164,6 @@ namespace ProjectElectricLocomotive.DrawingObjects Direction.Down => _startPosY + EntityLocomotive.Step < _pictureHeight, }; } - /// - /// Получение объекта IMoveableObject из объекта DrawningCar - /// public IMoveableObject GetMoveableObject => new DrawingObjectLocomotive(this); } diff --git a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs index bbc6eff..cee1fea 100644 --- a/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/FormElectricLocomotive.cs @@ -133,7 +133,6 @@ namespace ElectricLocomotive } private void ElectricLocomotive_Load(object sender, EventArgs e) { - } private void ButtonSelectLocomotive_Click(object sender, EventArgs e) { diff --git a/ElectricLocomotive/ElectricLocomotive/ProjectElectricLocomotive.csproj b/ElectricLocomotive/ElectricLocomotive/ProjectElectricLocomotive.csproj index 244387d..13ee123 100644 --- a/ElectricLocomotive/ElectricLocomotive/ProjectElectricLocomotive.csproj +++ b/ElectricLocomotive/ElectricLocomotive/ProjectElectricLocomotive.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net6.0-windows enable true enable diff --git a/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs b/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs index 9d02fdc..60c65ce 100644 --- a/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs +++ b/ElectricLocomotive/ElectricLocomotive/SetGeneric.cs @@ -27,7 +27,7 @@ namespace ProjectElectricLocomotive.Generics { if (_places[i] != null) Full++; } - if (Full == Count - position - 1) + if (Full == Count - position - 1) return -1; if (position < Count && position >= 0) { -- 2.25.1 From f75d1f1b7b7fd64e4023ee2e9e6984227d582cdb Mon Sep 17 00:00:00 2001 From: tellsense Date: Sun, 29 Oct 2023 18:50:36 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ElectricLocomotive/LocomotivesGenericCollection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs b/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs index 2e3ee3e..aaa36a9 100644 --- a/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs +++ b/ElectricLocomotive/ElectricLocomotive/LocomotivesGenericCollection.cs @@ -25,7 +25,7 @@ namespace ProjectElectricLocomotive.Generics _pictureHeight = picHeight; _collection = new SetGeneric(width * height); } - public static int operator + (LocomotivesGenericCollection collect, T? locomotive) + public static int operator +(LocomotivesGenericCollection collect, T? locomotive) { if (locomotive == null) { @@ -33,7 +33,7 @@ namespace ProjectElectricLocomotive.Generics } return collect?._collection.Insert(locomotive) ?? -1; } - public static bool operator - (LocomotivesGenericCollection collect, int pos) + public static bool operator -(LocomotivesGenericCollection collect, int pos) { T? locomotive = collect._collection.Get(pos); if (locomotive != null) @@ -59,7 +59,7 @@ namespace ProjectElectricLocomotive.Generics { for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) - {//линия рамзетки места + { g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight); -- 2.25.1