Третья усложненная лабораторн.
This commit is contained in:
parent
a8cca87e52
commit
436fb15353
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace ProjectExcavator.MovementStrategy
|
||||
{
|
||||
|
@ -36,6 +36,21 @@ namespace ProjectExcavator
|
||||
}
|
||||
}
|
||||
}
|
||||
public int GetShape()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public int GetAmount()
|
||||
{
|
||||
int x = 0;
|
||||
if (KatNum == KatkiNumber.Four)
|
||||
x = 1;
|
||||
if (KatNum == KatkiNumber.Five)
|
||||
x = 2;
|
||||
if (KatNum == KatkiNumber.Six)
|
||||
x = 3;
|
||||
return x;
|
||||
}
|
||||
public void Draw(int _startPosX, int _startPosY, Color katkiColor, Graphics g)
|
||||
{
|
||||
Pen pen = new Pen(Color.Black);
|
@ -36,6 +36,21 @@ namespace ProjectExcavator
|
||||
}
|
||||
}
|
||||
}
|
||||
public int GetShape()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public int GetAmount()
|
||||
{
|
||||
int x = 0;
|
||||
if (KatNum == KatkiNumber.Four)
|
||||
x = 1;
|
||||
if (KatNum == KatkiNumber.Five)
|
||||
x = 2;
|
||||
if (KatNum == KatkiNumber.Six)
|
||||
x = 3;
|
||||
return x;
|
||||
}
|
||||
public void Draw(int _startPosX, int _startPosY, Color katkiColor, Graphics g)
|
||||
{
|
||||
Pen pen = new Pen(Color.Black);
|
||||
|
@ -36,6 +36,21 @@ namespace ProjectExcavator
|
||||
}
|
||||
}
|
||||
}
|
||||
public int GetShape()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
public int GetAmount()
|
||||
{
|
||||
int x = 0;
|
||||
if (KatNum == KatkiNumber.Four)
|
||||
x = 1;
|
||||
if (KatNum == KatkiNumber.Five)
|
||||
x = 2;
|
||||
if (KatNum == KatkiNumber.Six)
|
||||
x = 3;
|
||||
return x;
|
||||
}
|
||||
public void Draw(int _startPosX, int _startPosY, Color katkiColor, Graphics g)
|
||||
{
|
||||
Pen pen = new Pen(Color.Black);
|
||||
|
@ -4,12 +4,14 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectExcavator.Entities;
|
||||
using ProjectExcavator.MovementStrategy;
|
||||
using ProjectExcavator;
|
||||
|
||||
namespace ProjectExcavator.DrawingObjects
|
||||
{
|
||||
public class DrawingExcavator
|
||||
{
|
||||
public IMoveableObject GetMoveableObject => new DrawingObjectExcavator(this);
|
||||
private IDrawingKatki? DrawingKatki;
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
@ -212,33 +214,32 @@ namespace ProjectExcavator.DrawingObjects
|
||||
Brush brYellow = new SolidBrush(Color.Yellow);
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
|
||||
|
||||
//отрисовка экскаватора без ковша
|
||||
g.DrawRectangle(pen, _startPosX + 15, _startPosY + 25, 75, 25);
|
||||
g.DrawRectangle(pen, _startPosX + 60, _startPosY, 30, 25);
|
||||
g.DrawRectangle(pen, _startPosX + 30, _startPosY + 5, 10, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 55, 86, 20);
|
||||
g.DrawPie(pen, _startPosX, _startPosY + 55, 20, 20, 90, 180);
|
||||
g.DrawPie(pen, _startPosX + 85, _startPosY + 55, 20, 20, 270, 180);
|
||||
g.DrawEllipse(pen, _startPosX + 5, _startPosY + 58, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 85, _startPosY + 58, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 25, _startPosY + 65, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 45, _startPosY + 65, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 65, _startPosY + 65, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 37, _startPosY + 58, 6, 6);
|
||||
g.DrawEllipse(pen, _startPosX + 57, _startPosY + 58, 6, 6);
|
||||
//экскаватор
|
||||
g.DrawRectangle(pen, _startPosX + 50, _startPosY + 35, 75, 25);
|
||||
g.DrawRectangle(pen, _startPosX + 95, _startPosY + 10, 30, 25);
|
||||
g.DrawRectangle(pen, _startPosX + 60, _startPosY + 15, 10, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 44, _startPosY + 65, 86, 20);
|
||||
g.DrawPie(pen, _startPosX + 34, _startPosY + 65, 20, 20, 90, 180);
|
||||
g.DrawPie(pen, _startPosX + 120, _startPosY + 65, 20, 20, 270, 180);
|
||||
g.DrawEllipse(pen, _startPosX + 40, _startPosY + 68, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 120, _startPosY + 68, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 60, _startPosY + 76, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 76, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 100, _startPosY + 76, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 72, _startPosY + 68, 6, 6);
|
||||
g.DrawEllipse(pen, _startPosX + 92, _startPosY + 68, 6, 6);
|
||||
//кабина водителя
|
||||
g.FillRectangle(brBlue, _startPosX + 61, _startPosY + 1, 29, 24);
|
||||
g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 11, 29, 24);
|
||||
// кузов
|
||||
g.FillRectangle(brYellow, _startPosX + 16, _startPosY + 26, 74, 24);
|
||||
g.FillRectangle(brYellow, _startPosX + 51, _startPosY + 36, 74, 24);
|
||||
// труба
|
||||
g.FillRectangle(brYellow, _startPosX + 31, _startPosY + 6, 9, 19);
|
||||
g.FillRectangle(brYellow, _startPosX + 61, _startPosY + 16, 9, 19);
|
||||
//гусеница
|
||||
g.FillPie(brGray, _startPosX, _startPosY + 55, 20, 20, 90, 180);
|
||||
g.FillPie(brGray, _startPosX + 85, _startPosY + 55, 20, 20, 270, 180);
|
||||
g.FillRectangle(brGray, _startPosX + 10, _startPosY + 55, 86, 20);
|
||||
g.FillPie(brGray, _startPosX + 34, _startPosY + 65, 20, 20, 90, 180);
|
||||
g.FillPie(brGray, _startPosX + 120, _startPosY + 65, 20, 20, 270, 180);
|
||||
g.FillRectangle(brGray, _startPosX + 44, _startPosY + 65, 86, 20);
|
||||
//катки орнамент(4,5,6)
|
||||
DrawingKatki.Draw(_startPosX, _startPosY, EntityExcavator.BodyColor, g);
|
||||
DrawingKatki.Draw(_startPosX + 35, _startPosY + 10, EntityExcavator.BodyColor, g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ namespace ProjectExcavator.DrawingObjects
|
||||
/// </summary>
|
||||
public class DrawingExcavatorKovsh : DrawingExcavator
|
||||
{
|
||||
private IDrawingKatki? DrawingKatki;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -33,20 +32,6 @@ namespace ProjectExcavator.DrawingObjects
|
||||
EntityExcavator = new EntityExcavatorKovsh(speed, weight, bodyColor,
|
||||
additionalColor, kovsh, katki);
|
||||
}
|
||||
int choose = numchoose % 3;
|
||||
switch (choose)
|
||||
{
|
||||
case 0:
|
||||
DrawingKatki = new DrawKatkiSquare();
|
||||
break;
|
||||
case 1:
|
||||
DrawingKatki = new DrawKatkiTriangle();
|
||||
break;
|
||||
case 2:
|
||||
DrawingKatki = new DrawKatkiCircle();
|
||||
break;
|
||||
}
|
||||
DrawingKatki.Properties = numKatki;
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
@ -59,35 +44,8 @@ namespace ProjectExcavator.DrawingObjects
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(excavatorKovsh.AdditionalColor);
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
Brush brYellow = new SolidBrush(Color.Yellow);
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
|
||||
|
||||
//экскаватор
|
||||
g.DrawRectangle(pen, _startPosX + 50, _startPosY + 35, 75, 25);
|
||||
g.DrawRectangle(pen, _startPosX + 95, _startPosY + 10, 30, 25);
|
||||
g.DrawRectangle(pen, _startPosX + 60, _startPosY + 15, 10, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 44, _startPosY + 65, 86, 20);
|
||||
g.DrawPie(pen, _startPosX + 34, _startPosY + 65, 20, 20, 90, 180);
|
||||
g.DrawPie(pen, _startPosX + 120, _startPosY + 65, 20, 20, 270, 180);
|
||||
g.DrawEllipse(pen, _startPosX + 40, _startPosY + 68, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 120, _startPosY + 68, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX + 60, _startPosY + 76, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 76, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 100, _startPosY + 76, 8, 8);
|
||||
g.DrawEllipse(pen, _startPosX + 72, _startPosY + 68, 6, 6);
|
||||
g.DrawEllipse(pen, _startPosX + 92, _startPosY + 68, 6, 6);
|
||||
//кабина водителя
|
||||
g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 11, 29, 24);
|
||||
// кузов
|
||||
g.FillRectangle(brYellow, _startPosX + 51, _startPosY + 36, 74, 24);
|
||||
// труба
|
||||
g.FillRectangle(brYellow, _startPosX + 61, _startPosY + 16, 9, 19);
|
||||
//гусеница
|
||||
g.FillPie(brGray, _startPosX + 34, _startPosY + 65, 20, 20, 90, 180);
|
||||
g.FillPie(brGray, _startPosX + 120, _startPosY + 65, 20, 20, 270, 180);
|
||||
g.FillRectangle(brGray, _startPosX + 44, _startPosY + 65, 86, 20);
|
||||
base.DrawTransport(g);
|
||||
//ковш
|
||||
g.DrawLine(pen, _startPosX + 50, _startPosY + 35, _startPosX + 10, _startPosY + 10);
|
||||
g.DrawLine(pen, _startPosX + 58, _startPosY + 35, _startPosX + 12, _startPosY + 5);
|
||||
@ -130,7 +88,6 @@ namespace ProjectExcavator.DrawingObjects
|
||||
Point point15 = new Point(_startPosX + 14, _startPosY);
|
||||
Point[] krepl = { point12, point13, point14, point15, point12 };
|
||||
g.FillPolygon(additionalBrush, krepl);
|
||||
DrawingKatki.Draw(_startPosX + 35, _startPosY + 10, EntityExcavator.BodyColor, g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
146
ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs
Normal file
146
ProjectExcavator/ProjectExcavator/ExcavatorGenericCollection.cs
Normal file
@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectExcavator.DrawingObjects;
|
||||
using ProjectExcavator.MovementStrategy;
|
||||
|
||||
namespace ProjectExcavator.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный класс для набора объектов DrawingExcavator
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
internal class ExcavatorGenericCollection<T, U>
|
||||
where T : DrawingExcavator
|
||||
where U : IMoveableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Ширина окна прорисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна прорисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeWidth = 200;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (высота)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeHeight = 90;
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly SetGeneric<T> _collection;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth"></param>
|
||||
/// <param name="picHeight"></param>
|
||||
public ExcavatorGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения
|
||||
/// </summary>
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(ExcavatorGenericCollection<T, U> collect, T?
|
||||
obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return collect?._collection.Insert(obj) ?? -1;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator -(ExcavatorGenericCollection<T, U> collect, int
|
||||
pos)
|
||||
{
|
||||
T? obj = collect._collection.Get(pos);
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта IMoveableObject
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection.Get(pos)?.GetMoveableObject;
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowExcavator()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки фона
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||
1; ++j)
|
||||
{//линия разметки места
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j *
|
||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth, j *
|
||||
_placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
|
||||
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки объектов
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
for (int i = 0; i < _collection.Count; i++)
|
||||
{
|
||||
DrawingExcavator? excavator = _collection.Get(i);
|
||||
if (excavator == null)
|
||||
continue;
|
||||
int r = i / width;
|
||||
int s = width - 1 - (i % width);
|
||||
excavator.SetPosition(s * _placeSizeWidth, r * _placeSizeHeight);
|
||||
excavator.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -28,134 +28,146 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxExcavator = new System.Windows.Forms.PictureBox();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonCreateExKovsh = new System.Windows.Forms.Button();
|
||||
this.buttonCreateEx = new System.Windows.Forms.Button();
|
||||
this.buttonStep = new System.Windows.Forms.Button();
|
||||
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxExcavator)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
pictureBoxExcavator = new PictureBox();
|
||||
buttonLeft = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonCreateExKovsh = new Button();
|
||||
buttonCreateEx = new Button();
|
||||
buttonStep = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonSelectExcavator = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxExcavator
|
||||
//
|
||||
this.pictureBoxExcavator.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxExcavator.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxExcavator.Name = "pictureBoxExcavator";
|
||||
this.pictureBoxExcavator.Size = new System.Drawing.Size(884, 461);
|
||||
this.pictureBoxExcavator.TabIndex = 0;
|
||||
this.pictureBoxExcavator.TabStop = false;
|
||||
pictureBoxExcavator.Dock = DockStyle.Fill;
|
||||
pictureBoxExcavator.Location = new Point(0, 0);
|
||||
pictureBoxExcavator.Name = "pictureBoxExcavator";
|
||||
pictureBoxExcavator.Size = new Size(884, 461);
|
||||
pictureBoxExcavator.TabIndex = 0;
|
||||
pictureBoxExcavator.TabStop = false;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::ProjectExcavator.Properties.Resources.влево;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(762, 404);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonLeft.TabIndex = 2;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.влево;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(762, 404);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(30, 30);
|
||||
buttonLeft.TabIndex = 2;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonRight.BackgroundImage = global::ProjectExcavator.Properties.Resources.право;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonRight.Location = new System.Drawing.Point(842, 404);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonRight.TabIndex = 3;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = Properties.Resources.право;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(842, 404);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(30, 30);
|
||||
buttonRight.TabIndex = 3;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUp.BackgroundImage = global::ProjectExcavator.Properties.Resources.up;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonUp.Location = new System.Drawing.Point(803, 368);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonUp.TabIndex = 4;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = Properties.Resources.up;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(803, 368);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(30, 30);
|
||||
buttonUp.TabIndex = 4;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDown.BackgroundImage = global::ProjectExcavator.Properties.Resources.down;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.buttonDown.Location = new System.Drawing.Point(803, 404);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.buttonDown.TabIndex = 5;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = Properties.Resources.down;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(803, 404);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(30, 30);
|
||||
buttonDown.TabIndex = 5;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonCreateExKovsh
|
||||
//
|
||||
this.buttonCreateExKovsh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateExKovsh.Location = new System.Drawing.Point(12, 426);
|
||||
this.buttonCreateExKovsh.Name = "buttonCreateExKovsh";
|
||||
this.buttonCreateExKovsh.Size = new System.Drawing.Size(180, 23);
|
||||
this.buttonCreateExKovsh.TabIndex = 6;
|
||||
this.buttonCreateExKovsh.Text = "Создать экскаватор с ковшом";
|
||||
this.buttonCreateExKovsh.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateExKovsh.Click += new System.EventHandler(this.buttonCreateExKovsh_Click);
|
||||
buttonCreateExKovsh.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateExKovsh.Location = new Point(12, 426);
|
||||
buttonCreateExKovsh.Name = "buttonCreateExKovsh";
|
||||
buttonCreateExKovsh.Size = new Size(180, 23);
|
||||
buttonCreateExKovsh.TabIndex = 6;
|
||||
buttonCreateExKovsh.Text = "Создать экскаватор с ковшом";
|
||||
buttonCreateExKovsh.UseVisualStyleBackColor = true;
|
||||
buttonCreateExKovsh.Click += buttonCreateExKovsh_Click;
|
||||
//
|
||||
// buttonCreateEx
|
||||
//
|
||||
this.buttonCreateEx.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.buttonCreateEx.Location = new System.Drawing.Point(198, 426);
|
||||
this.buttonCreateEx.Name = "buttonCreateEx";
|
||||
this.buttonCreateEx.Size = new System.Drawing.Size(133, 23);
|
||||
this.buttonCreateEx.TabIndex = 7;
|
||||
this.buttonCreateEx.Text = "Создать";
|
||||
this.buttonCreateEx.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateEx.Click += new System.EventHandler(this.buttonCreateEx_Click);
|
||||
buttonCreateEx.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateEx.Location = new Point(198, 426);
|
||||
buttonCreateEx.Name = "buttonCreateEx";
|
||||
buttonCreateEx.Size = new Size(133, 23);
|
||||
buttonCreateEx.TabIndex = 7;
|
||||
buttonCreateEx.Text = "Создать";
|
||||
buttonCreateEx.UseVisualStyleBackColor = true;
|
||||
buttonCreateEx.Click += buttonCreateEx_Click;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
this.buttonStep.Location = new System.Drawing.Point(797, 41);
|
||||
this.buttonStep.Name = "buttonStep";
|
||||
this.buttonStep.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonStep.TabIndex = 8;
|
||||
this.buttonStep.Text = "Шаг";
|
||||
this.buttonStep.UseVisualStyleBackColor = true;
|
||||
this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click);
|
||||
buttonStep.Location = new Point(797, 41);
|
||||
buttonStep.Name = "buttonStep";
|
||||
buttonStep.Size = new Size(75, 23);
|
||||
buttonStep.TabIndex = 8;
|
||||
buttonStep.Text = "Шаг";
|
||||
buttonStep.UseVisualStyleBackColor = true;
|
||||
buttonStep.Click += buttonStep_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
this.comboBoxStrategy.FormattingEnabled = true;
|
||||
this.comboBoxStrategy.Location = new System.Drawing.Point(751, 12);
|
||||
this.comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
this.comboBoxStrategy.Size = new System.Drawing.Size(121, 23);
|
||||
this.comboBoxStrategy.TabIndex = 9;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "0", "1" });
|
||||
comboBoxStrategy.Location = new Point(751, 12);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(121, 23);
|
||||
comboBoxStrategy.TabIndex = 9;
|
||||
//
|
||||
// buttonSelectExcavator
|
||||
//
|
||||
buttonSelectExcavator.Location = new Point(370, 426);
|
||||
buttonSelectExcavator.Name = "buttonSelectExcavator";
|
||||
buttonSelectExcavator.Size = new Size(105, 23);
|
||||
buttonSelectExcavator.TabIndex = 10;
|
||||
buttonSelectExcavator.Text = "Выбрать обьект";
|
||||
buttonSelectExcavator.UseVisualStyleBackColor = true;
|
||||
buttonSelectExcavator.Click += ButtonSelectExcavator_Click;
|
||||
//
|
||||
// FormExcavator
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(884, 461);
|
||||
this.Controls.Add(this.comboBoxStrategy);
|
||||
this.Controls.Add(this.buttonStep);
|
||||
this.Controls.Add(this.buttonCreateEx);
|
||||
this.Controls.Add(this.buttonCreateExKovsh);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonUp);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
this.Controls.Add(this.buttonLeft);
|
||||
this.Controls.Add(this.pictureBoxExcavator);
|
||||
this.Name = "FormExcavator";
|
||||
this.Text = "FormExcavator";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxExcavator)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(884, 461);
|
||||
Controls.Add(buttonSelectExcavator);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonStep);
|
||||
Controls.Add(buttonCreateEx);
|
||||
Controls.Add(buttonCreateExKovsh);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(pictureBoxExcavator);
|
||||
Name = "FormExcavator";
|
||||
Text = "FormExcavator";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxExcavator).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -169,5 +181,6 @@
|
||||
private Button buttonCreateEx;
|
||||
private Button buttonStep;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonSelectExcavator;
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ namespace ProjectExcavator
|
||||
/// Ñòðàòåãèÿ ïåðåìåùåíèÿ
|
||||
/// </summary>
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
public DrawingExcavator? SelectedExcavator { get; private set; }
|
||||
public FormExcavator()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -116,5 +117,10 @@ namespace ProjectExcavator
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
}
|
||||
private void ButtonSelectExcavator_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedExcavator = _drawingExcavator;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
133
ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs
generated
Normal file
133
ProjectExcavator/ProjectExcavator/FormExcavatorCollection.Designer.cs
generated
Normal file
@ -0,0 +1,133 @@
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
partial class FormExcavatorCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||
this.buttonAddEx = new System.Windows.Forms.Button();
|
||||
this.buttonRemoveEx = new System.Windows.Forms.Button();
|
||||
this.buttonRefreshCollection = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.buttonGeneration = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
this.pictureBoxCollection.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(909, 461);
|
||||
this.pictureBoxCollection.TabIndex = 0;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(26, 125);
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(100, 23);
|
||||
this.maskedTextBoxNumber.TabIndex = 1;
|
||||
//
|
||||
// buttonAddEx
|
||||
//
|
||||
this.buttonAddEx.Location = new System.Drawing.Point(6, 57);
|
||||
this.buttonAddEx.Name = "buttonAddEx";
|
||||
this.buttonAddEx.Size = new System.Drawing.Size(150, 23);
|
||||
this.buttonAddEx.TabIndex = 2;
|
||||
this.buttonAddEx.Text = "Добавить экскаватор";
|
||||
this.buttonAddEx.UseVisualStyleBackColor = true;
|
||||
this.buttonAddEx.Click += new System.EventHandler(this.ButtonAddEx_Click);
|
||||
//
|
||||
// buttonRemoveEx
|
||||
//
|
||||
this.buttonRemoveEx.Location = new System.Drawing.Point(6, 166);
|
||||
this.buttonRemoveEx.Name = "buttonRemoveEx";
|
||||
this.buttonRemoveEx.Size = new System.Drawing.Size(150, 23);
|
||||
this.buttonRemoveEx.TabIndex = 3;
|
||||
this.buttonRemoveEx.Text = "Удалить экскаватор";
|
||||
this.buttonRemoveEx.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonRefreshCollection
|
||||
//
|
||||
this.buttonRefreshCollection.Location = new System.Drawing.Point(6, 230);
|
||||
this.buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||
this.buttonRefreshCollection.Size = new System.Drawing.Size(148, 23);
|
||||
this.buttonRefreshCollection.TabIndex = 4;
|
||||
this.buttonRefreshCollection.Text = "Обновить коллекцию";
|
||||
this.buttonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.buttonGeneration);
|
||||
this.groupBox1.Controls.Add(this.buttonAddEx);
|
||||
this.groupBox1.Controls.Add(this.buttonRefreshCollection);
|
||||
this.groupBox1.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.groupBox1.Controls.Add(this.buttonRemoveEx);
|
||||
this.groupBox1.Location = new System.Drawing.Point(749, 0);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(160, 461);
|
||||
this.groupBox1.TabIndex = 5;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Инструменты";
|
||||
//
|
||||
// buttonGeneration
|
||||
//
|
||||
this.buttonGeneration.Location = new System.Drawing.Point(6, 332);
|
||||
this.buttonGeneration.Name = "buttonGeneration";
|
||||
this.buttonGeneration.Size = new System.Drawing.Size(150, 23);
|
||||
this.buttonGeneration.TabIndex = 5;
|
||||
this.buttonGeneration.Text = "Форма генерации";
|
||||
this.buttonGeneration.UseVisualStyleBackColor = true;
|
||||
this.buttonGeneration.Click += new System.EventHandler(this.buttonGeneration_Click);
|
||||
//
|
||||
// FormExcavatorCollection
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(909, 461);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Name = "FormExcavatorCollection";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCollection;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
private Button buttonAddEx;
|
||||
private Button buttonRemoveEx;
|
||||
private Button buttonRefreshCollection;
|
||||
private GroupBox groupBox1;
|
||||
private Button buttonGeneration;
|
||||
}
|
||||
}
|
87
ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs
Normal file
87
ProjectExcavator/ProjectExcavator/FormExcavatorCollection.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using ProjectExcavator.DrawingObjects;
|
||||
using ProjectExcavator.Generics;
|
||||
using ProjectExcavator.MovementStrategy;
|
||||
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма для работы с набором объектов класса DrawningExcavator
|
||||
/// </summary>
|
||||
public partial class FormExcavatorCollection : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly ExcavatorGenericCollection<DrawingExcavator,
|
||||
DrawingObjectExcavator> _excavator;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormExcavatorCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_excavator = new ExcavatorGenericCollection<DrawingExcavator,
|
||||
DrawingObjectExcavator>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddEx_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormExcavator form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
int result = _excavator + form.SelectedExcavator;
|
||||
if (result != -2)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = _excavator.ShowExcavator();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveEx_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
if (_excavator - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = _excavator.ShowExcavator();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Обновление рисунка по набору
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _excavator.ShowExcavator();
|
||||
}
|
||||
|
||||
private void buttonGeneration_Click(object sender, EventArgs e)
|
||||
{
|
||||
RandGeneration form = new();
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectExcavator/ProjectExcavator/FormExcavatorCollection.resx
Normal file
120
ProjectExcavator/ProjectExcavator/FormExcavatorCollection.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>
|
@ -10,5 +10,7 @@ namespace ProjectExcavator
|
||||
{
|
||||
int Properties { get; set; }
|
||||
void Draw(int _startPosX, int _startPosY, Color katkiColor, Graphics g);
|
||||
public int GetAmount();
|
||||
public int GetShape();
|
||||
}
|
||||
}
|
||||
|
79
ProjectExcavator/ProjectExcavator/ParamGenericObject.cs
Normal file
79
ProjectExcavator/ProjectExcavator/ParamGenericObject.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using ProjectExcavator;
|
||||
using ProjectExcavator.DrawingObjects;
|
||||
using ProjectExcavator.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
public class ParamGenericObject<T, U>
|
||||
where T : EntityExcavator
|
||||
where U : IDrawingKatki
|
||||
{
|
||||
private T[] _excavators;
|
||||
private U[] _katki;
|
||||
|
||||
private int CountExcavators = 0;
|
||||
private int CountKatki = 0;
|
||||
private readonly Random random;
|
||||
private readonly int Width;
|
||||
private readonly int Height;
|
||||
|
||||
public ParamGenericObject(int count, int width, int height)
|
||||
{
|
||||
_excavators = new T[count];
|
||||
_katki = new U[count];
|
||||
random = new Random();
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool Add(T excavator)
|
||||
{
|
||||
for (int i = 0; i < _excavators.Length; i++)
|
||||
{
|
||||
if (_excavators[i] == null)
|
||||
{
|
||||
_excavators[i] = excavator;
|
||||
CountExcavators++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Add(U katki)
|
||||
{
|
||||
for (int i = 0; i < _excavators.Length; i++)
|
||||
{
|
||||
if (_katki[i] == null)
|
||||
{
|
||||
_katki[i] = katki;
|
||||
CountKatki++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public DrawingExcavator CreateDrawObject()
|
||||
{
|
||||
Random rand = new Random();
|
||||
EntityExcavator excavator = _excavators[rand.Next(0, CountExcavators)];
|
||||
IDrawingKatki katki = _katki[rand.Next(0, CountKatki)];
|
||||
if (excavator is EntityExcavatorKovsh kovshExcavator)
|
||||
{
|
||||
return new DrawingExcavatorKovsh(excavator.Speed, excavator.Weight, excavator.BodyColor, kovshExcavator.AdditionalColor, kovshExcavator.Kovsh, kovshExcavator.Katki,
|
||||
Width, Height, katki.GetAmount(), katki.GetShape());
|
||||
}
|
||||
|
||||
return new DrawingExcavator(excavator.Speed, excavator.Weight, excavator.BodyColor, Width, Height, katki.GetAmount(), katki.GetShape());
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace ProjectExcavator
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormExcavator());
|
||||
Application.Run(new FormExcavatorCollection());
|
||||
}
|
||||
}
|
||||
}
|
74
ProjectExcavator/ProjectExcavator/RandGeneration.Designer.cs
generated
Normal file
74
ProjectExcavator/ProjectExcavator/RandGeneration.Designer.cs
generated
Normal file
@ -0,0 +1,74 @@
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
partial class RandGeneration
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonGen = new System.Windows.Forms.Button();
|
||||
this.pictureBoxGen = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxGen)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonGen
|
||||
//
|
||||
this.buttonGen.Location = new System.Drawing.Point(12, 415);
|
||||
this.buttonGen.Name = "buttonGen";
|
||||
this.buttonGen.Size = new System.Drawing.Size(166, 23);
|
||||
this.buttonGen.TabIndex = 0;
|
||||
this.buttonGen.Text = "Сгенерировать";
|
||||
this.buttonGen.UseVisualStyleBackColor = true;
|
||||
this.buttonGen.Click += new System.EventHandler(this.buttonGen_Click);
|
||||
//
|
||||
// pictureBoxGen
|
||||
//
|
||||
this.pictureBoxGen.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxGen.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxGen.Name = "pictureBoxGen";
|
||||
this.pictureBoxGen.Size = new System.Drawing.Size(800, 450);
|
||||
this.pictureBoxGen.TabIndex = 1;
|
||||
this.pictureBoxGen.TabStop = false;
|
||||
//
|
||||
// RandGeneration
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonGen);
|
||||
this.Controls.Add(this.pictureBoxGen);
|
||||
this.Name = "RandGeneration";
|
||||
this.Text = "RandGeneration";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxGen)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonGen;
|
||||
private PictureBox pictureBoxGen;
|
||||
}
|
||||
}
|
88
ProjectExcavator/ProjectExcavator/RandGeneration.cs
Normal file
88
ProjectExcavator/ProjectExcavator/RandGeneration.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using ProjectExcavator.DrawingObjects;
|
||||
using ProjectExcavator.Entities;
|
||||
using ProjectExcavator;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectExcavator
|
||||
{
|
||||
public partial class RandGeneration : Form
|
||||
{
|
||||
private DrawingExcavator _drawingExcavator;
|
||||
private ParamGenericObject<EntityExcavator, IDrawingKatki> objGeneric;
|
||||
private readonly int _pictureWidth = 250;
|
||||
private readonly int _pictureHeight = 185;
|
||||
Random random = new Random();
|
||||
public RandGeneration()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawingExcavator == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxGen.Width, pictureBoxGen.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawingExcavator.DrawTransport(gr);
|
||||
pictureBoxGen.Image = bmp;
|
||||
}
|
||||
private void buttonGen_Click(object sender, EventArgs e)
|
||||
{
|
||||
int size = random.Next(1, 10);
|
||||
objGeneric = new ParamGenericObject<EntityExcavator, IDrawingKatki>(size, _pictureWidth, _pictureHeight);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
EntityExcavator excavator = CreateRandomExcavator();
|
||||
IDrawingKatki katki = CreateRandomKatki();
|
||||
objGeneric.Add(excavator);
|
||||
objGeneric.Add(katki);
|
||||
_drawingExcavator = objGeneric.CreateDrawObject();
|
||||
_drawingExcavator.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
public EntityExcavator CreateRandomExcavator()
|
||||
{
|
||||
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||
EntityExcavator excavator;
|
||||
switch (random.Next(0, 2))
|
||||
{
|
||||
case 1:
|
||||
excavator = new EntityExcavatorKovsh(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(2)), Convert.ToBoolean(random.Next(2)));
|
||||
break;
|
||||
default:
|
||||
excavator = new EntityExcavator(random.Next(100, 300), random.Next(1000, 3000), color);
|
||||
break;
|
||||
}
|
||||
return excavator;
|
||||
}
|
||||
public IDrawingKatki CreateRandomKatki()
|
||||
{
|
||||
IDrawingKatki _katki;
|
||||
switch (random.Next(3))
|
||||
{
|
||||
case 1:
|
||||
_katki = new DrawKatkiTriangle();
|
||||
break;
|
||||
case 2:
|
||||
_katki = new DrawKatkiSquare();
|
||||
break;
|
||||
default:
|
||||
_katki = new DrawKatkiCircle();
|
||||
break;
|
||||
}
|
||||
_katki.Properties = (random.Next(1, 4));
|
||||
return _katki;
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectExcavator/ProjectExcavator/RandGeneration.resx
Normal file
120
ProjectExcavator/ProjectExcavator/RandGeneration.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>
|
114
ProjectExcavator/ProjectExcavator/SetGeneric.cs
Normal file
114
ProjectExcavator/ProjectExcavator/SetGeneric.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectExcavator.Generics
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly T?[] _places;
|
||||
/// <summary>
|
||||
/// Количество объектов в массиве
|
||||
/// </summary>
|
||||
public int Count => _places.Length;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_places = new T?[count];
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="excavator">Добавляемый экскаватор</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T excavator)
|
||||
{
|
||||
for (int i = _places.Length - 1; i > 0; i--)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
_places[0] = excavator;
|
||||
return Insert(excavator, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="excavator">Добавляемый экскаватор</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T excavator, int position)
|
||||
{
|
||||
if (position < 0 || position >= _places.Length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_places[position] != null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int NullIndex = 0;
|
||||
for (int i = position; i < _places.Length; i++)
|
||||
{
|
||||
if (_places[i] == null)
|
||||
{
|
||||
NullIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NullIndex == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = NullIndex; i >= position; i--)
|
||||
{
|
||||
_places[i + 1] = _places[i];
|
||||
}
|
||||
_places[position] = excavator;
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= _places.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_places[position] = null;
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T? Get(int position)
|
||||
{
|
||||
if (position < 0 || position >= _places.Length)
|
||||
return null;
|
||||
|
||||
return _places[position];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user