Pi-12_Kukushkina_E.O._LabWork05_Simple #5

Closed
Katushka wants to merge 1 commits from Lab05 into Lab04
9 changed files with 784 additions and 153 deletions

View File

@ -8,11 +8,11 @@ namespace ProjectExcavator.CollectionGenericObjects;
internal class GarageService : AbstractCompany
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
public GarageService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTrackedVehicle> collection) : base(picWidth, picHeight, collection)
{
}
@ -39,21 +39,23 @@ internal class GarageService : AbstractCompany
protected override void SetObjectsPosition()
{
int col = _collection?.Count ?? 0;
int LevelWidth = 0;
int LevelHeight = 0;
for (int i = 0; i < col; i++)
for (int i = 0; i < _collection?.Count; i++)
{
if (LevelHeight + 1 > _pictureHeight/ (_placeSizeHeight + 60))
if (_collection.Get(i) != null)
{
_collection?.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(i)?.SetPosition((_pictureWidth - 190) - _placeSizeWidth * LevelWidth, 20 + (_placeSizeHeight + 60) * LevelHeight);
}
if (LevelHeight + 1 > _pictureHeight / (_placeSizeHeight + 60))
{
return;
}
_collection?.Get(i)?.SetPosition((_pictureWidth - 190) - _placeSizeWidth * LevelWidth, 20 + (_placeSizeHeight + 60) * LevelHeight );
if (LevelWidth + 1 < _pictureWidth / _placeSizeWidth)
{
LevelWidth++;

View File

@ -10,7 +10,7 @@ public class DrawningTrackedVehicle
/// <summary>
/// Класс-сущность
/// </summary>
public TrackedVehicle? EntityTrackedVehicle { get; protected set; }
public EntityTrackedVehicle? EntityTrackedVehicle { get; protected set; }
/// <summary>
/// Ширина окна
@ -81,7 +81,7 @@ public class DrawningTrackedVehicle
/// <param name="bodyColor">Основной цвет</param>
public DrawningTrackedVehicle(int speed, double weight, Color bodyColor) : this()
{
EntityTrackedVehicle = new TrackedVehicle(speed, weight, bodyColor);
EntityTrackedVehicle = new EntityTrackedVehicle(speed, weight, bodyColor);
}
/// <summary>

View File

@ -3,13 +3,18 @@
/// <summary>
/// Класс-сущность "Экскаватор"
/// </summary>
public class EntityExcavator : TrackedVehicle
public class EntityExcavator : EntityTrackedVehicle
{
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; private set; }
public void SetAdditionalColor(Color additionalColor)
{
AdditionalColor = additionalColor;
}
/// <summary>
/// Признак (опция) наличия ковша
/// </summary>

View File

@ -3,7 +3,7 @@
/// <summary>
/// Класс-сущность "Гусеничная Машина"
/// </summary>
public class TrackedVehicle
public class EntityTrackedVehicle
{
/// <summary>
/// Скорость
@ -20,6 +20,11 @@ public class TrackedVehicle
/// </summary>
public Color BodyColor { get; private set; }
public void SetBodyColor(Color bodyColor)
{
BodyColor = bodyColor;
}
/// <summary>
/// Шаг перемещения Экскаватора/Гусеничной машины
/// </summary>
@ -32,7 +37,7 @@ public class TrackedVehicle
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
public TrackedVehicle(int speed, double weight, Color bodyColor)
public EntityTrackedVehicle(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;

View File

@ -29,6 +29,12 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonAddTrackedVehicle = new Button();
buttonRefresh = new Button();
maskedTextBoxPosition = new MaskedTextBox();
buttonGoToCheck = new Button();
ButtonRemoveExcavator = new Button();
buttonCreateCompany = new Button();
panelStorage = new Panel();
buttonCollectionDel = new Button();
@ -38,19 +44,12 @@
radioButtonMassive = new RadioButton();
textBoxCollectionName = new TextBox();
labelCollectionName = new Label();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
ButtonRemoveExcavator = new Button();
maskedTextBoxPosition = new MaskedTextBox();
buttonAddExcavator = new Button();
buttonAddTrackedVehicle = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
panelCompanyTools = new Panel();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
panelCompanyTools.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
@ -67,6 +66,73 @@
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddTrackedVehicle);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(ButtonRemoveExcavator);
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(2, 350);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(220, 289);
panelCompanyTools.TabIndex = 2;
//
// buttonAddTrackedVehicle
//
buttonAddTrackedVehicle.Anchor = AnchorStyles.Top;
buttonAddTrackedVehicle.Location = new Point(3, 3);
buttonAddTrackedVehicle.Name = "buttonAddTrackedVehicle";
buttonAddTrackedVehicle.Size = new Size(215, 50);
buttonAddTrackedVehicle.TabIndex = 1;
buttonAddTrackedVehicle.Text = "Добавление гусеничной машины";
buttonAddTrackedVehicle.UseVisualStyleBackColor = true;
buttonAddTrackedVehicle.Click += ButtonAddTrackedVehicle_Click;
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top;
buttonRefresh.Location = new Point(3, 240);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(215, 40);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Anchor = AnchorStyles.Top;
maskedTextBoxPosition.Location = new Point(3, 115);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(215, 27);
maskedTextBoxPosition.TabIndex = 3;
maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top;
buttonGoToCheck.Location = new Point(3, 194);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(215, 40);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// ButtonRemoveExcavator
//
ButtonRemoveExcavator.Anchor = AnchorStyles.Top;
ButtonRemoveExcavator.Location = new Point(3, 148);
ButtonRemoveExcavator.Name = "ButtonRemoveExcavator";
ButtonRemoveExcavator.Size = new Size(215, 40);
ButtonRemoveExcavator.TabIndex = 4;
ButtonRemoveExcavator.Text = "Удаление транспорта";
ButtonRemoveExcavator.UseVisualStyleBackColor = true;
ButtonRemoveExcavator.Click += ButtonRemoveExcavator_Click;
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(13, 317);
@ -170,71 +236,6 @@
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:";
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top;
buttonRefresh.Location = new Point(3, 240);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(215, 40);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top;
buttonGoToCheck.Location = new Point(3, 194);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(215, 40);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// ButtonRemoveExcavator
//
ButtonRemoveExcavator.Anchor = AnchorStyles.Top;
ButtonRemoveExcavator.Location = new Point(3, 148);
ButtonRemoveExcavator.Name = "ButtonRemoveExcavator";
ButtonRemoveExcavator.Size = new Size(215, 40);
ButtonRemoveExcavator.TabIndex = 4;
ButtonRemoveExcavator.Text = "Удаление транспорта";
ButtonRemoveExcavator.UseVisualStyleBackColor = true;
ButtonRemoveExcavator.Click += ButtonRemoveExcavator_Click;
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Anchor = AnchorStyles.Top;
maskedTextBoxPosition.Location = new Point(3, 115);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(215, 27);
maskedTextBoxPosition.TabIndex = 3;
maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonAddExcavator
//
buttonAddExcavator.Anchor = AnchorStyles.Top;
buttonAddExcavator.Location = new Point(2, 59);
buttonAddExcavator.Name = "buttonAddExcavator";
buttonAddExcavator.Size = new Size(215, 50);
buttonAddExcavator.TabIndex = 2;
buttonAddExcavator.Text = "Добавление экскаватора";
buttonAddExcavator.UseVisualStyleBackColor = true;
buttonAddExcavator.Click += ButtonAddExcavator_Click;
//
// buttonAddTrackedVehicle
//
buttonAddTrackedVehicle.Anchor = AnchorStyles.Top;
buttonAddTrackedVehicle.Location = new Point(3, 3);
buttonAddTrackedVehicle.Name = "buttonAddTrackedVehicle";
buttonAddTrackedVehicle.Size = new Size(215, 50);
buttonAddTrackedVehicle.TabIndex = 1;
buttonAddTrackedVehicle.Text = "Добавление гусеничной машины";
buttonAddTrackedVehicle.UseVisualStyleBackColor = true;
buttonAddTrackedVehicle.Click += ButtonAddTrackedVehicle_Click;
//
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@ -256,20 +257,6 @@
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddTrackedVehicle);
panelCompanyTools.Controls.Add(buttonAddExcavator);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(ButtonRemoveExcavator);
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(2, 350);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(220, 289);
panelCompanyTools.TabIndex = 2;
//
// FormExcavatorCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
@ -280,11 +267,11 @@
Name = "FormExcavatorCollection";
Text = "Коллекция экскаваторов";
groupBoxTools.ResumeLayout(false);
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
ResumeLayout(false);
}
@ -292,7 +279,6 @@
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddExcavator;
private Button buttonAddTrackedVehicle;
private PictureBox pictureBox;
private Button ButtonRemoveExcavator;

View File

@ -42,46 +42,29 @@ public partial class FormExcavatorCollection : Form
}
/// <summary>
/// Добавление гусеничной машины
/// Добавление гусеничной машины/ экскаватора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddTrackedVehicle_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrackedVehicle));
private void ButtonAddTrackedVehicle_Click(object sender, EventArgs e) {
FormExcavatorConfig form = new();
// TODO передать метод(c)
form.Show();
form.AddEvent(SetTrackedVehicle);
}
/// <summary>
/// Добавление экскаватора
/// Добавление экскаватора/гусинечной машины в коллекцию
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddExcavator_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningExcavator));
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
/// <param name="trackedVehicle"></param>
private void SetTrackedVehicle(DrawningTrackedVehicle? trackedVehicle)
{
if (_company == null)
if (_company == null || trackedVehicle == null)
{
return;
}
Random random = new();
DrawningTrackedVehicle drawningTrackedVehicle;
switch (type)
{
case nameof(DrawningTrackedVehicle):
drawningTrackedVehicle = new DrawningTrackedVehicle(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningExcavator):
drawningTrackedVehicle = new DrawningExcavator(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random), true, true);
break;
default:
return;
}
if (_company + drawningTrackedVehicle != -1)
if (_company + trackedVehicle != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -92,23 +75,6 @@ public partial class FormExcavatorCollection : Form
}
}
/// <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>

View File

@ -0,0 +1,373 @@
namespace ProjectExcavator
{
partial class FormExcavatorConfig
{
/// <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()
{
groupBoxConfig = new GroupBox();
labelWeight = new Label();
groupBoxColors = new GroupBox();
panelPurple = new Panel();
panelYellow = new Panel();
panelBlack = new Panel();
panelGray = new Panel();
panelBlue = new Panel();
panelWhite = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxSupports = new CheckBox();
checkBoxBucket = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
labelSpeed = new Label();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
buttonAdd = new Button();
buttonCancel = new Button();
panelObject = new Panel();
pictureBoxObject = new PictureBox();
labelBodyColor = new Label();
labelAdditionalColor = new Label();
groupBoxConfig.SuspendLayout();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(labelWeight);
groupBoxConfig.Controls.Add(groupBoxColors);
groupBoxConfig.Controls.Add(checkBoxSupports);
groupBoxConfig.Controls.Add(checkBoxBucket);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(labelSpeed);
groupBoxConfig.Controls.Add(labelModifiedObject);
groupBoxConfig.Controls.Add(labelSimpleObject);
groupBoxConfig.Dock = DockStyle.Left;
groupBoxConfig.Location = new Point(0, 0);
groupBoxConfig.Name = "groupBoxConfig";
groupBoxConfig.Size = new Size(548, 285);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(12, 90);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 12;
labelWeight.Text = "Вес:";
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelPurple);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlack);
groupBoxColors.Controls.Add(panelGray);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(260, 27);
groupBoxColors.Margin = new Padding(3, 4, 3, 4);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Padding = new Padding(3, 4, 3, 4);
groupBoxColors.Size = new Size(259, 149);
groupBoxColors.TabIndex = 10;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.MediumPurple;
panelPurple.Location = new Point(201, 88);
panelPurple.Margin = new Padding(3, 4, 3, 4);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(39, 45);
panelPurple.TabIndex = 3;
//
// panelYellow
//
panelYellow.BackColor = Color.Gold;
panelYellow.Location = new Point(201, 29);
panelYellow.Margin = new Padding(3, 4, 3, 4);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(39, 45);
panelYellow.TabIndex = 1;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(137, 88);
panelBlack.Margin = new Padding(3, 4, 3, 4);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(39, 45);
panelBlack.TabIndex = 4;
//
// panelGray
//
panelGray.BackColor = Color.DarkGray;
panelGray.Location = new Point(77, 88);
panelGray.Margin = new Padding(3, 4, 3, 4);
panelGray.Name = "panelGray";
panelGray.Size = new Size(39, 45);
panelGray.TabIndex = 5;
//
// panelBlue
//
panelBlue.BackColor = Color.LightSteelBlue;
panelBlue.Location = new Point(137, 29);
panelBlue.Margin = new Padding(3, 4, 3, 4);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(39, 45);
panelBlue.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.Transparent;
panelWhite.Location = new Point(17, 88);
panelWhite.Margin = new Padding(3, 4, 3, 4);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(39, 45);
panelWhite.TabIndex = 2;
//
// panelGreen
//
panelGreen.BackColor = Color.Olive;
panelGreen.Location = new Point(77, 29);
panelGreen.Margin = new Padding(3, 4, 3, 4);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(39, 45);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.DarkRed;
panelRed.Location = new Point(17, 29);
panelRed.Margin = new Padding(3, 4, 3, 4);
panelRed.Name = "panelRed";
panelRed.Size = new Size(39, 45);
panelRed.TabIndex = 0;
//
// checkBoxSupports
//
checkBoxSupports.AutoSize = true;
checkBoxSupports.Location = new Point(12, 248);
checkBoxSupports.Margin = new Padding(3, 4, 3, 4);
checkBoxSupports.Name = "checkBoxSupports";
checkBoxSupports.Size = new Size(305, 24);
checkBoxSupports.TabIndex = 8;
checkBoxSupports.Text = "Признак наличия опоры для фиксации";
checkBoxSupports.UseVisualStyleBackColor = true;
//
// checkBoxBucket
//
checkBoxBucket.AutoSize = true;
checkBoxBucket.Location = new Point(12, 208);
checkBoxBucket.Margin = new Padding(3, 4, 3, 4);
checkBoxBucket.Name = "checkBoxBucket";
checkBoxBucket.Size = new Size(202, 24);
checkBoxBucket.TabIndex = 7;
checkBoxBucket.Text = "Признак наличия ковша";
checkBoxBucket.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(109, 88);
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(105, 27);
numericUpDownWeight.TabIndex = 6;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(109, 45);
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(105, 27);
numericUpDownSpeed.TabIndex = 5;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(12, 47);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 3;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(404, 187);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(115, 45);
labelModifiedObject.TabIndex = 2;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(261, 187);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(115, 45);
labelSimpleObject.TabIndex = 1;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// buttonAdd
//
buttonAdd.Location = new Point(575, 241);
buttonAdd.Margin = new Padding(3, 4, 3, 4);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(86, 31);
buttonAdd.TabIndex = 3;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(740, 240);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(86, 31);
buttonCancel.TabIndex = 4;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(575, 13);
panelObject.Margin = new Padding(3, 4, 3, 4);
panelObject.Name = "panelObject";
panelObject.Size = new Size(251, 219);
panelObject.TabIndex = 5;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(13, 75);
pictureBoxObject.Margin = new Padding(3, 4, 3, 4);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(226, 132);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(16, 17);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(100, 40);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(139, 17);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(100, 40);
labelAdditionalColor.TabIndex = 4;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter;
//
// FormExcavatorConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(838, 285);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
Name = "FormExcavatorConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
panelObject.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private Label labelSpeed;
private Label labelModifiedObject;
private Label labelSimpleObject;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private CheckBox checkBoxBucket;
private CheckBox checkBoxSupports;
private GroupBox groupBoxColors;
private Panel panelPurple;
private Panel panelYellow;
private Panel panelBlack;
private Panel panelGray;
private Panel panelBlue;
private Panel panelWhite;
private Panel panelGreen;
private Panel panelRed;
private Button buttonAdd;
private Button buttonCancel;
private Panel panelObject;
private PictureBox pictureBoxObject;
private Label labelWeight;
private Label labelAdditionalColor;
private Label labelBodyColor;
}
}

View File

@ -0,0 +1,174 @@
using ProjectExcavator.Drawnings;
using ProjectExcavator.Entities;
namespace ProjectExcavator;
/// <summary>
/// Форма конфигурации объекта
/// </summary>
public partial class FormExcavatorConfig : Form
{
/// <summary>
/// Объект - прорисовка гусеничной машины/экскаватора
/// </summary>
private DrawningTrackedVehicle? _trackedVehicle;
/// <summary>
/// Событие для передачи объекта
/// </summary>
private event Action<DrawningTrackedVehicle>? _trackedVehicleDelegate;
/// <summary>
/// Конструктор
/// </summary>
public FormExcavatorConfig()
{
InitializeComponent();
panelRed.MouseDown += Panel_MouseDown;
panelGreen.MouseDown += Panel_MouseDown;
panelBlue.MouseDown += Panel_MouseDown;
panelYellow.MouseDown += Panel_MouseDown;
panelWhite.MouseDown += Panel_MouseDown;
panelGray.MouseDown += Panel_MouseDown;
panelBlack.MouseDown += Panel_MouseDown;
panelPurple.MouseDown += Panel_MouseDown;
// TODO buttonCancel.Click привязать анонимный метод через lambda с закрытием формы(c)
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="excavatorDelegate"></param>
public void AddEvent(Action<DrawningTrackedVehicle> excavatorDelegate)
{
_trackedVehicleDelegate += excavatorDelegate;
}
/// <summary>
/// Прорисовка объекта
/// </summary>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_trackedVehicle?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_trackedVehicle?.SetPosition(30, 20);
_trackedVehicle?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{
case "labelSimpleObject":
_trackedVehicle = new DrawningTrackedVehicle((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
_trackedVehicle = new DrawningExcavator((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
Color.Black, checkBoxBucket.Checked, checkBoxSupports.Checked);
break;
}
DrawObject();
}
// <summary>
/// Передаем информацию при нажатии на Panel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Panel_MouseDown(object? sender, MouseEventArgs e)
{
//Отправка цвета в Drag&Drop
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
//Логика смены цветов: основного и дополнительного (для продвинутого объекта)
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_trackedVehicle != null)
{
_trackedVehicle.EntityTrackedVehicle.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
}
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (_trackedVehicle is DrawningExcavator)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_trackedVehicle?.EntityTrackedVehicle is EntityExcavator _catamaran)
{
_catamaran.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
}
DrawObject();
}
/// <summary>
/// Передача объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAdd_Click(object sender, EventArgs e)
{
if (_trackedVehicle != null)
{
_trackedVehicleDelegate?.Invoke(_trackedVehicle);
Close();
}
}
}

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>