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

This commit is contained in:
Мария Котова 2024-04-10 14:38:23 +04:00
parent ad03df31a4
commit 340e44fdb1
8 changed files with 881 additions and 146 deletions

View File

@ -22,9 +22,15 @@ public class EntityExcavator : EntityExcavatorEmpty
/// Признак (опция) наличие бульдозерного отвала /// Признак (опция) наличие бульдозерного отвала
/// </summary> /// </summary>
public bool BulldozerDump { get; private set; } public bool BulldozerDump { get; private set; }
/// <summary>
/// установка доп. цвета
/// </summary>
/// <param name="color"></param>
public void setAdditionalColor(Color color)
{
AdditionalColor = color;
}
/// <summary> /// <summary>
/// Конструктор /// Конструктор
/// </summary> /// </summary>

View File

@ -25,6 +25,15 @@ public class EntityExcavatorEmpty
/// </summary> /// </summary>
public double Step => Speed * 100 / Weight; public double Step => Speed * 100 / Weight;
/// <summary>
/// Основной цвет
/// </summary>
/// <param name="color"></param>
public void setBodyColor(Color color)
{
BodyColor = color;
}
/// <summary> /// <summary>
/// конструктор сущности /// конструктор сущности
/// </summary> /// </summary>

View File

@ -0,0 +1,9 @@
using WinFormsAppExcavator.Drawings;
namespace WinFormsAppExcavator;
/// <summary>
/// Делегат для передачи объекта-экскаватора
/// </summary>
/// <param name="excavator"></param>
public delegate void ExcavatorDelegate(DrawingExcavatorEmpty excavator);

View File

@ -29,6 +29,12 @@
private void InitializeComponent() private void InitializeComponent()
{ {
groupBoxTools = new GroupBox(); groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
maskedTextBox = new MaskedTextBox();
buttonAddExcavatorEmpty = new Button();
buttonGoToCheck = new Button();
buttonRemoveExcavator = new Button();
buttonRefresh = new Button();
buttonCreateCompany = new Button(); buttonCreateCompany = new Button();
panelStorage = new Panel(); panelStorage = new Panel();
buttonCollectionDel = new Button(); buttonCollectionDel = new Button();
@ -38,19 +44,12 @@
radioButtonMassive = new RadioButton(); radioButtonMassive = new RadioButton();
textBoxCollectionName = new TextBox(); textBoxCollectionName = new TextBox();
labelCollectionName = new Label(); labelCollectionName = new Label();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonRemoveExcavator = new Button();
maskedTextBox = new MaskedTextBox();
buttonAddExcavator = new Button();
buttonAddExcavatorEmpty = new Button();
comboBoxSelectorCompany = new ComboBox(); comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox(); pictureBox = new PictureBox();
panelCompanyTools = new Panel();
groupBoxTools.SuspendLayout(); groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout(); panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
panelCompanyTools.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// groupBoxTools // groupBoxTools
@ -67,6 +66,73 @@
groupBoxTools.TabStop = false; groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты"; groupBoxTools.Text = "Инструменты";
// //
// panelCompanyTools
//
panelCompanyTools.Controls.Add(maskedTextBox);
panelCompanyTools.Controls.Add(buttonAddExcavatorEmpty);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(buttonRemoveExcavator);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 324);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(214, 228);
panelCompanyTools.TabIndex = 9;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(3, 96);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(208, 27);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonAddExcavatorEmpty
//
buttonAddExcavatorEmpty.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddExcavatorEmpty.Location = new Point(5, 0);
buttonAddExcavatorEmpty.Name = "buttonAddExcavatorEmpty";
buttonAddExcavatorEmpty.Size = new Size(209, 53);
buttonAddExcavatorEmpty.TabIndex = 1;
buttonAddExcavatorEmpty.Text = "Добавление экскаватора простого";
buttonAddExcavatorEmpty.UseVisualStyleBackColor = true;
buttonAddExcavatorEmpty.Click += ButtonAddExcavatorEmpty_Click;
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(5, 163);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(206, 29);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Отправление на тест";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// buttonRemoveExcavator
//
buttonRemoveExcavator.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveExcavator.Location = new Point(5, 127);
buttonRemoveExcavator.Name = "buttonRemoveExcavator";
buttonRemoveExcavator.Size = new Size(206, 30);
buttonRemoveExcavator.TabIndex = 4;
buttonRemoveExcavator.Text = "Удаление экскаватора";
buttonRemoveExcavator.UseVisualStyleBackColor = true;
buttonRemoveExcavator.Click += ButtonRemoveExcavator_Click;
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(5, 198);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(206, 27);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonCreateCompany // buttonCreateCompany
// //
buttonCreateCompany.Location = new Point(6, 292); buttonCreateCompany.Location = new Point(6, 292);
@ -158,70 +224,6 @@
labelCollectionName.TabIndex = 0; labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции"; labelCollectionName.Text = "Название коллекции";
// //
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(5, 198);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(206, 27);
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(5, 163);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(206, 29);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Отправление на тест";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// buttonRemoveExcavator
//
buttonRemoveExcavator.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveExcavator.Location = new Point(5, 127);
buttonRemoveExcavator.Name = "buttonRemoveExcavator";
buttonRemoveExcavator.Size = new Size(206, 30);
buttonRemoveExcavator.TabIndex = 4;
buttonRemoveExcavator.Text = "Удаление экскаватора";
buttonRemoveExcavator.UseVisualStyleBackColor = true;
buttonRemoveExcavator.Click += ButtonRemoveExcavator_Click;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(3, 96);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(208, 27);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonAddExcavator
//
buttonAddExcavator.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddExcavator.Location = new Point(0, 59);
buttonAddExcavator.Name = "buttonAddExcavator";
buttonAddExcavator.Size = new Size(214, 31);
buttonAddExcavator.TabIndex = 2;
buttonAddExcavator.Text = "Добавление экскаватора";
buttonAddExcavator.UseVisualStyleBackColor = true;
buttonAddExcavator.Click += ButtonAddExcavator_Click;
//
// buttonAddExcavatorEmpty
//
buttonAddExcavatorEmpty.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddExcavatorEmpty.Location = new Point(5, 0);
buttonAddExcavatorEmpty.Name = "buttonAddExcavatorEmpty";
buttonAddExcavatorEmpty.Size = new Size(209, 53);
buttonAddExcavatorEmpty.TabIndex = 1;
buttonAddExcavatorEmpty.Text = "Добавление экскаватора простого";
buttonAddExcavatorEmpty.UseVisualStyleBackColor = true;
buttonAddExcavatorEmpty.Click += ButtonAddExcavatorEmpty_Click;
//
// comboBoxSelectorCompany // comboBoxSelectorCompany
// //
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@ -243,21 +245,6 @@
pictureBox.TabIndex = 1; pictureBox.TabIndex = 1;
pictureBox.TabStop = false; pictureBox.TabStop = false;
// //
// panelCompanyTools
//
panelCompanyTools.Controls.Add(maskedTextBox);
panelCompanyTools.Controls.Add(buttonAddExcavator);
panelCompanyTools.Controls.Add(buttonAddExcavatorEmpty);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(buttonRemoveExcavator);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 324);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(214, 228);
panelCompanyTools.TabIndex = 9;
//
// FormExcavatorCollection // FormExcavatorCollection
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
@ -268,11 +255,11 @@
Name = "FormExcavatorCollection"; Name = "FormExcavatorCollection";
Text = "Коллекция экскаваторов"; Text = "Коллекция экскаваторов";
groupBoxTools.ResumeLayout(false); groupBoxTools.ResumeLayout(false);
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
panelStorage.ResumeLayout(false); panelStorage.ResumeLayout(false);
panelStorage.PerformLayout(); panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
} }
@ -280,7 +267,6 @@
private GroupBox groupBoxTools; private GroupBox groupBoxTools;
private ComboBox comboBoxSelectorCompany; private ComboBox comboBoxSelectorCompany;
private Button buttonAddExcavator;
private Button buttonAddExcavatorEmpty; private Button buttonAddExcavatorEmpty;
private Button buttonRemoveExcavator; private Button buttonRemoveExcavator;
private MaskedTextBox maskedTextBox; private MaskedTextBox maskedTextBox;

View File

@ -38,44 +38,27 @@ public partial class FormExcavatorCollection : Form
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void ButtonAddExcavatorEmpty_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingExcavatorEmpty)); private void ButtonAddExcavatorEmpty_Click(object sender, EventArgs e)
/// <summary>
/// Добавление полного экскаватора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddExcavator_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingExcavator));
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{ {
if (_company == null) FormExcavatorConfig form= new ();
// TODO передать метод
form.Show();
form.AddEvent(SetExcavator);
}
/// <summary>
/// Добавление экскаватора
/// </summary>
/// <param name="excavator"></param>
private void SetExcavator(DrawingExcavatorEmpty? excavator)
{
if (_company == null || excavator == null)
{ {
return; return;
} }
Random random = new(); if (_company + excavator != -1)
DrawingExcavatorEmpty drawningExcavatorEmpty;
switch (type)
{
case nameof(DrawingExcavatorEmpty):
drawningExcavatorEmpty = new DrawingExcavatorEmpty(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawingExcavator):
// TODO вызов диалогового окна для выбора цвета
drawningExcavatorEmpty = new DrawingExcavator(random.Next(100, 300), random.Next(1000, 3000),
GetColor(random), GetColor(random),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + excavator == 1)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show(); pictureBox.Image = _company.Show();
@ -85,24 +68,6 @@ public partial class FormExcavatorCollection : Form
MessageBox.Show("Не удалось добавить объект"); 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>
/// Удаление объекта /// Удаление объекта
/// </summary> /// </summary>
@ -133,7 +98,11 @@ public partial class FormExcavatorCollection : Form
} }
} }
/// <summary>
/// Кнопка передачи на тест
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonGoToCheck_Click(object sender, EventArgs e) private void ButtonGoToCheck_Click(object sender, EventArgs e)
{ {
if (_company == null) if (_company == null)
@ -164,7 +133,11 @@ public partial class FormExcavatorCollection : Form
}; };
form.ShowDialog(); form.ShowDialog();
} }
/// <summary>
/// Кнопка обновления
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRefresh_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
if (_company == null) if (_company == null)
@ -199,6 +172,10 @@ public partial class FormExcavatorCollection : Form
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType); _storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
RerfreshListBoxItems(); RerfreshListBoxItems();
} }
/// <summary>
/// обновление элементов
/// </summary>
private void RerfreshListBoxItems() private void RerfreshListBoxItems()
{ {
listBoxCollection.Items.Clear(); listBoxCollection.Items.Clear();

View File

@ -0,0 +1,410 @@
namespace WinFormsAppExcavator
{
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();
panel2 = new Panel();
pictureBox1 = new PictureBox();
panel1 = new Panel();
groupBoxColors = new GroupBox();
panelPurple = new Panel();
panelYellow = new Panel();
panelBlack = new Panel();
panelBlue = new Panel();
panelGray = new Panel();
panelGreen = new Panel();
panelWhite = new Panel();
panelRed = new Panel();
checkBoxBulldozerDump = new CheckBox();
checkBoxSupport = new CheckBox();
checkBoxBucket = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
labelWeight = new Label();
labelSpeed = new Label();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
panelObject = new Panel();
labelBodyColor = new Label();
pictureBoxObject = new PictureBox();
labelAdditionalColor = new Label();
buttonAdd = new Button();
buttonCancel = new Button();
groupBoxConfig.SuspendLayout();
panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(panel2);
groupBoxConfig.Controls.Add(panel1);
groupBoxConfig.Controls.Add(groupBoxColors);
groupBoxConfig.Controls.Add(checkBoxBulldozerDump);
groupBoxConfig.Controls.Add(checkBoxSupport);
groupBoxConfig.Controls.Add(checkBoxBucket);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(labelWeight);
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(571, 251);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// panel2
//
panel2.Controls.Add(pictureBox1);
panel2.Location = new Point(578, 10);
panel2.Name = "panel2";
panel2.Size = new Size(250, 125);
panel2.TabIndex = 1;
//
// pictureBox1
//
pictureBox1.Location = new Point(59, 48);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new Size(125, 62);
pictureBox1.TabIndex = 0;
pictureBox1.TabStop = false;
//
// panel1
//
panel1.Location = new Point(594, 12);
panel1.Name = "panel1";
panel1.Size = new Size(226, 144);
panel1.TabIndex = 1;
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelPurple);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlack);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelGray);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(316, 21);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(256, 125);
groupBoxColors.TabIndex = 9;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(189, 81);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(35, 33);
panelPurple.TabIndex = 7;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(189, 36);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(35, 33);
panelYellow.TabIndex = 3;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(130, 81);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(35, 33);
panelBlack.TabIndex = 6;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(130, 36);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(35, 33);
panelBlue.TabIndex = 2;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(74, 81);
panelGray.Name = "panelGray";
panelGray.Size = new Size(35, 33);
panelGray.TabIndex = 5;
//
// panelGreen
//
panelGreen.BackColor = Color.FromArgb(0, 192, 0);
panelGreen.Location = new Point(74, 36);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(35, 33);
panelGreen.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(23, 81);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(35, 33);
panelWhite.TabIndex = 4;
//
// panelRed
//
panelRed.AllowDrop = true;
panelRed.AutoSize = true;
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(23, 36);
panelRed.Name = "panelRed";
panelRed.Size = new Size(35, 33);
panelRed.TabIndex = 0;
panelRed.MouseDown += Panel_MouseDown;
//
// checkBoxBulldozerDump
//
checkBoxBulldozerDump.AutoSize = true;
checkBoxBulldozerDump.Location = new Point(13, 162);
checkBoxBulldozerDump.Name = "checkBoxBulldozerDump";
checkBoxBulldozerDump.Size = new Size(315, 24);
checkBoxBulldozerDump.TabIndex = 8;
checkBoxBulldozerDump.Text = "Признак наличие бульдозерного отвала";
checkBoxBulldozerDump.UseVisualStyleBackColor = true;
//
// checkBoxSupport
//
checkBoxSupport.AutoSize = true;
checkBoxSupport.Location = new Point(12, 132);
checkBoxSupport.Name = "checkBoxSupport";
checkBoxSupport.Size = new Size(209, 24);
checkBoxSupport.TabIndex = 7;
checkBoxSupport.Text = "Признак наличие опоры ";
checkBoxSupport.UseVisualStyleBackColor = true;
//
// checkBoxBucket
//
checkBoxBucket.AutoSize = true;
checkBoxBucket.Location = new Point(13, 102);
checkBoxBucket.Name = "checkBoxBucket";
checkBoxBucket.Size = new Size(202, 24);
checkBoxBucket.TabIndex = 6;
checkBoxBucket.Text = "Признак наличия ковша";
checkBoxBucket.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(91, 54);
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(150, 27);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(91, 21);
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(150, 27);
numericUpDownSpeed.TabIndex = 4;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(12, 61);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(33, 20);
labelWeight.TabIndex = 3;
labelWeight.Text = "Вес";
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(12, 23);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(73, 20);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(161, 201);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(113, 25);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(33, 201);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(98, 25);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Location = new Point(575, 7);
panelObject.Name = "panelObject";
panelObject.Size = new Size(250, 197);
panelObject.TabIndex = 1;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.AutoSize = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(31, 19);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(44, 22);
labelBodyColor.TabIndex = 1;
labelBodyColor.Text = "Цвет";
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(19, 44);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(216, 150);
pictureBoxObject.TabIndex = 0;
pictureBoxObject.TabStop = false;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.AutoSize = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(158, 19);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(77, 22);
labelAdditionalColor.TabIndex = 2;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter;
//
// buttonAdd
//
buttonAdd.Location = new Point(578, 210);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 29);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(716, 210);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// FormExcavatorConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(822, 251);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(panelObject);
Controls.Add(groupBoxConfig);
Name = "FormExcavatorConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
groupBoxColors.ResumeLayout(false);
groupBoxColors.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
panelObject.ResumeLayout(false);
panelObject.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private Label labelModifiedObject;
private Label labelSimpleObject;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelWeight;
private Label labelSpeed;
private CheckBox checkBoxBulldozerDump;
private CheckBox checkBoxSupport;
private CheckBox checkBoxBucket;
private GroupBox groupBoxColors;
private Panel panelPurple;
private Panel panelYellow;
private Panel panelBlack;
private Panel panelBlue;
private Panel panelGray;
private Panel panelGreen;
private Panel panelWhite;
private Panel panelRed;
private Panel panel1;
private Panel panel2;
private PictureBox pictureBox1;
private Panel panelObject;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
private Label labelAdditionalColor;
private Label labelBodyColor;
}
}

View File

@ -0,0 +1,218 @@
using WinFormsAppExcavator.Drawings;
using WinFormsAppExcavator.Entity;
namespace WinFormsAppExcavator
{
/// <summary>
/// форма конфигурации объекта
/// </summary>
public partial class FormExcavatorConfig : Form
{
private DrawingExcavatorEmpty? _excavatorempty;
/// <summary>
/// событие для передачи объекта
/// </summary>
private event Action<DrawingExcavatorEmpty>? ExcavatorDelegate;
/// <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 закрытием формы
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="carDelegate"></param>
public void AddEvent(Action<DrawingExcavatorEmpty> excavatorDelegate)
{
ExcavatorDelegate += excavatorDelegate;
}
/// <summary>
/// Отрисовка объекта
/// </summary>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_excavatorempty?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_excavatorempty?.SetPosition(15, 15);
_excavatorempty?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Передаем информацию при нажатии на Labe
/// </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)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{
case "labelSimpleObject":
_excavatorempty = new DrawingExcavatorEmpty((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
_excavatorempty = new DrawingExcavator((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value,
Color.White,
Color.Black, checkBoxBucket.Checked,
checkBoxSupport.Checked, checkBoxBulldozerDump.Checked);
break;
}
labelBodyColor.BackColor = Color.Empty;
labelAdditionalColor.BackColor = Color.Empty;
DrawObject();
}
/// <summary>
/// Передаем информацию при нажатии на Panel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Panel_MouseDown(object? sender, MouseEventArgs e)
{
// TODO отправка цвета в Drag&Drop
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
/// <summary>
/// Проверка получаемой информации по основному цвету
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// действия при приеме перетаскиваемого основного цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_excavatorempty != null)
{
_excavatorempty.EntityExcavatorEmpty.setBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
}
/// <summary>
/// проверка получаемой информации по доп. цвету
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (_excavatorempty is DrawingExcavator)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
/// <summary>
/// действия при перетаскивании доп. цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_excavatorempty.EntityExcavatorEmpty is EntityExcavator _excavator)
{
_excavator.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 (_excavatorempty != null)
{
ExcavatorDelegate?.Invoke(_excavatorempty);
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>