Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e82bda63b | |||
| ef93a0293c | |||
| 16b6400b36 | |||
| c53647752a | |||
| e03720990d | |||
| 9bbe889440 | |||
| a92d29b242 | |||
| e173941bbc | |||
| b97db5b022 |
@@ -4,14 +4,13 @@ namespace ProjectBulldozer.Drawning
|
|||||||
public class DrawingBulldozer : DrawingTractor
|
public class DrawingBulldozer : DrawingTractor
|
||||||
{
|
{
|
||||||
public DrawingBulldozer(int speed, double weight, Color bodyColor, Color additionalColor,
|
public DrawingBulldozer(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||||
bool horns, bool seifBatteries, int width, int height) : base(speed, weight, bodyColor, width, height, 140, 130)
|
bool otval, bool thirdWheel, int width, int height) : base(speed, weight, bodyColor, width, height, 120, 110)
|
||||||
{
|
{
|
||||||
if (EntityTractor != null)
|
if (EntityTractor != null)
|
||||||
{
|
{
|
||||||
EntityTractor = new EntityBulldozer(speed, width, bodyColor, additionalColor, horns, seifBatteries);
|
EntityTractor = new EntityBulldozer(speed, width, bodyColor, additionalColor, otval, thirdWheel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public object Otval { get; private set; }
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityTractor is not EntityBulldozer Bulldozer)
|
if (EntityTractor is not EntityBulldozer Bulldozer)
|
||||||
@@ -21,27 +20,35 @@ namespace ProjectBulldozer.Drawning
|
|||||||
|
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush blackBrush = new SolidBrush(Color.Black);
|
Brush blackBrush = new SolidBrush(Color.Black);
|
||||||
Brush windows = new SolidBrush(Color.LightBlue);
|
|
||||||
Brush bodyColor = new SolidBrush(Bulldozer.BodyColor);
|
|
||||||
Brush additionalColor = new SolidBrush(Bulldozer.AdditionalColor);
|
Brush additionalColor = new SolidBrush(Bulldozer.AdditionalColor);
|
||||||
Brush grayBrush = new SolidBrush(Color.Gray);
|
Brush grayBrush = new SolidBrush(Color.Gray);
|
||||||
//otval
|
|
||||||
Point[] Otval =
|
if (Bulldozer.Otval)
|
||||||
{
|
{
|
||||||
|
//otval
|
||||||
|
Point[] Otval =
|
||||||
|
{
|
||||||
new Point(_startPosX + 118, _startPosY + 50),
|
new Point(_startPosX + 118, _startPosY + 50),
|
||||||
new Point(_startPosX + 148, _startPosY + 111),
|
new Point(_startPosX + 148, _startPosY + 111),
|
||||||
new Point(_startPosX+ 118, _startPosY + 111),
|
new Point(_startPosX+ 118, _startPosY + 111),
|
||||||
};
|
};
|
||||||
g.FillPolygon(additionalColor, Otval);
|
g.FillPolygon(additionalColor, Otval);
|
||||||
g.DrawPolygon(pen, Otval);
|
g.DrawPolygon(pen, Otval);
|
||||||
|
}
|
||||||
//гусеницы
|
//гусеницы
|
||||||
Brush gg = new SolidBrush(Color.LightGray);
|
Brush gg = new SolidBrush(Color.LightGray);
|
||||||
g.FillEllipse(gg, _startPosX + 16, _startPosY + 65, 101, 63);
|
g.FillEllipse(gg, _startPosX + 16, _startPosY + 65, 101, 63);
|
||||||
g.DrawEllipse(pen, _startPosX + 16, _startPosY + 65, 101, 63);
|
g.DrawEllipse(pen, _startPosX + 16, _startPosY + 65, 101, 63);
|
||||||
g.FillEllipse(grayBrush, _startPosX + 65, _startPosY + 100, 13, 13);
|
|
||||||
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 100, 13, 13);
|
if (Bulldozer.ThirdWheel)
|
||||||
|
{
|
||||||
|
|
||||||
|
g.FillEllipse(grayBrush, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||||
|
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 100, 13, 13);
|
||||||
|
}
|
||||||
Point[] Ttt =
|
Point[] Ttt =
|
||||||
{
|
{
|
||||||
|
|
||||||
new Point(_startPosX + 16, _startPosY + 79),
|
new Point(_startPosX + 16, _startPosY + 79),
|
||||||
new Point(_startPosX + 16, _startPosY + 120),
|
new Point(_startPosX + 16, _startPosY + 120),
|
||||||
new Point(_startPosX, _startPosY + 48),
|
new Point(_startPosX, _startPosY + 48),
|
||||||
@@ -49,10 +56,8 @@ namespace ProjectBulldozer.Drawning
|
|||||||
};
|
};
|
||||||
g.FillPolygon(blackBrush, Ttt);
|
g.FillPolygon(blackBrush, Ttt);
|
||||||
g.DrawPolygon(pen, Ttt);
|
g.DrawPolygon(pen, Ttt);
|
||||||
if (Bulldozer.SeifBatteries)
|
g.FillRectangle(blackBrush, _startPosX + 110, _startPosY + 60, 5, 10);
|
||||||
{
|
|
||||||
g.FillRectangle(blackBrush, _startPosX + 110, _startPosY + 60, 5, 10);
|
|
||||||
}
|
|
||||||
base.DrawTransport(g);
|
base.DrawTransport(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using ProjectBulldozer.Entities;
|
using ProjectBulldozer.Entities;
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
|
|
||||||
namespace ProjectBulldozer.Drawning
|
namespace ProjectBulldozer.Drawning
|
||||||
{
|
{
|
||||||
public class DrawingTractor
|
public class DrawingTractor
|
||||||
{
|
{
|
||||||
public EntityTractor? EntityTractor { get; protected set; }
|
public EntityTractor? EntityTractor { get; protected set; }
|
||||||
protected int _pictureWidth;
|
public int _pictureWidth;
|
||||||
protected int _pictureHeight;
|
public int _pictureHeight;
|
||||||
protected int _startPosX;
|
protected int _startPosX;
|
||||||
protected int _startPosY;
|
protected int _startPosY;
|
||||||
protected readonly int _tractWidth = 120;
|
protected readonly int _tractWidth = 120;
|
||||||
@@ -40,7 +39,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
_tractHeight = tractHeight;
|
_tractHeight = tractHeight;
|
||||||
EntityTractor = new EntityTractor(speed, weight, bodyColor);
|
EntityTractor = new EntityTractor(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
//Установка позиции
|
|
||||||
public void SetPosition(int x, int y)
|
public void SetPosition(int x, int y)
|
||||||
{
|
{
|
||||||
if (x < 0 || x + _tractWidth > _pictureWidth)
|
if (x < 0 || x + _tractWidth > _pictureWidth)
|
||||||
@@ -54,7 +52,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveTransport(DirectionType direction)
|
public void MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityTractor == null)
|
if (EntityTractor == null)
|
||||||
@@ -89,7 +86,6 @@ namespace ProjectBulldozer.Drawning
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -123,13 +119,9 @@ namespace ProjectBulldozer.Drawning
|
|||||||
}
|
}
|
||||||
return direction switch
|
return direction switch
|
||||||
{
|
{
|
||||||
//влево
|
|
||||||
DirectionType.Left => _startPosX - EntityTractor.Step > 0,
|
DirectionType.Left => _startPosX - EntityTractor.Step > 0,
|
||||||
//вверх
|
|
||||||
DirectionType.Up => _startPosY - EntityTractor.Step > 0,
|
DirectionType.Up => _startPosY - EntityTractor.Step > 0,
|
||||||
// вправо
|
|
||||||
DirectionType.Right => _startPosX + EntityTractor.Step < _pictureWidth,
|
DirectionType.Right => _startPosX + EntityTractor.Step < _pictureWidth,
|
||||||
//вниз
|
|
||||||
DirectionType.Down => _startPosY + EntityTractor.Step < _pictureHeight,
|
DirectionType.Down => _startPosY + EntityTractor.Step < _pictureHeight,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
using System;
|
namespace ProjectBulldozer.Entities
|
||||||
namespace ProjectBulldozer.Entities
|
|
||||||
{
|
{
|
||||||
public class EntityBulldozer : EntityTractor
|
public class EntityBulldozer : EntityTractor
|
||||||
{
|
{
|
||||||
public Color AdditionalColor { get; private set; }
|
public Color AdditionalColor { get; private set; }
|
||||||
public bool Otval { get; private set; }
|
public bool Otval { get; private set; }
|
||||||
public bool SeifBatteries { get; private set; }
|
public bool ThirdWheel { get; private set; }
|
||||||
public EntityBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool otval,
|
public EntityBulldozer(int speed, double weight, Color bodyColor, Color additionalColor,
|
||||||
bool seifBatteries) : base(speed, weight, bodyColor)
|
bool otval, bool thirdWheel) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
Otval = otval;
|
Otval = otval;
|
||||||
SeifBatteries = seifBatteries;
|
ThirdWheel = thirdWheel;
|
||||||
|
|
||||||
|
}
|
||||||
|
public void setAdditionalColor(Color color)
|
||||||
|
{
|
||||||
|
AdditionalColor = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,9 @@
|
|||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
public void setBodyColor(Color color)
|
||||||
|
{
|
||||||
|
BodyColor = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
66
ProjectBulldozer/FormBulldozer.Designer.cs
generated
66
ProjectBulldozer/FormBulldozer.Designer.cs
generated
@@ -1,20 +1,11 @@
|
|||||||
|
namespace Bulldozer
|
||||||
namespace Bulldozer
|
|
||||||
{
|
{
|
||||||
partial class FormBulldozer
|
partial class FormBulldozer
|
||||||
{
|
{
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormBulldozer));
|
||||||
pictureBoxBulldozer = new PictureBox();
|
pictureBoxBulldozer = new PictureBox();
|
||||||
buttonCreateBulldozer = new Button();
|
buttonCreateBulldozer = new Button();
|
||||||
buttonLeft = new Button();
|
buttonLeft = new Button();
|
||||||
@@ -34,7 +25,7 @@ namespace Bulldozer
|
|||||||
pictureBoxBulldozer.Location = new Point(0, 0);
|
pictureBoxBulldozer.Location = new Point(0, 0);
|
||||||
pictureBoxBulldozer.Margin = new Padding(2);
|
pictureBoxBulldozer.Margin = new Padding(2);
|
||||||
pictureBoxBulldozer.Name = "pictureBoxBulldozer";
|
pictureBoxBulldozer.Name = "pictureBoxBulldozer";
|
||||||
pictureBoxBulldozer.Size = new Size(870, 390);
|
pictureBoxBulldozer.Size = new Size(870, 572);
|
||||||
pictureBoxBulldozer.SizeMode = PictureBoxSizeMode.AutoSize;
|
pictureBoxBulldozer.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||||
pictureBoxBulldozer.TabIndex = 0;
|
pictureBoxBulldozer.TabIndex = 0;
|
||||||
pictureBoxBulldozer.TabStop = false;
|
pictureBoxBulldozer.TabStop = false;
|
||||||
@@ -42,24 +33,24 @@ namespace Bulldozer
|
|||||||
// buttonCreateBulldozer
|
// buttonCreateBulldozer
|
||||||
//
|
//
|
||||||
buttonCreateBulldozer.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonCreateBulldozer.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonCreateBulldozer.Location = new Point(11, 332);
|
buttonCreateBulldozer.Location = new Point(20, 514);
|
||||||
buttonCreateBulldozer.Margin = new Padding(2);
|
buttonCreateBulldozer.Margin = new Padding(2);
|
||||||
buttonCreateBulldozer.Name = "buttonCreateBulldozer";
|
buttonCreateBulldozer.Name = "buttonCreateBulldozer";
|
||||||
buttonCreateBulldozer.Size = new Size(95, 48);
|
buttonCreateBulldozer.Size = new Size(88, 48);
|
||||||
buttonCreateBulldozer.TabIndex = 1;
|
buttonCreateBulldozer.TabIndex = 1;
|
||||||
buttonCreateBulldozer.Text = "Создать булльдозер";
|
buttonCreateBulldozer.Text = "Создать бульдозер";
|
||||||
buttonCreateBulldozer.UseVisualStyleBackColor = true;
|
buttonCreateBulldozer.UseVisualStyleBackColor = true;
|
||||||
buttonCreateBulldozer.Click += buttonCreateBulldozer_Click;
|
buttonCreateBulldozer.Click += buttonCreateBulldozer_Click;
|
||||||
//
|
//
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonLeft.BackgroundImage = ProjectBulldozer.Properties.Resources.left1;
|
buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonLeft.Location = new Point(767, 353);
|
buttonLeft.Location = new Point(732, 522);
|
||||||
buttonLeft.Margin = new Padding(2);
|
buttonLeft.Margin = new Padding(2);
|
||||||
buttonLeft.Name = "buttonLeft";
|
buttonLeft.Name = "buttonLeft";
|
||||||
buttonLeft.Size = new Size(30, 27);
|
buttonLeft.Size = new Size(40, 33);
|
||||||
buttonLeft.TabIndex = 2;
|
buttonLeft.TabIndex = 2;
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
buttonLeft.UseVisualStyleBackColor = true;
|
||||||
buttonLeft.Click += buttonMove_Click;
|
buttonLeft.Click += buttonMove_Click;
|
||||||
@@ -67,12 +58,12 @@ namespace Bulldozer
|
|||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonUp.BackgroundImage = ProjectBulldozer.Properties.Resources.up1;
|
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonUp.Location = new Point(801, 320);
|
buttonUp.Location = new Point(776, 485);
|
||||||
buttonUp.Margin = new Padding(2);
|
buttonUp.Margin = new Padding(2);
|
||||||
buttonUp.Name = "buttonUp";
|
buttonUp.Name = "buttonUp";
|
||||||
buttonUp.Size = new Size(34, 28);
|
buttonUp.Size = new Size(40, 33);
|
||||||
buttonUp.TabIndex = 3;
|
buttonUp.TabIndex = 3;
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
buttonUp.Click += buttonMove_Click;
|
buttonUp.Click += buttonMove_Click;
|
||||||
@@ -80,12 +71,12 @@ namespace Bulldozer
|
|||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonRight.BackgroundImage = ProjectBulldozer.Properties.Resources.right1;
|
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonRight.Location = new Point(837, 353);
|
buttonRight.Location = new Point(819, 522);
|
||||||
buttonRight.Margin = new Padding(2);
|
buttonRight.Margin = new Padding(2);
|
||||||
buttonRight.Name = "buttonRight";
|
buttonRight.Name = "buttonRight";
|
||||||
buttonRight.Size = new Size(28, 26);
|
buttonRight.Size = new Size(40, 33);
|
||||||
buttonRight.TabIndex = 4;
|
buttonRight.TabIndex = 4;
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
buttonRight.UseVisualStyleBackColor = true;
|
||||||
buttonRight.Click += buttonMove_Click;
|
buttonRight.Click += buttonMove_Click;
|
||||||
@@ -93,12 +84,12 @@ namespace Bulldozer
|
|||||||
// buttonDown
|
// buttonDown
|
||||||
//
|
//
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonDown.BackgroundImage = ProjectBulldozer.Properties.Resources.down1;
|
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
buttonDown.Location = new Point(801, 353);
|
buttonDown.Location = new Point(776, 522);
|
||||||
buttonDown.Margin = new Padding(2);
|
buttonDown.Margin = new Padding(2);
|
||||||
buttonDown.Name = "buttonDown";
|
buttonDown.Name = "buttonDown";
|
||||||
buttonDown.Size = new Size(32, 27);
|
buttonDown.Size = new Size(40, 33);
|
||||||
buttonDown.TabIndex = 5;
|
buttonDown.TabIndex = 5;
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
buttonDown.Click += buttonMove_Click;
|
buttonDown.Click += buttonMove_Click;
|
||||||
@@ -108,7 +99,7 @@ namespace Bulldozer
|
|||||||
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
comboBoxStrategy.FormattingEnabled = true;
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "В угол" });
|
comboBoxStrategy.Items.AddRange(new object[] { "В центр", "В угол" });
|
||||||
comboBoxStrategy.Location = new Point(740, 8);
|
comboBoxStrategy.Location = new Point(740, 8);
|
||||||
comboBoxStrategy.Margin = new Padding(2);
|
comboBoxStrategy.Margin = new Padding(2);
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||||
@@ -119,10 +110,10 @@ namespace Bulldozer
|
|||||||
// buttonCreateTractor
|
// buttonCreateTractor
|
||||||
//
|
//
|
||||||
buttonCreateTractor.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonCreateTractor.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonCreateTractor.Location = new Point(122, 332);
|
buttonCreateTractor.Location = new Point(122, 514);
|
||||||
buttonCreateTractor.Margin = new Padding(2);
|
buttonCreateTractor.Margin = new Padding(2);
|
||||||
buttonCreateTractor.Name = "buttonCreateTractor";
|
buttonCreateTractor.Name = "buttonCreateTractor";
|
||||||
buttonCreateTractor.Size = new Size(81, 47);
|
buttonCreateTractor.Size = new Size(88, 48);
|
||||||
buttonCreateTractor.TabIndex = 7;
|
buttonCreateTractor.TabIndex = 7;
|
||||||
buttonCreateTractor.Text = "Создать трактор";
|
buttonCreateTractor.Text = "Создать трактор";
|
||||||
buttonCreateTractor.UseVisualStyleBackColor = true;
|
buttonCreateTractor.UseVisualStyleBackColor = true;
|
||||||
@@ -134,7 +125,7 @@ namespace Bulldozer
|
|||||||
buttonStep.Location = new Point(755, 39);
|
buttonStep.Location = new Point(755, 39);
|
||||||
buttonStep.Margin = new Padding(2);
|
buttonStep.Margin = new Padding(2);
|
||||||
buttonStep.Name = "buttonStep";
|
buttonStep.Name = "buttonStep";
|
||||||
buttonStep.Size = new Size(88, 20);
|
buttonStep.Size = new Size(88, 28);
|
||||||
buttonStep.TabIndex = 8;
|
buttonStep.TabIndex = 8;
|
||||||
buttonStep.Text = "Шаг";
|
buttonStep.Text = "Шаг";
|
||||||
buttonStep.UseVisualStyleBackColor = true;
|
buttonStep.UseVisualStyleBackColor = true;
|
||||||
@@ -143,10 +134,10 @@ namespace Bulldozer
|
|||||||
// ButtonSelect_Tractor
|
// ButtonSelect_Tractor
|
||||||
//
|
//
|
||||||
ButtonSelect_Tractor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
ButtonSelect_Tractor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
ButtonSelect_Tractor.Location = new Point(755, 63);
|
ButtonSelect_Tractor.Location = new Point(755, 71);
|
||||||
ButtonSelect_Tractor.Margin = new Padding(2);
|
ButtonSelect_Tractor.Margin = new Padding(2);
|
||||||
ButtonSelect_Tractor.Name = "ButtonSelect_Tractor";
|
ButtonSelect_Tractor.Name = "ButtonSelect_Tractor";
|
||||||
ButtonSelect_Tractor.Size = new Size(88, 23);
|
ButtonSelect_Tractor.Size = new Size(88, 28);
|
||||||
ButtonSelect_Tractor.TabIndex = 9;
|
ButtonSelect_Tractor.TabIndex = 9;
|
||||||
ButtonSelect_Tractor.Text = "Выбрать";
|
ButtonSelect_Tractor.Text = "Выбрать";
|
||||||
ButtonSelect_Tractor.UseVisualStyleBackColor = true;
|
ButtonSelect_Tractor.UseVisualStyleBackColor = true;
|
||||||
@@ -156,7 +147,7 @@ namespace Bulldozer
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(870, 390);
|
ClientSize = new Size(870, 572);
|
||||||
Controls.Add(ButtonSelect_Tractor);
|
Controls.Add(ButtonSelect_Tractor);
|
||||||
Controls.Add(buttonStep);
|
Controls.Add(buttonStep);
|
||||||
Controls.Add(buttonCreateTractor);
|
Controls.Add(buttonCreateTractor);
|
||||||
@@ -175,12 +166,6 @@ namespace Bulldozer
|
|||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
private void comboBoxStrategy_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private PictureBox pictureBoxBulldozer;
|
private PictureBox pictureBoxBulldozer;
|
||||||
private Button buttonCreateBulldozer;
|
private Button buttonCreateBulldozer;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
@@ -191,5 +176,6 @@ namespace Bulldozer
|
|||||||
private Button buttonCreateTractor;
|
private Button buttonCreateTractor;
|
||||||
private Button buttonStep;
|
private Button buttonStep;
|
||||||
private Button ButtonSelect_Tractor;
|
private Button ButtonSelect_Tractor;
|
||||||
|
private EventHandler comboBoxStrategy_SelectedIndexChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using ProjectBulldozer;
|
using ProjectBulldozer;
|
||||||
using ProjectBulldozer.Drawning;
|
using ProjectBulldozer.Drawning;
|
||||||
using ProjectBulldozer.Generics;
|
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
namespace Bulldozer
|
namespace Bulldozer
|
||||||
{
|
{
|
||||||
@@ -30,7 +29,9 @@ namespace Bulldozer
|
|||||||
{
|
{
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
Color color = 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();
|
ColorDialog colorDialog = new ColorDialog();
|
||||||
|
|
||||||
if (colorDialog.ShowDialog() == DialogResult.OK)
|
if (colorDialog.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
color = colorDialog.Color;
|
color = colorDialog.Color;
|
||||||
|
|||||||
171
ProjectBulldozer/FormBulldozerCollections.Designer.cs
generated
171
ProjectBulldozer/FormBulldozerCollections.Designer.cs
generated
@@ -1,72 +1,61 @@
|
|||||||
namespace ProjectBulldozer
|
|
||||||
|
namespace ProjectBulldozer
|
||||||
{
|
{
|
||||||
partial class FormTractorCollections
|
partial class FormTractorCollections
|
||||||
{
|
{
|
||||||
private System.ComponentModel.IContainer components = null;
|
private System.ComponentModel.IContainer components = null;
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
Instruments = new Panel();
|
components = new System.ComponentModel.Container();
|
||||||
maskedTextBoxNumber = new MaskedTextBox();
|
maskedTextBoxNumber = new MaskedTextBox();
|
||||||
ButtonRefreshCollection = new Button();
|
ButtonRefreshCollection = new Button();
|
||||||
ButtonRemoveTractor = new Button();
|
ButtonRemoveTractor = new Button();
|
||||||
ButtonAddTractor = new Button();
|
ButtonAddTractor = new Button();
|
||||||
pictureBoxCollections = new PictureBox();
|
pictureBoxCollections = new PictureBox();
|
||||||
Instruments.SuspendLayout();
|
textBoxStorageName = new TextBox();
|
||||||
|
bindingSource1 = new BindingSource(components);
|
||||||
|
bindingSource2 = new BindingSource(components);
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
listBoxStorage = new ListBox();
|
||||||
|
ButtonAddObject = new Button();
|
||||||
|
ButtonRemoveObject = new Button();
|
||||||
|
Instruments = new GroupBox();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)bindingSource2).BeginInit();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
Instruments.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// Instruments
|
|
||||||
//
|
|
||||||
Instruments.Anchor = AnchorStyles.Right;
|
|
||||||
Instruments.AutoSize = true;
|
|
||||||
Instruments.Controls.Add(maskedTextBoxNumber);
|
|
||||||
Instruments.Controls.Add(ButtonRefreshCollection);
|
|
||||||
Instruments.Controls.Add(ButtonAddTractor);
|
|
||||||
Instruments.Controls.Add(ButtonRemoveTractor);
|
|
||||||
Instruments.Location = new Point(588, 11);
|
|
||||||
Instruments.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
Instruments.Name = "Instruments";
|
|
||||||
Instruments.Size = new Size(150, 456);
|
|
||||||
Instruments.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// maskedTextBoxNumber
|
// maskedTextBoxNumber
|
||||||
//
|
//
|
||||||
maskedTextBoxNumber.Location = new Point(15, 51);
|
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
maskedTextBoxNumber.Location = new Point(33, 399);
|
||||||
maskedTextBoxNumber.Margin = new Padding(3, 2, 3, 2);
|
maskedTextBoxNumber.Margin = new Padding(3, 2, 3, 2);
|
||||||
maskedTextBoxNumber.Mask = "0";
|
maskedTextBoxNumber.Mask = "0";
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
maskedTextBoxNumber.Size = new Size(119, 23);
|
maskedTextBoxNumber.Size = new Size(131, 23);
|
||||||
maskedTextBoxNumber.TabIndex = 4;
|
maskedTextBoxNumber.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// ButtonRefreshCollection
|
// ButtonRefreshCollection
|
||||||
//
|
//
|
||||||
ButtonRefreshCollection.Anchor = AnchorStyles.Right;
|
ButtonRefreshCollection.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
ButtonRefreshCollection.Location = new Point(3, 175);
|
ButtonRefreshCollection.Location = new Point(33, 499);
|
||||||
ButtonRefreshCollection.Margin = new Padding(3, 2, 3, 2);
|
ButtonRefreshCollection.Margin = new Padding(3, 2, 3, 2);
|
||||||
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
|
||||||
ButtonRefreshCollection.Size = new Size(131, 27);
|
ButtonRefreshCollection.Size = new Size(131, 31);
|
||||||
ButtonRefreshCollection.TabIndex = 2;
|
ButtonRefreshCollection.TabIndex = 2;
|
||||||
ButtonRefreshCollection.Text = "Обновить ";
|
ButtonRefreshCollection.Text = "Обновить все";
|
||||||
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
ButtonRefreshCollection.UseVisualStyleBackColor = true;
|
||||||
ButtonRefreshCollection.Click += ButtonRefreshCollection_Click;
|
|
||||||
//
|
//
|
||||||
// ButtonRemoveTractor
|
// ButtonRemoveTractor
|
||||||
//
|
//
|
||||||
ButtonRemoveTractor.Anchor = AnchorStyles.Right;
|
ButtonRemoveTractor.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
ButtonRemoveTractor.Location = new Point(3, 133);
|
ButtonRemoveTractor.Location = new Point(33, 444);
|
||||||
ButtonRemoveTractor.Margin = new Padding(3, 2, 3, 2);
|
ButtonRemoveTractor.Margin = new Padding(3, 2, 3, 2);
|
||||||
ButtonRemoveTractor.Name = "ButtonRemoveTractor";
|
ButtonRemoveTractor.Name = "ButtonRemoveTractor";
|
||||||
ButtonRemoveTractor.Size = new Size(131, 27);
|
ButtonRemoveTractor.Size = new Size(131, 33);
|
||||||
ButtonRemoveTractor.TabIndex = 1;
|
ButtonRemoveTractor.TabIndex = 1;
|
||||||
ButtonRemoveTractor.Text = "Удалить объект";
|
ButtonRemoveTractor.Text = "Удалить объект";
|
||||||
ButtonRemoveTractor.UseVisualStyleBackColor = true;
|
ButtonRemoveTractor.UseVisualStyleBackColor = true;
|
||||||
@@ -74,11 +63,11 @@
|
|||||||
//
|
//
|
||||||
// ButtonAddTractor
|
// ButtonAddTractor
|
||||||
//
|
//
|
||||||
ButtonAddTractor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
ButtonAddTractor.Anchor = AnchorStyles.Top;
|
||||||
ButtonAddTractor.Location = new Point(6, 20);
|
ButtonAddTractor.Location = new Point(33, 346);
|
||||||
ButtonAddTractor.Margin = new Padding(3, 2, 3, 2);
|
ButtonAddTractor.Margin = new Padding(3, 2, 3, 2);
|
||||||
ButtonAddTractor.Name = "ButtonAddTractor";
|
ButtonAddTractor.Name = "ButtonAddTractor";
|
||||||
ButtonAddTractor.Size = new Size(128, 27);
|
ButtonAddTractor.Size = new Size(131, 29);
|
||||||
ButtonAddTractor.TabIndex = 0;
|
ButtonAddTractor.TabIndex = 0;
|
||||||
ButtonAddTractor.Text = "Добавить объект";
|
ButtonAddTractor.Text = "Добавить объект";
|
||||||
ButtonAddTractor.UseVisualStyleBackColor = true;
|
ButtonAddTractor.UseVisualStyleBackColor = true;
|
||||||
@@ -86,41 +75,115 @@
|
|||||||
//
|
//
|
||||||
// pictureBoxCollections
|
// pictureBoxCollections
|
||||||
//
|
//
|
||||||
pictureBoxCollections.Anchor = AnchorStyles.Left;
|
pictureBoxCollections.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
pictureBoxCollections.Location = new Point(12, 11);
|
pictureBoxCollections.Location = new Point(4, 4);
|
||||||
pictureBoxCollections.Margin = new Padding(3, 2, 3, 2);
|
pictureBoxCollections.Margin = new Padding(3, 2, 3, 2);
|
||||||
pictureBoxCollections.Name = "pictureBoxCollections";
|
pictureBoxCollections.Name = "pictureBoxCollections";
|
||||||
pictureBoxCollections.Size = new Size(570, 456);
|
pictureBoxCollections.Size = new Size(693, 541);
|
||||||
pictureBoxCollections.TabIndex = 1;
|
pictureBoxCollections.TabIndex = 1;
|
||||||
pictureBoxCollections.TabStop = false;
|
pictureBoxCollections.TabStop = false;
|
||||||
pictureBoxCollections.Click += pictureBoxCollections_Click;
|
//
|
||||||
|
// textBoxStorageName
|
||||||
|
//
|
||||||
|
textBoxStorageName.Location = new Point(27, 32);
|
||||||
|
textBoxStorageName.Name = "textBoxStorageName";
|
||||||
|
textBoxStorageName.Size = new Size(131, 23);
|
||||||
|
textBoxStorageName.TabIndex = 5;
|
||||||
|
textBoxStorageName.TextChanged += textBoxStorageName_TextChanged;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(listBoxStorage);
|
||||||
|
groupBox1.Controls.Add(ButtonAddObject);
|
||||||
|
groupBox1.Controls.Add(ButtonRemoveObject);
|
||||||
|
groupBox1.Controls.Add(textBoxStorageName);
|
||||||
|
groupBox1.Location = new Point(6, 22);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(189, 296);
|
||||||
|
groupBox1.TabIndex = 5;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Наборы";
|
||||||
|
//
|
||||||
|
// listBoxStorage
|
||||||
|
//
|
||||||
|
listBoxStorage.FormattingEnabled = true;
|
||||||
|
listBoxStorage.ItemHeight = 15;
|
||||||
|
listBoxStorage.Location = new Point(27, 122);
|
||||||
|
listBoxStorage.Name = "listBoxStorage";
|
||||||
|
listBoxStorage.Size = new Size(131, 94);
|
||||||
|
listBoxStorage.TabIndex = 9;
|
||||||
|
listBoxStorage.SelectedIndexChanged += listBoxStorage_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// ButtonAddObject
|
||||||
|
//
|
||||||
|
ButtonAddObject.Anchor = AnchorStyles.Top;
|
||||||
|
ButtonAddObject.Location = new Point(27, 72);
|
||||||
|
ButtonAddObject.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonAddObject.Name = "ButtonAddObject";
|
||||||
|
ButtonAddObject.Size = new Size(131, 29);
|
||||||
|
ButtonAddObject.TabIndex = 7;
|
||||||
|
ButtonAddObject.Text = "Добавить набор";
|
||||||
|
ButtonAddObject.UseVisualStyleBackColor = true;
|
||||||
|
ButtonAddObject.Click += ButtonAddObject_Click;
|
||||||
|
//
|
||||||
|
// ButtonRemoveObject
|
||||||
|
//
|
||||||
|
ButtonRemoveObject.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
ButtonRemoveObject.Location = new Point(27, 244);
|
||||||
|
ButtonRemoveObject.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonRemoveObject.Name = "ButtonRemoveObject";
|
||||||
|
ButtonRemoveObject.Size = new Size(131, 33);
|
||||||
|
ButtonRemoveObject.TabIndex = 8;
|
||||||
|
ButtonRemoveObject.Text = "Удалить набор";
|
||||||
|
ButtonRemoveObject.UseVisualStyleBackColor = true;
|
||||||
|
ButtonRemoveObject.Click += ButtonRemoveObject_Click;
|
||||||
|
//
|
||||||
|
// Instruments
|
||||||
|
//
|
||||||
|
Instruments.Controls.Add(ButtonRefreshCollection);
|
||||||
|
Instruments.Controls.Add(groupBox1);
|
||||||
|
Instruments.Controls.Add(maskedTextBoxNumber);
|
||||||
|
Instruments.Controls.Add(ButtonAddTractor);
|
||||||
|
Instruments.Controls.Add(ButtonRemoveTractor);
|
||||||
|
Instruments.Location = new Point(697, 4);
|
||||||
|
Instruments.Name = "Instruments";
|
||||||
|
Instruments.Size = new Size(200, 541);
|
||||||
|
Instruments.TabIndex = 6;
|
||||||
|
Instruments.TabStop = false;
|
||||||
|
Instruments.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// FormTractorCollections
|
// FormTractorCollections
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(748, 478);
|
ClientSize = new Size(904, 543);
|
||||||
Controls.Add(pictureBoxCollections);
|
|
||||||
Controls.Add(Instruments);
|
Controls.Add(Instruments);
|
||||||
|
Controls.Add(pictureBoxCollections);
|
||||||
Margin = new Padding(3, 2, 3, 2);
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
Name = "FormTractorCollections";
|
Name = "FormTractorCollections";
|
||||||
Text = "Набор трактороов";
|
Text = "Набор локомотивов";
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)bindingSource1).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)bindingSource2).EndInit();
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
Instruments.ResumeLayout(false);
|
Instruments.ResumeLayout(false);
|
||||||
Instruments.PerformLayout();
|
Instruments.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollections).EndInit();
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
|
||||||
}
|
}
|
||||||
private void pictureBoxCollections_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
private Panel Instruments;
|
|
||||||
private Button ButtonRefreshCollection;
|
private Button ButtonRefreshCollection;
|
||||||
private Button ButtonRemoveTractor;
|
private Button ButtonRemoveTractor;
|
||||||
private Button ButtonAddTractor;
|
private Button ButtonAddTractor;
|
||||||
private PictureBox pictureBoxCollections;
|
private PictureBox pictureBoxCollections;
|
||||||
private MaskedTextBox maskedTextBoxNumber;
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private TextBox textBoxStorageName;
|
||||||
|
private BindingSource bindingSource1;
|
||||||
|
private BindingSource bindingSource2;
|
||||||
|
private ListBox listBoxStorage;
|
||||||
|
private Button ButtonAddObject;
|
||||||
|
private Button ButtonRemoveObject;
|
||||||
|
private GroupBox Instruments;
|
||||||
|
private EventHandler textBoxStorageName_TextChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,56 +1,119 @@
|
|||||||
using Bulldozer;
|
using Bulldozer;
|
||||||
using ProjectBulldozer.Drawning;
|
|
||||||
using ProjectBulldozer.Generics;
|
using ProjectBulldozer.Generics;
|
||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.Drawning;
|
||||||
|
|
||||||
namespace ProjectBulldozer
|
namespace ProjectBulldozer
|
||||||
{
|
{
|
||||||
public partial class FormTractorCollections : Form
|
public partial class FormTractorCollections : Form
|
||||||
{
|
{
|
||||||
private readonly TractorGenericCollection<DrawingTractor, DrawingObjectTractor> _Tractors;
|
private readonly TractorGenericStorage _storage;
|
||||||
|
readonly int countPlace = 10;
|
||||||
public FormTractorCollections()
|
public FormTractorCollections()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_Tractors = new TractorGenericCollection<DrawingTractor, DrawingObjectTractor>(pictureBoxCollections.Width,
|
_storage = new TractorGenericStorage(pictureBoxCollections.Width, pictureBoxCollections.Height);
|
||||||
pictureBoxCollections.Height);
|
}
|
||||||
|
private void ReloadObjects()
|
||||||
|
{
|
||||||
|
int index = listBoxStorage.SelectedIndex;
|
||||||
|
|
||||||
|
listBoxStorage.Items.Clear();
|
||||||
|
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
listBoxStorage.Items.Add(_storage.Keys[i]);
|
||||||
|
}
|
||||||
|
if (listBoxStorage.Items.Count > 0 && (index == -1 || index >= listBoxStorage.Items.Count))
|
||||||
|
{
|
||||||
|
listBoxStorage.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxStorage.Items.Count > 0 && index > -1 && index < listBoxStorage.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxStorage.SelectedIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не всё заполнено", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_storage.AddSet(textBoxStorageName.Text);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
|
private void listBoxStorage_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBoxCollections.Image = _storage[listBoxStorage.SelectedItem?.ToString() ?? string.Empty]?.ShowTractors();
|
||||||
|
}
|
||||||
|
private void ButtonRemoveObject_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxStorage.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
|
||||||
|
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_storage.DelSet(listBoxStorage.SelectedItem.ToString() ?? string.Empty);
|
||||||
|
ReloadObjects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
private void ButtonAddTractor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_Tractors == null) return;
|
var formBulldozerConfig = new FormBulldozerConfig();
|
||||||
FormBulldozer form = new();
|
formBulldozerConfig.AddEvent(AddTractor);
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
formBulldozerConfig.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddTractor(DrawingTractor tractor)
|
||||||
|
{
|
||||||
|
tractor._pictureWidth = pictureBoxCollections.Width;
|
||||||
|
tractor._pictureHeight = pictureBoxCollections.Height;
|
||||||
|
|
||||||
|
if (listBoxStorage.SelectedIndex == -1) return;
|
||||||
|
|
||||||
|
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
|
||||||
|
if (obj == null)
|
||||||
{
|
{
|
||||||
//проверяем, удалось ли нам загрузить объект
|
return;
|
||||||
if (_Tractors + form.SelectedTractor != -1)
|
}
|
||||||
{
|
int addedIndex = obj + tractor;
|
||||||
MessageBox.Show("Объект добавлен");
|
if (addedIndex != -1 && addedIndex < countPlace)
|
||||||
pictureBoxCollections.Image = _Tractors.ShowTractors();
|
{
|
||||||
}
|
MessageBox.Show("Объект добавлен");
|
||||||
else
|
pictureBoxCollections.Image = obj.ShowTractors();
|
||||||
{
|
}
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
else
|
||||||
}
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
private void ButtonRemoveTractor_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (listBoxStorage.SelectedIndex == -1) return;
|
||||||
|
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||||
if (_Tractors - pos != null)
|
if (obj - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBoxCollections.Image = _Tractors.ShowTractors();
|
pictureBoxCollections.Image = obj.ShowTractors();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
pictureBoxCollections.Image = _Tractors.ShowTractors();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
412
ProjectBulldozer/FormBulldozerConfig.Designer.cs
generated
Normal file
412
ProjectBulldozer/FormBulldozerConfig.Designer.cs
generated
Normal file
@@ -0,0 +1,412 @@
|
|||||||
|
namespace Bulldozer
|
||||||
|
{
|
||||||
|
partial class FormBulldozerConfig
|
||||||
|
{
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
labelModifiedObject = new Label();
|
||||||
|
labelSimpleObject = new Label();
|
||||||
|
GroupColor = new GroupBox();
|
||||||
|
panelPurple = new Panel();
|
||||||
|
panelYellow = new Panel();
|
||||||
|
panelBlack = new Panel();
|
||||||
|
panelBlue = new Panel();
|
||||||
|
panelGray = new Panel();
|
||||||
|
panelGreen = new Panel();
|
||||||
|
panelWhite = new Panel();
|
||||||
|
panelRed = new Panel();
|
||||||
|
checkBoxKovsh = new CheckBox();
|
||||||
|
checkBoxThirdWheel = new CheckBox();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
numericUpDownWeight = new NumericUpDown();
|
||||||
|
numericUpDownSpeed = new NumericUpDown();
|
||||||
|
ButtonOk = new Button();
|
||||||
|
ButtonCancel = new Button();
|
||||||
|
label_body_color = new Label();
|
||||||
|
label_additional_color = new Label();
|
||||||
|
pictureBoxObject = new PictureBox();
|
||||||
|
label4 = new Label();
|
||||||
|
PanelObject = new Panel();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
GroupColor.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||||
|
PanelObject.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(labelModifiedObject);
|
||||||
|
groupBox1.Controls.Add(labelSimpleObject);
|
||||||
|
groupBox1.Controls.Add(GroupColor);
|
||||||
|
groupBox1.Controls.Add(checkBoxKovsh);
|
||||||
|
groupBox1.Controls.Add(checkBoxThirdWheel);
|
||||||
|
groupBox1.Controls.Add(label2);
|
||||||
|
groupBox1.Controls.Add(label1);
|
||||||
|
groupBox1.Controls.Add(numericUpDownWeight);
|
||||||
|
groupBox1.Controls.Add(numericUpDownSpeed);
|
||||||
|
groupBox1.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
groupBox1.Location = new Point(10, 9);
|
||||||
|
groupBox1.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
groupBox1.Size = new Size(542, 405);
|
||||||
|
groupBox1.TabIndex = 0;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Параметры";
|
||||||
|
groupBox1.Enter += groupBox1_Enter;
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
labelModifiedObject.AllowDrop = true;
|
||||||
|
labelModifiedObject.BackColor = SystemColors.Info;
|
||||||
|
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelModifiedObject.ForeColor = SystemColors.ControlText;
|
||||||
|
labelModifiedObject.Location = new Point(377, 170);
|
||||||
|
labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
labelModifiedObject.Size = new Size(132, 53);
|
||||||
|
labelModifiedObject.TabIndex = 9;
|
||||||
|
labelModifiedObject.Text = "Продвинутый";
|
||||||
|
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
labelSimpleObject.AllowDrop = true;
|
||||||
|
labelSimpleObject.BackColor = SystemColors.Info;
|
||||||
|
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
labelSimpleObject.ForeColor = SystemColors.ControlText;
|
||||||
|
labelSimpleObject.Location = new Point(225, 170);
|
||||||
|
labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
labelSimpleObject.Size = new Size(132, 53);
|
||||||
|
labelSimpleObject.TabIndex = 7;
|
||||||
|
labelSimpleObject.Text = "Простой";
|
||||||
|
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||||
|
//
|
||||||
|
// GroupColor
|
||||||
|
//
|
||||||
|
GroupColor.Controls.Add(panelPurple);
|
||||||
|
GroupColor.Controls.Add(panelYellow);
|
||||||
|
GroupColor.Controls.Add(panelBlack);
|
||||||
|
GroupColor.Controls.Add(panelBlue);
|
||||||
|
GroupColor.Controls.Add(panelGray);
|
||||||
|
GroupColor.Controls.Add(panelGreen);
|
||||||
|
GroupColor.Controls.Add(panelWhite);
|
||||||
|
GroupColor.Controls.Add(panelRed);
|
||||||
|
GroupColor.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
GroupColor.Location = new Point(225, 20);
|
||||||
|
GroupColor.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
GroupColor.Name = "GroupColor";
|
||||||
|
GroupColor.Padding = new Padding(3, 2, 3, 2);
|
||||||
|
GroupColor.Size = new Size(302, 131);
|
||||||
|
GroupColor.TabIndex = 6;
|
||||||
|
GroupColor.TabStop = false;
|
||||||
|
GroupColor.Text = "Цвета";
|
||||||
|
GroupColor.Enter += GroupColor_Enter;
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
panelPurple.BackColor = Color.Purple;
|
||||||
|
panelPurple.Location = new Point(226, 76);
|
||||||
|
panelPurple.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelPurple.Name = "panelPurple";
|
||||||
|
panelPurple.Size = new Size(68, 41);
|
||||||
|
panelPurple.TabIndex = 3;
|
||||||
|
panelPurple.Paint += panelPurple_Paint;
|
||||||
|
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
panelYellow.BackColor = Color.Yellow;
|
||||||
|
panelYellow.Location = new Point(226, 24);
|
||||||
|
panelYellow.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelYellow.Name = "panelYellow";
|
||||||
|
panelYellow.Size = new Size(68, 41);
|
||||||
|
panelYellow.TabIndex = 1;
|
||||||
|
panelYellow.Paint += panelYellow_Paint;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
panelBlack.BackColor = Color.Black;
|
||||||
|
panelBlack.Location = new Point(152, 76);
|
||||||
|
panelBlack.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelBlack.Name = "panelBlack";
|
||||||
|
panelBlack.Size = new Size(68, 41);
|
||||||
|
panelBlack.TabIndex = 4;
|
||||||
|
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
panelBlue.BackColor = Color.Blue;
|
||||||
|
panelBlue.Location = new Point(152, 24);
|
||||||
|
panelBlue.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelBlue.Name = "panelBlue";
|
||||||
|
panelBlue.Size = new Size(68, 41);
|
||||||
|
panelBlue.TabIndex = 1;
|
||||||
|
panelBlue.Paint += panelBlue_Paint;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
panelGray.BackColor = Color.Gray;
|
||||||
|
panelGray.Location = new Point(79, 76);
|
||||||
|
panelGray.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelGray.Name = "panelGray";
|
||||||
|
panelGray.Size = new Size(68, 41);
|
||||||
|
panelGray.TabIndex = 5;
|
||||||
|
panelGray.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
panelGreen.BackColor = Color.Lime;
|
||||||
|
panelGreen.Location = new Point(79, 24);
|
||||||
|
panelGreen.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelGreen.Name = "panelGreen";
|
||||||
|
panelGreen.Size = new Size(68, 41);
|
||||||
|
panelGreen.TabIndex = 1;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
panelWhite.BackColor = Color.White;
|
||||||
|
panelWhite.Location = new Point(5, 76);
|
||||||
|
panelWhite.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelWhite.Name = "panelWhite";
|
||||||
|
panelWhite.Size = new Size(68, 41);
|
||||||
|
panelWhite.TabIndex = 2;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
panelRed.BackColor = Color.Red;
|
||||||
|
panelRed.Location = new Point(5, 24);
|
||||||
|
panelRed.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
panelRed.Name = "panelRed";
|
||||||
|
panelRed.Size = new Size(68, 41);
|
||||||
|
panelRed.TabIndex = 0;
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
//
|
||||||
|
// checkBoxKovsh
|
||||||
|
//
|
||||||
|
checkBoxKovsh.AutoSize = true;
|
||||||
|
checkBoxKovsh.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
checkBoxKovsh.Location = new Point(18, 132);
|
||||||
|
checkBoxKovsh.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
checkBoxKovsh.Name = "checkBoxKovsh";
|
||||||
|
checkBoxKovsh.Size = new Size(182, 19);
|
||||||
|
checkBoxKovsh.TabIndex = 5;
|
||||||
|
checkBoxKovsh.Text = "Третье колесо в гусеницах";
|
||||||
|
checkBoxKovsh.UseVisualStyleBackColor = true;
|
||||||
|
checkBoxKovsh.CheckedChanged += GroupColor_Enter;
|
||||||
|
//
|
||||||
|
// checkBoxThirdWheel
|
||||||
|
//
|
||||||
|
checkBoxThirdWheel.AutoSize = true;
|
||||||
|
checkBoxThirdWheel.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
checkBoxThirdWheel.Location = new Point(18, 106);
|
||||||
|
checkBoxThirdWheel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
checkBoxThirdWheel.Name = "checkBoxThirdWheel";
|
||||||
|
checkBoxThirdWheel.Size = new Size(60, 19);
|
||||||
|
checkBoxThirdWheel.TabIndex = 4;
|
||||||
|
checkBoxThirdWheel.Text = "Отвал";
|
||||||
|
checkBoxThirdWheel.UseVisualStyleBackColor = true;
|
||||||
|
checkBoxThirdWheel.CheckedChanged += checkBoxOtval_CheckedChanged;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
label2.Location = new Point(5, 70);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(31, 15);
|
||||||
|
label2.TabIndex = 3;
|
||||||
|
label2.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.ForeColor = SystemColors.ControlLightLight;
|
||||||
|
label1.Location = new Point(5, 38);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(63, 15);
|
||||||
|
label1.TabIndex = 2;
|
||||||
|
label1.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
numericUpDownWeight.BackColor = SystemColors.Info;
|
||||||
|
numericUpDownWeight.Location = new Point(88, 68);
|
||||||
|
numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||||
|
numericUpDownWeight.Size = new Size(131, 23);
|
||||||
|
numericUpDownWeight.TabIndex = 1;
|
||||||
|
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
numericUpDownSpeed.BackColor = SystemColors.Info;
|
||||||
|
numericUpDownSpeed.Location = new Point(88, 36);
|
||||||
|
numericUpDownSpeed.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||||
|
numericUpDownSpeed.Size = new Size(131, 23);
|
||||||
|
numericUpDownSpeed.TabIndex = 0;
|
||||||
|
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// ButtonOk
|
||||||
|
//
|
||||||
|
ButtonOk.BackColor = SystemColors.Info;
|
||||||
|
ButtonOk.ForeColor = SystemColors.ControlText;
|
||||||
|
ButtonOk.Location = new Point(27, 345);
|
||||||
|
ButtonOk.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonOk.Name = "ButtonOk";
|
||||||
|
ButtonOk.Size = new Size(93, 44);
|
||||||
|
ButtonOk.TabIndex = 12;
|
||||||
|
ButtonOk.Text = "Добавить";
|
||||||
|
ButtonOk.UseVisualStyleBackColor = false;
|
||||||
|
ButtonOk.Click += ButtonOk_Click;
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
ButtonCancel.BackColor = SystemColors.Info;
|
||||||
|
ButtonCancel.ForeColor = SystemColors.ControlText;
|
||||||
|
ButtonCancel.Location = new Point(203, 345);
|
||||||
|
ButtonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
ButtonCancel.Name = "ButtonCancel";
|
||||||
|
ButtonCancel.Size = new Size(93, 44);
|
||||||
|
ButtonCancel.TabIndex = 13;
|
||||||
|
ButtonCancel.Text = "Отмена";
|
||||||
|
ButtonCancel.UseVisualStyleBackColor = false;
|
||||||
|
ButtonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// label_body_color
|
||||||
|
//
|
||||||
|
label_body_color.AllowDrop = true;
|
||||||
|
label_body_color.BackColor = SystemColors.Info;
|
||||||
|
label_body_color.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
label_body_color.ForeColor = SystemColors.ControlText;
|
||||||
|
label_body_color.Location = new Point(27, 7);
|
||||||
|
label_body_color.Name = "label_body_color";
|
||||||
|
label_body_color.Size = new Size(93, 42);
|
||||||
|
label_body_color.TabIndex = 10;
|
||||||
|
label_body_color.Text = "Осн. цвет";
|
||||||
|
label_body_color.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
label_body_color.DragDrop += PanelColor_DragDrop;
|
||||||
|
label_body_color.DragEnter += PanelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// label_additional_color
|
||||||
|
//
|
||||||
|
label_additional_color.AllowDrop = true;
|
||||||
|
label_additional_color.BackColor = SystemColors.Info;
|
||||||
|
label_additional_color.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
label_additional_color.ForeColor = SystemColors.ControlText;
|
||||||
|
label_additional_color.Location = new Point(207, 7);
|
||||||
|
label_additional_color.Name = "label_additional_color";
|
||||||
|
label_additional_color.Size = new Size(89, 42);
|
||||||
|
label_additional_color.TabIndex = 10;
|
||||||
|
label_additional_color.Text = "Доп. цвет";
|
||||||
|
label_additional_color.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
label_additional_color.DragDrop += PanelColor_DragDrop;
|
||||||
|
label_additional_color.DragEnter += PanelColor_DragEnter;
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
pictureBoxObject.Location = new Point(27, 53);
|
||||||
|
pictureBoxObject.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
pictureBoxObject.Size = new Size(306, 288);
|
||||||
|
pictureBoxObject.TabIndex = 1;
|
||||||
|
pictureBoxObject.TabStop = false;
|
||||||
|
pictureBoxObject.Click += pictureBoxObject_Click;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(449, 278);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(0, 15);
|
||||||
|
label4.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// PanelObject
|
||||||
|
//
|
||||||
|
PanelObject.AllowDrop = true;
|
||||||
|
PanelObject.Controls.Add(ButtonCancel);
|
||||||
|
PanelObject.Controls.Add(ButtonOk);
|
||||||
|
PanelObject.Controls.Add(pictureBoxObject);
|
||||||
|
PanelObject.Controls.Add(label_body_color);
|
||||||
|
PanelObject.Controls.Add(label_additional_color);
|
||||||
|
PanelObject.Location = new Point(558, 19);
|
||||||
|
PanelObject.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
PanelObject.Name = "PanelObject";
|
||||||
|
PanelObject.Size = new Size(347, 395);
|
||||||
|
PanelObject.TabIndex = 15;
|
||||||
|
PanelObject.DragDrop += PanelObject_DragDrop;
|
||||||
|
PanelObject.DragEnter += PanelObject_DragEnter;
|
||||||
|
//
|
||||||
|
// FormBulldozerConfig
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BackColor = SystemColors.WindowFrame;
|
||||||
|
ClientSize = new Size(917, 419);
|
||||||
|
Controls.Add(PanelObject);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
|
Name = "FormBulldozerConfig";
|
||||||
|
Text = "FormBulldozerlConfig";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
GroupColor.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||||
|
PanelObject.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private GroupBox GroupColor;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelRed;
|
||||||
|
private CheckBox checkBoxKovsh;
|
||||||
|
private CheckBox checkBoxThirdWheel;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private Panel panelPurple;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Label label4;
|
||||||
|
private Button ButtonOk;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
private Panel PanelObject;
|
||||||
|
private Label label_body_color;
|
||||||
|
private Label label_additional_color;
|
||||||
|
private EventHandler groupBox1_Enter;
|
||||||
|
private PaintEventHandler panelPurple_Paint;
|
||||||
|
private PaintEventHandler panelYellow_Paint;
|
||||||
|
private PaintEventHandler panelBlue_Paint;
|
||||||
|
private EventHandler checkBoxOtval_CheckedChanged;
|
||||||
|
private EventHandler pictureBoxObject_Click;
|
||||||
|
|
||||||
|
public EventHandler GroupColor_Enter { get; private set; }
|
||||||
|
public EventHandler ButtonCancel_Click { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
119
ProjectBulldozer/FormBulldozerConfig.cs
Normal file
119
ProjectBulldozer/FormBulldozerConfig.cs
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
using ProjectBulldozer.Drawning;
|
||||||
|
using ProjectBulldozer.Entities;
|
||||||
|
namespace Bulldozer
|
||||||
|
{
|
||||||
|
public partial class FormBulldozerConfig : Form
|
||||||
|
{
|
||||||
|
DrawingTractor? _tractor = null;
|
||||||
|
public event Action<DrawingTractor>? EventAddTractor;
|
||||||
|
public FormBulldozerConfig()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGray.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelRed.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
ButtonCancel.Click += (s, e) => Close();
|
||||||
|
}
|
||||||
|
private void DrawTractor()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_tractor?.SetPosition(pictureBoxObject.Width / 10, pictureBoxObject.Height / 10);
|
||||||
|
_tractor?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
|
}
|
||||||
|
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||||
|
DragDropEffects.Copy | DragDropEffects.Move);
|
||||||
|
}
|
||||||
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject":
|
||||||
|
_tractor = new DrawingTractor((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_tractor = new DrawingBulldozer((int)numericUpDownSpeed.Value,
|
||||||
|
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxThirdWheel.Checked,
|
||||||
|
checkBoxKovsh.Checked, pictureBoxObject.Width,
|
||||||
|
pictureBoxObject.Height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawTractor();
|
||||||
|
}
|
||||||
|
private void PanelColor_DragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.Copy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.Effect = DragDropEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void PanelColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_tractor == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (((Label)sender).Name)
|
||||||
|
{
|
||||||
|
case "label_body_color":
|
||||||
|
_tractor?.EntityTractor?.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
case "label_additional_color":
|
||||||
|
if (!(_tractor is DrawingBulldozer))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(_tractor.EntityTractor as EntityBulldozer)?
|
||||||
|
.setAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawTractor();
|
||||||
|
}
|
||||||
|
public void AddEvent(Action<DrawingTractor> ev)
|
||||||
|
{
|
||||||
|
if (EventAddTractor == null)
|
||||||
|
{
|
||||||
|
EventAddTractor = ev;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddTractor += ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddTractor?.Invoke(obj: _tractor);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
ProjectBulldozer/FormBulldozerConfig.resx
Normal file
120
ProjectBulldozer/FormBulldozerConfig.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -1,29 +1,24 @@
|
|||||||
using ProjectBulldozer.MovementStrategy;
|
using ProjectBulldozer.Drawning;
|
||||||
using ProjectBulldozer.Drawning;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
|
|
||||||
namespace ProjectBulldozer.Generics
|
namespace ProjectBulldozer.Generics
|
||||||
{
|
{
|
||||||
internal class TractorGenericCollection<T, U> where T : DrawingTractor where U : IMoveableObject
|
internal class TractorGenericCollection<T, U> where T : DrawingTractor where U : IMoveableObject
|
||||||
{
|
{
|
||||||
//ширина /высота окна
|
|
||||||
private readonly int _pictureWidth;
|
private readonly int _pictureWidth;
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
//ширина /высота занимаемого места
|
private readonly int _placeSizeWidth = 150;
|
||||||
private readonly int _placeSizeWidth = 170;
|
|
||||||
private readonly int _placeSizeHeight = 130;
|
private readonly int _placeSizeHeight = 130;
|
||||||
/// Набор объектов
|
|
||||||
private readonly SetGeneric<T> _collection;
|
private readonly SetGeneric<T> _collection;
|
||||||
public TractorGenericCollection(int picWidth, int picHeight)
|
public TractorGenericCollection(int picWidth, int picHeight)
|
||||||
{
|
{
|
||||||
|
|
||||||
// высчитываем размер массива для setgeneric
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
int width = picWidth / _placeSizeWidth;
|
||||||
int height = picHeight / _placeSizeHeight;
|
int height = picHeight / _placeSizeHeight;
|
||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = new SetGeneric<T>(width * height);
|
_collection = new SetGeneric<T>(width * height);
|
||||||
}
|
}
|
||||||
/// Перегрузка оператора сложения
|
public static int operator +(TractorGenericCollection<T, U> collect, T? tract)
|
||||||
public static int operator +(TractorGenericCollection<T, U> collect, T tract)
|
|
||||||
{
|
{
|
||||||
if (tract == null)
|
if (tract == null)
|
||||||
{
|
{
|
||||||
@@ -31,26 +26,15 @@ namespace ProjectBulldozer.Generics
|
|||||||
}
|
}
|
||||||
return collect._collection.Insert(tract);
|
return collect._collection.Insert(tract);
|
||||||
}
|
}
|
||||||
public static bool operator -(TractorGenericCollection<T, U> collect, int
|
public static T? operator -(TractorGenericCollection<T, U> collect, int pos)
|
||||||
pos)
|
|
||||||
{
|
{
|
||||||
T obj = collect._collection.Get(pos);
|
T? obj = collect._collection[pos];
|
||||||
if (obj != null)
|
if (obj != null)
|
||||||
{
|
{
|
||||||
return collect.Remove(pos);
|
collect._collection.Remove(pos);
|
||||||
}
|
}
|
||||||
return false;
|
return obj;
|
||||||
}
|
}
|
||||||
private bool Remove(int pos)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
// получение объекта imoveableObj
|
|
||||||
public U? GetU(int pos)
|
|
||||||
{
|
|
||||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
|
||||||
}
|
|
||||||
/// Вывод всего набора объектов
|
|
||||||
public Bitmap ShowTractors()
|
public Bitmap ShowTractors()
|
||||||
{
|
{
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
@@ -72,21 +56,26 @@ namespace ProjectBulldozer.Generics
|
|||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawObjects(Graphics g)
|
private void DrawObjects(Graphics g)
|
||||||
{
|
{
|
||||||
int HeightObjCount = _pictureHeight / _placeSizeHeight;
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
int WidthObjCount = _pictureWidth / _placeSizeWidth;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
for (int i = 0; i < _collection.Count; i++)
|
for (int i = 0; i < _collection.Count; i++)
|
||||||
{
|
{
|
||||||
T t = _collection.Get(i);
|
var obj = _collection[i];
|
||||||
if (t != null)
|
obj?.SetPosition(
|
||||||
{
|
(int)((width - 1) * _placeSizeWidth - (i % width * _placeSizeWidth)),
|
||||||
{
|
(int)((height - 1) * _placeSizeHeight - (i / width * _placeSizeHeight))
|
||||||
t.SetPosition(((_collection.Count - i - 1) % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (_collection.Count - i - 1) / (_pictureWidth / _placeSizeWidth) * _placeSizeHeight);
|
);
|
||||||
t.DrawTransport(g);
|
obj?.DrawTransport(g);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,14 @@
|
|||||||
{
|
{
|
||||||
internal class SetGeneric<T> where T : class
|
internal class SetGeneric<T> where T : class
|
||||||
{
|
{
|
||||||
private readonly T[] _places;
|
private readonly List<T?> _places;
|
||||||
public int Count => _places.Length;
|
public int Count => _places.Count;
|
||||||
|
/// Максимальное количество объектов в списке
|
||||||
|
private readonly int _maxCount;
|
||||||
public SetGeneric(int count)
|
public SetGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T[count];
|
_maxCount = count;
|
||||||
|
_places = new List<T?>(count);
|
||||||
}
|
}
|
||||||
/// Добавление объекта в набор
|
/// Добавление объекта в набор
|
||||||
public int Insert(T tract)
|
public int Insert(T tract)
|
||||||
@@ -15,49 +18,42 @@
|
|||||||
}
|
}
|
||||||
public int Insert(T tract, int position)
|
public int Insert(T tract, int position)
|
||||||
{
|
{
|
||||||
int NoEmpty = 0, temp = 0;
|
if (position < 0 || position >= _maxCount) return -1;
|
||||||
for (int i = position; i < Count; i++)
|
_places.Insert(position, tract);
|
||||||
{
|
return position;
|
||||||
if (_places[i] != null) NoEmpty++;
|
|
||||||
}
|
|
||||||
if (NoEmpty == Count - position - 1) return -1;
|
|
||||||
|
|
||||||
if (position < Count && position >= 0)
|
|
||||||
{
|
|
||||||
for (int j = position; j < Count; j++)
|
|
||||||
{
|
|
||||||
if (_places[j] == null)
|
|
||||||
{
|
|
||||||
temp = j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// shift right
|
|
||||||
for (int i = temp; i > position; i--)
|
|
||||||
{
|
|
||||||
_places[i] = _places[i - 1];
|
|
||||||
}
|
|
||||||
_places[position] = tract;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Remove(int position)
|
public T? Remove(int position)
|
||||||
{
|
{
|
||||||
if (position >= Count || position < 0)
|
if (position >= Count || position < 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
T tmp = _places[position];
|
T? tmp = _places[position];
|
||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
//Получение объекта из набора по позиции
|
public T? this[int position]
|
||||||
public T? Get(int position)
|
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
get
|
||||||
if (position < 0 || position >= Count) return null;
|
{
|
||||||
return _places[position];
|
if (position < 0 || position >= Count) return null;
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count || Count == _maxCount) return;
|
||||||
|
_places.Insert(position, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IEnumerable<T?> GetTractors(int? maxTracts = null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _places.Count; ++i)
|
||||||
|
{
|
||||||
|
yield return _places[i];
|
||||||
|
if (maxTracts.HasValue && i == maxTracts.Value)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace ProjectBulldozer.Generics
|
namespace ProjectBulldozer.MovementStrategy
|
||||||
{
|
{
|
||||||
public enum Status
|
public enum Status
|
||||||
{
|
{
|
||||||
|
|||||||
43
ProjectBulldozer/Generics/TractorGenericStorage.cs
Normal file
43
ProjectBulldozer/Generics/TractorGenericStorage.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using ProjectBulldozer.Drawning;
|
||||||
|
namespace ProjectBulldozer.Generics
|
||||||
|
{
|
||||||
|
internal class TractorGenericStorage
|
||||||
|
{
|
||||||
|
readonly Dictionary<string, TractorGenericCollection<DrawingTractor, DrawingObjectTractor>> _TractorsStorage;
|
||||||
|
public List<string> Keys => _TractorsStorage.Keys.ToList();
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
public TractorGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_TractorsStorage = new Dictionary<string, TractorGenericCollection<DrawingTractor, DrawingObjectTractor>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
public void AddSet(string name)
|
||||||
|
{
|
||||||
|
if (!_TractorsStorage.ContainsKey(name))
|
||||||
|
{
|
||||||
|
_TractorsStorage.Add(name, new TractorGenericCollection<DrawingTractor, DrawingObjectTractor>(_pictureWidth, _pictureHeight));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DelSet(string name)
|
||||||
|
{
|
||||||
|
if (_TractorsStorage.ContainsKey(name))
|
||||||
|
{
|
||||||
|
_TractorsStorage.Remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public TractorGenericCollection<DrawingTractor, DrawingObjectTractor>?
|
||||||
|
this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_TractorsStorage.ContainsKey(ind))
|
||||||
|
{
|
||||||
|
return _TractorsStorage[ind];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using ProjectBulldozer.Generics;
|
namespace ProjectBulldozer.MovementStrategy
|
||||||
|
|
||||||
namespace ProjectBulldozer.MovementStrategy
|
|
||||||
{
|
{
|
||||||
public abstract class AbstractStrategy
|
public abstract class AbstractStrategy
|
||||||
{
|
{
|
||||||
@@ -10,6 +8,7 @@ namespace ProjectBulldozer.MovementStrategy
|
|||||||
protected int FieldWidth { get; private set; }
|
protected int FieldWidth { get; private set; }
|
||||||
protected int FieldHeight { get; private set; }
|
protected int FieldHeight { get; private set; }
|
||||||
public Status GetStatus() { return _state; }
|
public Status GetStatus() { return _state; }
|
||||||
|
|
||||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
public void SetData(IMoveableObject moveableObject, int width, int height)
|
||||||
{
|
{
|
||||||
if (moveableObject == null)
|
if (moveableObject == null)
|
||||||
@@ -22,7 +21,6 @@ namespace ProjectBulldozer.MovementStrategy
|
|||||||
FieldWidth = width;
|
FieldWidth = width;
|
||||||
FieldHeight = height;
|
FieldHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MakeStep()
|
public void MakeStep()
|
||||||
{
|
{
|
||||||
if (_state != Status.InProgress)
|
if (_state != Status.InProgress)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using ProjectBulldozer.Drawning;
|
using ProjectBulldozer.MovementStrategy;
|
||||||
namespace ProjectBulldozer.MovementStrategy
|
namespace ProjectBulldozer.Drawning
|
||||||
{
|
{
|
||||||
public class DrawingObjectTractor : IMoveableObject
|
public class DrawingObjectTractor : IMoveableObject
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
namespace ProjectBulldozer.MovementStrategy
|
using Bulldozer;
|
||||||
|
namespace ProjectBulldozer.MovementStrategy
|
||||||
{
|
{
|
||||||
public interface IMoveableObject
|
public interface IMoveableObject
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,17 +6,9 @@
|
|||||||
private readonly int _y;
|
private readonly int _y;
|
||||||
private readonly int _width;
|
private readonly int _width;
|
||||||
private readonly int _height;
|
private readonly int _height;
|
||||||
/// Левая граница
|
|
||||||
public int LeftBorder => _x;
|
|
||||||
/// Верхняя граница
|
|
||||||
public int TopBorder => _y;
|
|
||||||
/// Правая граница
|
|
||||||
public int RightBorder => _x + _width;
|
public int RightBorder => _x + _width;
|
||||||
/// Нижняя граница
|
|
||||||
public int DownBorder => _y + _height;
|
public int DownBorder => _y + _height;
|
||||||
/// Середина объекта по горизонтали
|
|
||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||||
/// Середина объекта по вертикали
|
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
public int ObjectMiddleVertical => _y + _height / 2;
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
public ObjectParameters(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user