From 15399b84b1705df80a204a60efa5242538a3f851 Mon Sep 17 00:00:00 2001 From: tyxz0 Date: Mon, 1 Apr 2024 14:58:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B1=D1=83=D1=81=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BE=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0,=20=D0=BE=D1=81=D1=82=D0=B0=D0=BB=D0=BE=D1=81=D1=8C=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D1=82=D1=8C=20setObjectsPo?= =?UTF-8?q?sitions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 2 +- .../CollectionGenericObjects/BusStation.cs | 41 ++++++++++++++++++- .../FormBusCollection.Designer.cs | 6 +-- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/AbstractCompany.cs b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/AbstractCompany.cs index f55bf5a..6693ce4 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/AbstractCompany.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/AbstractCompany.cs @@ -17,7 +17,7 @@ public abstract class AbstractCompany /// /// Размер места(ширина) /// - protected readonly int _placeSizeWidth = 210; + protected readonly int _placeSizeWidth = 130; /// /// Размер места(высота) diff --git a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/BusStation.cs b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/BusStation.cs index 6027ca1..3e598d3 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/BusStation.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/BusStation.cs @@ -9,17 +9,54 @@ namespace DoubleDeckerBus.CollectionGenericObjects; public class BusStation : AbstractCompany { + + private int[]? _arrayOfCoordinates; + public BusStation(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) { } protected override void DrawBackground(Graphics g) { - throw new NotImplementedException(); + Pen pen = new Pen(Color.Black, 3); + + int gap = 15; + int y = 10; + int size_of_array = 2; + + while (y + _placeSizeHeight < _pictureHeight - gap) + { + int x = _pictureWidth - gap; + + while (x - _placeSizeWidth > gap) + { + g.DrawLine(pen, x, y, x - _placeSizeWidth, y); + g.DrawLine(pen, x, y, x, y + _placeSizeHeight); + g.DrawLine(pen, x, y + _placeSizeHeight, x - _placeSizeWidth, y + _placeSizeHeight); + + Array.Resize(ref _arrayOfCoordinates, size_of_array); + _arrayOfCoordinates[size_of_array - 2] = x; + _arrayOfCoordinates[size_of_array - 1] = y; + + x -= (_placeSizeWidth + 70); + } + y += _placeSizeHeight; + size_of_array += 2; + } } protected override void SetObjectsPosition() { - throw new NotImplementedException(); + if (_arrayOfCoordinates == null || _collection == null) + { + return; + } + + for (int i = 0, coordinate_index = 0; i < _collection.Count; i++, coordinate_index += 2) + { + _collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); + _collection.Get(i)?.SetPosition(_arrayOfCoordinates[coordinate_index], _arrayOfCoordinates[coordinate_index + 1]); + + } } } diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBusCollection.Designer.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBusCollection.Designer.cs index dececd8..0bef3a8 100644 --- a/DoubleDeckerBus/DoubleDeckerBus/FormBusCollection.Designer.cs +++ b/DoubleDeckerBus/DoubleDeckerBus/FormBusCollection.Designer.cs @@ -51,7 +51,7 @@ groupBoxTools.Controls.Add(buttonAddBus); groupBoxTools.Controls.Add(comboBoxSelectCompany); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(600, 0); + groupBoxTools.Location = new Point(870, 0); groupBoxTools.Name = "groupBoxTools"; groupBoxTools.Size = new Size(200, 450); groupBoxTools.TabIndex = 0; @@ -138,7 +138,7 @@ pictureBox.Dock = DockStyle.Fill; pictureBox.Location = new Point(0, 0); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(600, 450); + pictureBox.Size = new Size(870, 450); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // @@ -146,7 +146,7 @@ // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + ClientSize = new Size(1070, 450); Controls.Add(pictureBox); Controls.Add(groupBoxTools); Name = "FormBusCollection";