Исправлены ошибки с отрисовкой sharing

This commit is contained in:
gettterot 2024-03-20 08:23:41 +04:00
parent 359c50745b
commit dac8a3ec17
7 changed files with 41 additions and 57 deletions

View File

@ -1,5 +1,4 @@
using ProjectLiner.CollectionGenericObjects; using ProjectLiner.Drawnings;
using ProjectLiner.Drawnings;
namespace ProjectLiner.CollectionGenericObjects namespace ProjectLiner.CollectionGenericObjects
{ {

View File

@ -1,6 +1,4 @@
 using ProjectLiner.Drawnings;
using ProjectLiner.Drawnings;
using ProjectLiner.CollectionGenericObjects;
namespace ProjectLiner.CollectionGenericObjects; namespace ProjectLiner.CollectionGenericObjects;
@ -15,60 +13,52 @@ public class LinerSharingService : AbstractCompany
/// <param name="picWidth">Ширина</param> /// <param name="picWidth">Ширина</param>
/// <param name="picHeight">Высота</param> /// <param name="picHeight">Высота</param>
/// <param name="collection">Коллекция</param> /// <param name="collection">Коллекция</param>
public LinerSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningLiner> collection) : base(picWidth, picHeight, collection) public LinerSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningCommonLiner> collection) : base(picWidth, picHeight, collection)
{ {
} }
protected override void DrawBackgound(Graphics g) protected override void DrawBackgound(Graphics g)
{ {
Pen pen = new(Color.Black, 4);
int count_width = _pictureWidth / _placeSizeWidth; // кол-во мест в ширину for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
int count_height = _pictureHeight / _placeSizeHeight;
Pen pen = new(Color.Black, 3);
for (int i = 0; i < count_width; 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, (int)(j * _placeSizeHeight * 1.3),
g.DrawLine(pen, i * _placeSizeWidth + 10, j * _placeSizeHeight, i * _placeSizeWidth + 10, j * _placeSizeHeight + _placeSizeHeight); i * _placeSizeWidth + _placeSizeWidth - 40, (int)(j * _placeSizeHeight * 1.3));
} }
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
} }
} }
protected override void SetObjectsPosition() protected override void SetObjectsPosition()
{ {
int width = _pictureWidth / _placeSizeWidth; int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight; 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 * curWidth + 10, (int)(curHeight * _placeSizeHeight * 1.3));
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight); }
_collection.Get(i).SetPosition(_placeSizeWidth * positionWidth + 25, positionHeight * _placeSizeHeight + 10);
}
if (positionWidth < width - 1) if (curWidth > 0)
{ curWidth--;
positionWidth++; else
} {
curWidth = width - 1;
else curHeight++;
{ }
positionWidth = 0; if (curHeight > height)
positionHeight--; {
} return;
if (positionHeight < 0)
{
return;
}
} }
} }
} }
} }

View File

@ -1,5 +1,4 @@
using ProjectLiner.CollectionGenericObjects; 
namespace ProjectLiner.CollectionGenericObjects namespace ProjectLiner.CollectionGenericObjects
{ {
/// <summary> /// <summary>

View File

@ -1,9 +1,5 @@
using ProjectLiner.Entities; using ProjectLiner.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLiner.Drawnings; namespace ProjectLiner.Drawnings;
/// <summary> /// <summary>

View File

@ -43,7 +43,7 @@
pictureBoxLiner.BackColor = SystemColors.Control; pictureBoxLiner.BackColor = SystemColors.Control;
pictureBoxLiner.Dock = DockStyle.Fill; pictureBoxLiner.Dock = DockStyle.Fill;
pictureBoxLiner.Location = new Point(0, 0); pictureBoxLiner.Location = new Point(0, 0);
pictureBoxLiner.Margin = new Padding(5, 5, 5, 5); pictureBoxLiner.Margin = new Padding(5);
pictureBoxLiner.Name = "pictureBoxLiner"; pictureBoxLiner.Name = "pictureBoxLiner";
pictureBoxLiner.Size = new Size(1465, 1007); pictureBoxLiner.Size = new Size(1465, 1007);
pictureBoxLiner.TabIndex = 0; pictureBoxLiner.TabIndex = 0;
@ -55,7 +55,7 @@
buttonDown.BackgroundImage = Properties.Resources.bottom; buttonDown.BackgroundImage = Properties.Resources.bottom;
buttonDown.BackgroundImageLayout = ImageLayout.Stretch; buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
buttonDown.Location = new Point(1283, 905); buttonDown.Location = new Point(1283, 905);
buttonDown.Margin = new Padding(5, 5, 5, 5); buttonDown.Margin = new Padding(5);
buttonDown.Name = "buttonDown"; buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(77, 82); buttonDown.Size = new Size(77, 82);
buttonDown.TabIndex = 2; buttonDown.TabIndex = 2;
@ -68,7 +68,7 @@
buttonUp.BackgroundImage = Properties.Resources.top; buttonUp.BackgroundImage = Properties.Resources.top;
buttonUp.BackgroundImageLayout = ImageLayout.Stretch; buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
buttonUp.Location = new Point(1283, 813); buttonUp.Location = new Point(1283, 813);
buttonUp.Margin = new Padding(5, 5, 5, 5); buttonUp.Margin = new Padding(5);
buttonUp.Name = "buttonUp"; buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(77, 82); buttonUp.Size = new Size(77, 82);
buttonUp.TabIndex = 3; buttonUp.TabIndex = 3;
@ -81,7 +81,7 @@
buttonLeft.BackgroundImage = Properties.Resources.left; buttonLeft.BackgroundImage = Properties.Resources.left;
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
buttonLeft.Location = new Point(1196, 905); buttonLeft.Location = new Point(1196, 905);
buttonLeft.Margin = new Padding(5, 5, 5, 5); buttonLeft.Margin = new Padding(5);
buttonLeft.Name = "buttonLeft"; buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(77, 82); buttonLeft.Size = new Size(77, 82);
buttonLeft.TabIndex = 4; buttonLeft.TabIndex = 4;
@ -94,7 +94,7 @@
buttonRight.BackgroundImage = Properties.Resources.right; buttonRight.BackgroundImage = Properties.Resources.right;
buttonRight.BackgroundImageLayout = ImageLayout.Stretch; buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
buttonRight.Location = new Point(1369, 905); buttonRight.Location = new Point(1369, 905);
buttonRight.Margin = new Padding(5, 5, 5, 5); buttonRight.Margin = new Padding(5);
buttonRight.Name = "buttonRight"; buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(77, 82); buttonRight.Size = new Size(77, 82);
buttonRight.TabIndex = 5; buttonRight.TabIndex = 5;
@ -107,7 +107,7 @@
comboBoxStrategy.FormattingEnabled = true; comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" }); comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
comboBoxStrategy.Location = new Point(1147, 20); comboBoxStrategy.Location = new Point(1147, 20);
comboBoxStrategy.Margin = new Padding(5, 5, 5, 5); comboBoxStrategy.Margin = new Padding(5);
comboBoxStrategy.Name = "comboBoxStrategy"; comboBoxStrategy.Name = "comboBoxStrategy";
comboBoxStrategy.Size = new Size(298, 49); comboBoxStrategy.Size = new Size(298, 49);
comboBoxStrategy.TabIndex = 11; comboBoxStrategy.TabIndex = 11;
@ -115,7 +115,7 @@
// buttonStrategyStep // buttonStrategyStep
// //
buttonStrategyStep.Location = new Point(1261, 84); buttonStrategyStep.Location = new Point(1261, 84);
buttonStrategyStep.Margin = new Padding(5, 5, 5, 5); buttonStrategyStep.Margin = new Padding(5);
buttonStrategyStep.Name = "buttonStrategyStep"; buttonStrategyStep.Name = "buttonStrategyStep";
buttonStrategyStep.Size = new Size(185, 61); buttonStrategyStep.Size = new Size(185, 61);
buttonStrategyStep.TabIndex = 12; buttonStrategyStep.TabIndex = 12;
@ -135,7 +135,7 @@
Controls.Add(buttonUp); Controls.Add(buttonUp);
Controls.Add(buttonDown); Controls.Add(buttonDown);
Controls.Add(pictureBoxLiner); Controls.Add(pictureBoxLiner);
Margin = new Padding(5, 5, 5, 5); Margin = new Padding(5);
Name = "FormLiner"; Name = "FormLiner";
Text = "Лайнер"; Text = "Лайнер";
((System.ComponentModel.ISupportInitialize)pictureBoxLiner).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxLiner).EndInit();

View File

@ -28,7 +28,7 @@ namespace ProjectLiner
/// Стратегия перемещения /// Стратегия перемещения
/// </summary> /// </summary>
public DrawningLiner SetLiner public DrawningCommonLiner SetLiner
{ {
set set
{ {

View File

@ -32,7 +32,7 @@ namespace ProjectLiner
switch (comboBoxSelectorCompany.Text) switch (comboBoxSelectorCompany.Text)
{ {
case "Хранилище": case "Хранилище":
_company = new LinerSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningLiner>()); _company = new LinerSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningCommonLiner>());
break; break;
} }
} }
@ -165,7 +165,7 @@ namespace ProjectLiner
FormLiner form = new() FormLiner form = new()
{ {
SetLiner = (DrawningLiner)liner SetLiner = liner
}; };
form.ShowDialog(); form.ShowDialog();
} }