diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs index 1eb7aa1..0e550fc 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/AbstractCompany.cs @@ -1,5 +1,4 @@ -using ProjectLiner.CollectionGenericObjects; -using ProjectLiner.Drawnings; +using ProjectLiner.Drawnings; namespace ProjectLiner.CollectionGenericObjects { diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs index 0501fa8..ad2d528 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/LinerSharingService.cs @@ -1,6 +1,4 @@ - -using ProjectLiner.Drawnings; -using ProjectLiner.CollectionGenericObjects; +using ProjectLiner.Drawnings; namespace ProjectLiner.CollectionGenericObjects; @@ -15,60 +13,52 @@ public class LinerSharingService : AbstractCompany /// Ширина /// Высота /// Коллекция - public LinerSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) + public LinerSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection) { } protected override void DrawBackgound(Graphics g) { - - int count_width = _pictureWidth / _placeSizeWidth; // кол-во мест в ширину - int count_height = _pictureHeight / _placeSizeHeight; - Pen pen = new(Color.Black, 3); - for (int i = 0; i < count_width; i++) + Pen pen = new(Color.Black, 4); + for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) { - for (int j = 0; j < count_height + 1; ++j) + for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) { - g.DrawLine(pen, i * _placeSizeWidth + 10, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 50, j * _placeSizeHeight); // вертикаль - g.DrawLine(pen, i * _placeSizeWidth + 10, j * _placeSizeHeight, i * _placeSizeWidth + 10, j * _placeSizeHeight + _placeSizeHeight); + g.DrawLine(pen, i * _placeSizeWidth, (int)(j * _placeSizeHeight * 1.3), + i * _placeSizeWidth + _placeSizeWidth - 40, (int)(j * _placeSizeHeight * 1.3)); } + g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); } } + protected override void SetObjectsPosition() { - int width = _pictureWidth / _placeSizeWidth; int height = _pictureHeight / _placeSizeHeight; - int positionWidth = 0; - int positionHeight = height - 1; - if (_collection?.Count != null) + int curWidth = width - 1; + int curHeight = 0; + + for (int i = 0; i < (_collection?.Count ?? 0); i++) { - for (int i = 0; i < (_collection.Count); i++) + if (_collection?.Get(i) != null) { - if (_collection.Get(i) != null) - { - _collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight); - _collection.Get(i).SetPosition(_placeSizeWidth * positionWidth + 25, positionHeight * _placeSizeHeight + 10); - } + _collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); + _collection.Get(i)?.SetPosition(_placeSizeWidth * curWidth + 10, (int)(curHeight * _placeSizeHeight * 1.3)); + } - if (positionWidth < width - 1) - { - positionWidth++; - } - - else - { - positionWidth = 0; - positionHeight--; - } - if (positionHeight < 0) - { - return; - } + if (curWidth > 0) + curWidth--; + else + { + curWidth = width - 1; + curHeight++; + } + if (curHeight > height) + { + return; } } - } } \ No newline at end of file diff --git a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs index 9865dd0..9ed2684 100644 --- a/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectLiner/ProjectLiner/CollectionGenericObjects/MassiveGenericObjects.cs @@ -1,5 +1,4 @@ -using ProjectLiner.CollectionGenericObjects; - + namespace ProjectLiner.CollectionGenericObjects { /// diff --git a/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs index b47fb35..ef854f9 100644 --- a/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs +++ b/ProjectLiner/ProjectLiner/Drawnings/DrawningCommonLiner.cs @@ -1,9 +1,5 @@ using ProjectLiner.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + namespace ProjectLiner.Drawnings; /// diff --git a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs index 7dc1072..8b9984b 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.Designer.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.Designer.cs @@ -43,7 +43,7 @@ pictureBoxLiner.BackColor = SystemColors.Control; pictureBoxLiner.Dock = DockStyle.Fill; pictureBoxLiner.Location = new Point(0, 0); - pictureBoxLiner.Margin = new Padding(5, 5, 5, 5); + pictureBoxLiner.Margin = new Padding(5); pictureBoxLiner.Name = "pictureBoxLiner"; pictureBoxLiner.Size = new Size(1465, 1007); pictureBoxLiner.TabIndex = 0; @@ -55,7 +55,7 @@ buttonDown.BackgroundImage = Properties.Resources.bottom; buttonDown.BackgroundImageLayout = ImageLayout.Stretch; buttonDown.Location = new Point(1283, 905); - buttonDown.Margin = new Padding(5, 5, 5, 5); + buttonDown.Margin = new Padding(5); buttonDown.Name = "buttonDown"; buttonDown.Size = new Size(77, 82); buttonDown.TabIndex = 2; @@ -68,7 +68,7 @@ buttonUp.BackgroundImage = Properties.Resources.top; buttonUp.BackgroundImageLayout = ImageLayout.Stretch; buttonUp.Location = new Point(1283, 813); - buttonUp.Margin = new Padding(5, 5, 5, 5); + buttonUp.Margin = new Padding(5); buttonUp.Name = "buttonUp"; buttonUp.Size = new Size(77, 82); buttonUp.TabIndex = 3; @@ -81,7 +81,7 @@ buttonLeft.BackgroundImage = Properties.Resources.left; buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; buttonLeft.Location = new Point(1196, 905); - buttonLeft.Margin = new Padding(5, 5, 5, 5); + buttonLeft.Margin = new Padding(5); buttonLeft.Name = "buttonLeft"; buttonLeft.Size = new Size(77, 82); buttonLeft.TabIndex = 4; @@ -94,7 +94,7 @@ buttonRight.BackgroundImage = Properties.Resources.right; buttonRight.BackgroundImageLayout = ImageLayout.Stretch; buttonRight.Location = new Point(1369, 905); - buttonRight.Margin = new Padding(5, 5, 5, 5); + buttonRight.Margin = new Padding(5); buttonRight.Name = "buttonRight"; buttonRight.Size = new Size(77, 82); buttonRight.TabIndex = 5; @@ -107,7 +107,7 @@ comboBoxStrategy.FormattingEnabled = true; comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" }); comboBoxStrategy.Location = new Point(1147, 20); - comboBoxStrategy.Margin = new Padding(5, 5, 5, 5); + comboBoxStrategy.Margin = new Padding(5); comboBoxStrategy.Name = "comboBoxStrategy"; comboBoxStrategy.Size = new Size(298, 49); comboBoxStrategy.TabIndex = 11; @@ -115,7 +115,7 @@ // buttonStrategyStep // buttonStrategyStep.Location = new Point(1261, 84); - buttonStrategyStep.Margin = new Padding(5, 5, 5, 5); + buttonStrategyStep.Margin = new Padding(5); buttonStrategyStep.Name = "buttonStrategyStep"; buttonStrategyStep.Size = new Size(185, 61); buttonStrategyStep.TabIndex = 12; @@ -135,7 +135,7 @@ Controls.Add(buttonUp); Controls.Add(buttonDown); Controls.Add(pictureBoxLiner); - Margin = new Padding(5, 5, 5, 5); + Margin = new Padding(5); Name = "FormLiner"; Text = "Лайнер"; ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).EndInit(); diff --git a/ProjectLiner/ProjectLiner/FormLiner.cs b/ProjectLiner/ProjectLiner/FormLiner.cs index 683457a..fbbb11d 100644 --- a/ProjectLiner/ProjectLiner/FormLiner.cs +++ b/ProjectLiner/ProjectLiner/FormLiner.cs @@ -28,7 +28,7 @@ namespace ProjectLiner /// Стратегия перемещения /// - public DrawningLiner SetLiner + public DrawningCommonLiner SetLiner { set { diff --git a/ProjectLiner/ProjectLiner/FormLinerCollection.cs b/ProjectLiner/ProjectLiner/FormLinerCollection.cs index 38bb839..56b4370 100644 --- a/ProjectLiner/ProjectLiner/FormLinerCollection.cs +++ b/ProjectLiner/ProjectLiner/FormLinerCollection.cs @@ -32,7 +32,7 @@ namespace ProjectLiner switch (comboBoxSelectorCompany.Text) { case "Хранилище": - _company = new LinerSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); + _company = new LinerSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects()); break; } } @@ -165,7 +165,7 @@ namespace ProjectLiner FormLiner form = new() { - SetLiner = (DrawningLiner)liner + SetLiner = liner }; form.ShowDialog(); }