Лабораторная работа №3

This commit is contained in:
Esenia12 2024-03-03 22:31:29 +04:00
parent 377098a07a
commit 65c79eb884
12 changed files with 661 additions and 144 deletions

View File

@ -6,12 +6,12 @@ public abstract class AbstractCompany
/// <summary>
/// Размер места (ширина)
/// </summary>
protected readonly int _placeSizeWidth = 210;
protected readonly int _placeSizeWidth = 220;
/// <summary>
/// Размер места (высота)
/// </summary>
protected readonly int _placeSizeHeight = 80;
protected readonly int _placeSizeHeight = 155;
/// <summary>
/// Ширина окна

View File

@ -1,6 +1,66 @@

using ProjectDumpTrack.Drawnings;
namespace ProjectDumpTruck.CollectionGenericObjects;
internal class CarSharingService
/// <summary>
/// Реализация абстрактной компании - каршеринг
/// </summary>
public class CarSharingService : AbstractCompany
{
}
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
public CarSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTrack> collection) : base(picWidth, picHeight, collection)
{
}
protected override void DrawBackgound(Graphics g)
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
Pen pen = new(Color.Black, 2);
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height + 1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth+15, j * _placeSizeHeight, i * _placeSizeWidth+15 + _placeSizeWidth-55, j * _placeSizeHeight);
g.DrawLine(pen, i * _placeSizeWidth+15, j * _placeSizeHeight, i * _placeSizeWidth+15, j * _placeSizeHeight -_placeSizeHeight);
}
}
}
protected override void SetObjectsPosition()
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
int curWidth = 0;
int curHeight = 0;
for (int i = 0; i < (_collection?.Count ?? 0); i++)
{
if (_collection.Get(i) != null)
{
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 20, curHeight * _placeSizeHeight + 4);
}
if (curWidth < width-1)
curWidth++;
else
{
curWidth = 0;
curHeight++;
}
if (curHeight > height)
{
return;
}
}
}
}

View File

@ -1,85 +1,109 @@

namespace ProjectDumpTruck.CollectionGenericObjects;
internal class SetDumpTrackGeneric<T>
where T : class
internal class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
where T : class
{
private readonly T[] _collection;
/// <summary>
/// Массив объектов, которые храним
/// </summary>
private T?[] _collection;
public int Count => _collection.Length;
public SetDumpTrackGeneric(int count)
public int SetMaxCount
{
_collection = new T[count];
set
{
if (value > 0)
{
if (_collection.Length > 0)
{
Array.Resize(ref _collection, value);
}
else
{
_collection = new T?[value];
}
}
}
}
public int Insert(T DumpTrack)
/// <summary>
/// Конструктор
/// </summary>
public MassiveGenericObjects()
{
// TODO вставка в начало набора
if (_collection[Count - 1] == null)
{
for (int i = Count - 1; i > 0; i--)
{
_collection[i] = _collection[i - 1];
}
_collection[0] = DumpTrack;
return 0;
}
return -1;
_collection = Array.Empty<T?>();
}
public int Insert(T DumpTrack, int position)
public T? Get(int position)
{
// TODO проверка позиции
if (position >= _collection.Length || position < 0) return null;
return _collection[position];
}
public bool Insert(T obj)
{
// TODO вставка в свободное место набора
int index = 0;
while (index < _collection.Length)
{
if (_collection[index] == null)
{
_collection[index] = obj;
return true;
}
index++;
}
return false;
}
public bool Insert(T obj, int position)
{
// TODO проверка позиции
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
// проверка, что после вставляемого элемента в массиве есть пустой элемент
// сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
// TODO вставка по позиции
if (position < 0 || position >= Count) return -1;
// ищется свободное место после этой позиции и идет вставка туда
// если нет после, ищем до
// TODO вставка
if (position >= _collection.Length || position < 0) return false;
if (_collection[position] == null)
{
_collection[position] = DumpTrack;
return position;
_collection[position] = obj;
return true;
}
else
int index = position + 1;
while (index < _collection.Length)
{
if (_collection[Count - 1] == null)
if (_collection[index] == null)
{
for (int i = Count - 1; i > position; i--)
{
_collection[i] = _collection[i - 1];
}
_collection[position] = DumpTrack;
return position;
_collection[index] = obj;
return true;
}
return -1;
index++;
}
index = position - 1;
while (index >= 0)
{
if (_collection[index] == null)
{
_collection[index] = obj;
return true;
}
index--;
}
return false;
}
public T Remove(int position)
public bool Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из массива, присовив элементу массива значение null
if (position < 0 || position >= Count)
return null;
if (_collection[position] != null)
{
T removed = _collection[position];
_collection[position] = null;
if (position < Count - 1)
{
for (int k = position; k < Count - 1; k++)
{
_collection[k] = _collection[k + 1];
}
}
return removed;
}
return null;
}
public T Get(int position)
{
// TODO проверка позиции
if (position >= Count || position < 0)
return null;
return _collection[position];
// TODO удаление объекта из массива, присвоив элементу массива значение null
if (position >= _collection.Length || position < 0) return false;
_collection[position] = null;
return true;
}
}

View File

@ -64,9 +64,9 @@ public class DrawningDumpTrack : DrawningTrack
/// <param name="awning">Признак наличия тента</param>
public DrawningDumpTrack(int speed, double weight, Color bodyColor, Color additionalColor, bool bodywork, bool awning) : base(130, 100)
public DrawningDumpTrack(int speed, double weight, Color bodyColor, Color additionalColor, Color additional2Color, bool bodywork, bool awning) : base(130, 100)
{
EntityTrack = new EntityDumpTrack(speed, weight, bodyColor, additionalColor, bodywork, awning);
EntityTrack = new EntityDumpTrack(speed, weight, bodyColor, additionalColor, additional2Color, bodywork, awning);
}
@ -77,15 +77,15 @@ public class DrawningDumpTrack : DrawningTrack
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(dumpTrack.AdditionalColor);
Brush additional2Brush = new SolidBrush(dumpTrack.Additional2Color);
base.DrawTransport(g);
//Отрисовка кузова
if (dumpTrack.Bodywork)
{
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 90, 35);
g.FillRectangle(additional2Brush, _startPosX.Value, _startPosY.Value, 90, 35);
}
//Отрисовка тента

View File

@ -219,7 +219,7 @@ public class DrawningTrack
}
Pen pen = new(Color.Black);
//Отрисовка основы (кабины водителя и днища)
Brush body = new SolidBrush(EntityTrack.BodyColor);

View File

@ -10,6 +10,11 @@ public class EntityDumpTrack : EntityTrack
/// </summary>
public Color AdditionalColor { get; private set; }
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color Additional2Color { get; private set; }
/// <summary>
/// Признак (опция) наличия кузова
/// </summary>
@ -29,12 +34,14 @@ public class EntityDumpTrack : EntityTrack
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// /// <param name="additional2Color">Дополнительный цвет</param>
/// <param name="bodywork">Признак наличия кузова</param>
/// <param name="awning">Признак наличия тента</param>
public EntityDumpTrack(int speed, double weight, Color bodyColor, Color additionalColor, bool bodywork, bool awning) : base(5, 45, Color.Black)
public EntityDumpTrack(int speed, double weight, Color bodyColor, Color additionalColor, Color additional2Color, bool bodywork, bool awning) : base(5, 45, Color.Black)
{
AdditionalColor = additionalColor;
Additional2Color = additional2Color;
Bodywork = bodywork;
Awning = awning;
}

View File

@ -0,0 +1,174 @@
namespace ProjectDumpTruck
{
partial class FormTrackCollection
{
/// <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()
{
groupBoxTools = new GroupBox();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonDelTrack = new Button();
maskedTextBox = new MaskedTextBox();
buttonAddDumpTrack = new Button();
buttonAddTrack = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonGoToCheck);
groupBoxTools.Controls.Add(buttonDelTrack);
groupBoxTools.Controls.Add(maskedTextBox);
groupBoxTools.Controls.Add(buttonAddDumpTrack);
groupBoxTools.Controls.Add(buttonAddTrack);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(745, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(216, 493);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(6, 423);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(192, 39);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += buttonRefresh_Click;
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(6, 306);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(192, 39);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += buttonGoToCheck_Click;
//
// buttonDelTrack
//
buttonDelTrack.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonDelTrack.Location = new Point(6, 198);
buttonDelTrack.Name = "buttonDelTrack";
buttonDelTrack.Size = new Size(192, 39);
buttonDelTrack.TabIndex = 4;
buttonDelTrack.Text = "Удалить грузовик";
buttonDelTrack.UseVisualStyleBackColor = true;
buttonDelTrack.Click += buttonDelTrack_Click;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(6, 169);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(192, 23);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonAddDumpTrack
//
buttonAddDumpTrack.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddDumpTrack.Location = new Point(6, 106);
buttonAddDumpTrack.Name = "buttonAddDumpTrack";
buttonAddDumpTrack.Size = new Size(192, 39);
buttonAddDumpTrack.TabIndex = 2;
buttonAddDumpTrack.Text = "Добавление самосвала";
buttonAddDumpTrack.UseVisualStyleBackColor = true;
buttonAddDumpTrack.Click += buttonAddDumpTrack_Click;
//
// buttonAddTrack
//
buttonAddTrack.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddTrack.Location = new Point(6, 61);
buttonAddTrack.Name = "buttonAddTrack";
buttonAddTrack.Size = new Size(192, 39);
buttonAddTrack.TabIndex = 1;
buttonAddTrack.Text = "Добавление грузовика";
buttonAddTrack.UseVisualStyleBackColor = true;
buttonAddTrack.Click += buttonAddTrack_Click;
//
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(6, 22);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(192, 23);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(745, 493);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// FormTrackCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(961, 493);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormTrackCollection";
Text = "Коллекция самосвалов";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddDumpTrack;
private Button buttonAddTrack;
private PictureBox pictureBox;
private Button buttonRefresh;
private Button buttonGoToCheck;
private Button buttonDelTrack;
private MaskedTextBox maskedTextBox;
}
}

View File

@ -0,0 +1,191 @@

using ProjectDumpTruck.CollectionGenericObjects;
using ProjectDumpTrack.Drawnings;
namespace ProjectDumpTruck;
/// <summary>
/// Форма работы с компанией и ее коллекцией
/// </summary>
public partial class FormTrackCollection : Form
{
/// <summary>
/// Компания
/// </summary>
private AbstractCompany? _company = null;
/// <summary>
/// Конструктор
/// </summary>
public FormTrackCollection()
{
InitializeComponent();
}
/// <summary>
/// Выбор компании
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new CarSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects< DrawningTrack > ());
break;
}
}
/// <summary>
/// Добавление обычного автомобиля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddTrack_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrack));
/// <summary>
/// Добавление спортивного автомобиля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddDumpTrack_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningDumpTrack));
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{
if (_company == null)
{
return;
}
Random random = new();
DrawningTrack drawningTrack;
switch (type)
{
case nameof(DrawningTrack):
drawningTrack = new DrawningTrack(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningDumpTrack):
drawningTrack = new DrawningDumpTrack(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random), GetColor(random),
Convert.ToBoolean(random.Next(2, 2)), Convert.ToBoolean(random.Next(1, 2)));
break;
default:
return;
}
if (_company + drawningTrack)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
/// <summary>
/// Получение цвета
/// </summary>
/// <param name="random">Генератор случайных чисел</param>
/// <returns></returns>
private static Color GetColor(Random random)
{
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
return color;
}
/// <summary>
/// Удаление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonDelTrack_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
int pos = Convert.ToInt32(maskedTextBox.Text);
if (_company - pos)
{
MessageBox.Show("Объект удален");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
/// <summary>
/// Передача объекта в другую форму
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonGoToCheck_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
DrawningTrack? track = null;
int counter = 100;
while (track == null)
{
track = _company.GetRandomObject();
counter--;
if (counter <= 0)
{
break;
}
}
if (track == null)
{
return;
}
FormTransport form = new()
{
SetTrack = track
};
form.ShowDialog();
}
/// <summary>
/// Перерисовка коллекции
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonRefresh_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
pictureBox.Image = _company.Show();
}
}

View 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>

View File

@ -29,12 +29,10 @@
private void InitializeComponent()
{
pictureBoxDumpTrack = new PictureBox();
buttonCreateDumpTrack = new Button();
buttonLeft = new Button();
buttonRight = new Button();
buttonUp = new Button();
buttonDown = new Button();
buttonCreateTrack = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxDumpTrack).BeginInit();
@ -49,17 +47,6 @@
pictureBoxDumpTrack.TabIndex = 0;
pictureBoxDumpTrack.TabStop = false;
//
// buttonCreateDumpTrack
//
buttonCreateDumpTrack.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateDumpTrack.Location = new Point(12, 409);
buttonCreateDumpTrack.Name = "buttonCreateDumpTrack";
buttonCreateDumpTrack.Size = new Size(210, 29);
buttonCreateDumpTrack.TabIndex = 1;
buttonCreateDumpTrack.Text = "Создать грузовик с кузовом";
buttonCreateDumpTrack.UseVisualStyleBackColor = true;
buttonCreateDumpTrack.Click += buttonCreateDumpTrack_Click;
//
// buttonLeft
//
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@ -108,17 +95,6 @@
buttonDown.UseVisualStyleBackColor = true;
buttonDown.Click += buttonMove_Click;
//
// buttonCreateTrack
//
buttonCreateTrack.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateTrack.Location = new Point(238, 409);
buttonCreateTrack.Name = "buttonCreateTrack";
buttonCreateTrack.Size = new Size(210, 29);
buttonCreateTrack.TabIndex = 6;
buttonCreateTrack.Text = "Создать грузовик";
buttonCreateTrack.UseVisualStyleBackColor = true;
buttonCreateTrack.Click += buttonCreateTrack_Click;
//
// comboBoxStrategy
//
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@ -146,12 +122,10 @@
ClientSize = new Size(800, 450);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonCreateTrack);
Controls.Add(buttonDown);
Controls.Add(buttonUp);
Controls.Add(buttonRight);
Controls.Add(buttonLeft);
Controls.Add(buttonCreateDumpTrack);
Controls.Add(pictureBoxDumpTrack);
Name = "FormTransport";
Text = "FormTransport";
@ -162,12 +136,10 @@
#endregion
private PictureBox pictureBoxDumpTrack;
private Button buttonCreateDumpTrack;
internal Button buttonLeft;
internal Button buttonRight;
internal Button buttonUp;
internal Button buttonDown;
private Button buttonCreateTrack;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}

View File

@ -21,6 +21,19 @@ namespace ProjectDumpTruck
/// <summary>
/// Конструктор формы
/// </summary>
///
public DrawningTrack SetTrack
{
set
{
_drawningTrack = value;
_drawningTrack.SetPictureSize(pictureBoxDumpTrack.Width, pictureBoxDumpTrack.Height);
comboBoxStrategy.Enabled = true;
_strategy = null;
Draw();
}
}
public FormTransport()
{
InitializeComponent();
@ -45,51 +58,6 @@ namespace ProjectDumpTruck
}
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{
Random random = new();
switch (type)
{
case nameof(DrawningTrack):
_drawningTrack = new DrawningTrack(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
break;
case nameof(DrawningDumpTrack):
_drawningTrack = new DrawningDumpTrack(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(1, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
_drawningTrack.SetPictureSize(pictureBoxDumpTrack.Width, pictureBoxDumpTrack.Height);
_drawningTrack.SetPosition(random.Next(10, 100), random.Next(10, 100));
_strategy = null;
comboBoxStrategy.Enabled = true;
Draw();
}
/// <summary>
/// Обработка нажатия кнопки "Создать грузовик с кузовом"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonCreateDumpTrack_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningDumpTrack));
/// <summary>
/// Обработка нажатия кнопки "Создать грузовик"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonCreateTrack_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrack));
/// <summary>
/// Перемещение объекта по форме (нажатие кнопок навигации)

View File

@ -13,7 +13,8 @@ namespace ProjectDumpTruck
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormTransport());
Application.Run(new FormTrackCollection());
////Àáñòðàêòíûé ìåòîä 3 çàäàíèå