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

This commit is contained in:
Esenia12 2024-04-01 10:01:58 +04:00
parent 749fe2c796
commit 08bcdc0bdf
10 changed files with 834 additions and 146 deletions

View File

@ -0,0 +1,11 @@
using ProjectDumpTrack.Drawnings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectDumpTruck
{
public delegate void TrackDelegate(DrawningTrack track);
}

View File

@ -24,7 +24,6 @@ public class DrawningDumpTrack : DrawningTrack
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, additional2Color, bodywork, awning);
}
public override void DrawTransport(Graphics g)

View File

@ -6,14 +6,22 @@
public class EntityDumpTrack : EntityTrack
{
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// Дополнительный цвет (для кузова)
/// </summary>
public Color AdditionalColor { get; private set; }
public void SetAdditionalColor(Color color)
{
AdditionalColor = color;
}
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// Дополнительный цвет (для тента)
/// </summary>
public Color AdditionalAwningColor { get; private set; }
public void SetAdditionalAwningColor(Color color)
{
AdditionalAwningColor = color;
}
/// <summary>
/// Признак (опция) наличия кузова

View File

@ -20,6 +20,10 @@ public class EntityTrack
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
public void SetBodyColor(Color color)
{
BodyColor = color;
}
/// <summary>
/// Шаг перемещения самосвала

View File

@ -31,7 +31,6 @@
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonAddTrack = new Button();
buttonAddDumpTrack = new Button();
buttonRefresh = new Button();
maskedTextBox = new MaskedTextBox();
buttonGoToCheck = new Button();
@ -60,9 +59,11 @@
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(790, 0);
groupBoxTools.Location = new Point(903, 0);
groupBoxTools.Margin = new Padding(3, 4, 3, 4);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(216, 588);
groupBoxTools.Padding = new Padding(3, 4, 3, 4);
groupBoxTools.Size = new Size(247, 784);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
@ -70,41 +71,33 @@
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddTrack);
panelCompanyTools.Controls.Add(buttonAddDumpTrack);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(maskedTextBox);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(buttonDelTrack);
panelCompanyTools.Location = new Point(3, 354);
panelCompanyTools.Location = new Point(3, 472);
panelCompanyTools.Margin = new Padding(3, 4, 3, 4);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(210, 231);
panelCompanyTools.Size = new Size(240, 308);
panelCompanyTools.TabIndex = 9;
//
// buttonAddTrack
//
buttonAddTrack.Location = new Point(9, 12);
buttonAddTrack.Location = new Point(10, 18);
buttonAddTrack.Margin = new Padding(3, 4, 3, 4);
buttonAddTrack.Name = "buttonAddTrack";
buttonAddTrack.Size = new Size(192, 30);
buttonAddTrack.Size = new Size(219, 40);
buttonAddTrack.TabIndex = 1;
buttonAddTrack.Text = "Добавление грузовика";
buttonAddTrack.UseVisualStyleBackColor = true;
buttonAddTrack.Click += ButtonAddTrack_Click;
//
// buttonAddDumpTrack
//
buttonAddDumpTrack.Location = new Point(9, 48);
buttonAddDumpTrack.Name = "buttonAddDumpTrack";
buttonAddDumpTrack.Size = new Size(192, 27);
buttonAddDumpTrack.TabIndex = 2;
buttonAddDumpTrack.Text = "Добавление самосвала";
buttonAddDumpTrack.UseVisualStyleBackColor = true;
buttonAddDumpTrack.Click += ButtonAddDumpTrack_Click;
//
// buttonRefresh
//
buttonRefresh.Location = new Point(9, 197);
buttonRefresh.Location = new Point(10, 263);
buttonRefresh.Margin = new Padding(3, 4, 3, 4);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(192, 25);
buttonRefresh.Size = new Size(219, 33);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
@ -112,18 +105,20 @@
//
// maskedTextBox
//
maskedTextBox.Location = new Point(9, 88);
maskedTextBox.Location = new Point(10, 117);
maskedTextBox.Margin = new Padding(3, 4, 3, 4);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(192, 23);
maskedTextBox.Size = new Size(219, 27);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonGoToCheck
//
buttonGoToCheck.Location = new Point(9, 162);
buttonGoToCheck.Location = new Point(10, 216);
buttonGoToCheck.Margin = new Padding(3, 4, 3, 4);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(192, 29);
buttonGoToCheck.Size = new Size(219, 39);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
@ -131,9 +126,10 @@
//
// buttonDelTrack
//
buttonDelTrack.Location = new Point(9, 117);
buttonDelTrack.Location = new Point(10, 156);
buttonDelTrack.Margin = new Padding(3, 4, 3, 4);
buttonDelTrack.Name = "buttonDelTrack";
buttonDelTrack.Size = new Size(192, 29);
buttonDelTrack.Size = new Size(219, 39);
buttonDelTrack.TabIndex = 4;
buttonDelTrack.Text = "Удалить грузовик";
buttonDelTrack.UseVisualStyleBackColor = true;
@ -141,9 +137,10 @@
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(12, 325);
buttonCreateCompany.Location = new Point(14, 433);
buttonCreateCompany.Margin = new Padding(3, 4, 3, 4);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(192, 23);
buttonCreateCompany.Size = new Size(219, 31);
buttonCreateCompany.TabIndex = 8;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
@ -159,16 +156,18 @@
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 19);
panelStorage.Location = new Point(3, 24);
panelStorage.Margin = new Padding(3, 4, 3, 4);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(210, 271);
panelStorage.Size = new Size(241, 361);
panelStorage.TabIndex = 7;
//
// buttonCollectionDel
//
buttonCollectionDel.Location = new Point(9, 233);
buttonCollectionDel.Location = new Point(10, 311);
buttonCollectionDel.Margin = new Padding(3, 4, 3, 4);
buttonCollectionDel.Name = "buttonCollectionDel";
buttonCollectionDel.Size = new Size(192, 23);
buttonCollectionDel.Size = new Size(219, 31);
buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удалить коллекцию";
buttonCollectionDel.UseVisualStyleBackColor = true;
@ -177,18 +176,19 @@
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(9, 112);
listBoxCollection.ItemHeight = 20;
listBoxCollection.Location = new Point(10, 149);
listBoxCollection.Margin = new Padding(3, 4, 3, 4);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(192, 109);
listBoxCollection.Size = new Size(219, 144);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
buttonCollectionAdd.Location = new Point(9, 83);
buttonCollectionAdd.Location = new Point(10, 111);
buttonCollectionAdd.Margin = new Padding(3, 4, 3, 4);
buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(192, 23);
buttonCollectionAdd.Size = new Size(219, 31);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
@ -197,9 +197,10 @@
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(126, 57);
radioButtonList.Location = new Point(144, 76);
radioButtonList.Margin = new Padding(3, 4, 3, 4);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(66, 19);
radioButtonList.Size = new Size(80, 24);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
@ -208,9 +209,10 @@
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(29, 57);
radioButtonMassive.Location = new Point(33, 76);
radioButtonMassive.Margin = new Padding(3, 4, 3, 4);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.Size = new Size(82, 24);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
@ -218,17 +220,18 @@
//
// textBoxCollectionName
//
textBoxCollectionName.Location = new Point(9, 28);
textBoxCollectionName.Location = new Point(10, 37);
textBoxCollectionName.Margin = new Padding(3, 4, 3, 4);
textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(192, 23);
textBoxCollectionName.Size = new Size(219, 27);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(47, 10);
labelCollectionName.Location = new Point(54, 13);
labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(128, 15);
labelCollectionName.Size = new Size(162, 20);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции :";
//
@ -237,9 +240,10 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(12, 296);
comboBoxSelectorCompany.Location = new Point(14, 395);
comboBoxSelectorCompany.Margin = new Padding(3, 4, 3, 4);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(192, 23);
comboBoxSelectorCompany.Size = new Size(219, 28);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
@ -248,20 +252,24 @@
pictureBox.Dock = DockStyle.Fill;
pictureBox.Enabled = false;
pictureBox.Location = new Point(0, 0);
pictureBox.Margin = new Padding(3, 4, 3, 4);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(790, 588);
pictureBox.Size = new Size(903, 784);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
pictureBox.Click += pictureBox_Click;
//
// FormTrackCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1006, 588);
ClientSize = new Size(1150, 784);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Margin = new Padding(3, 4, 3, 4);
Name = "FormTrackCollection";
Text = "Коллекция самосвалов";
Load += FormTrackCollection_Load;
groupBoxTools.ResumeLayout(false);
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
@ -275,7 +283,6 @@
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddDumpTrack;
private Button buttonAddTrack;
private PictureBox pictureBox;
private Button buttonRefresh;

View File

@ -39,46 +39,43 @@ public partial class FormTrackCollection : Form
}
/// <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)
private void ButtonAddTrack_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
FormTrackConfig form = new();
form.TrackDelegate += SetCar;
form.Show();
}
Random random = new();
DrawningTrack drawningTrack;
switch (type)
/// <summary>
/// Добавление самосвала
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddDumpTrack_Click(object sender, EventArgs e)
{
}
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void SetCar(DrawningTrack track)
{
if (_company == null || track == null)
{
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;
return;
}
if (_company + drawningTrack != -1)
if (_company + track != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -288,7 +285,15 @@ public partial class FormTrackCollection : Form
RerfreshListBoxItems();
}
private void pictureBox_Click(object sender, EventArgs e)
{
}
private void FormTrackCollection_Load(object sender, EventArgs e)
{
}
}

View File

@ -1,64 +1,4 @@
<?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.
-->
<root>
<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">

View File

@ -0,0 +1,392 @@
namespace ProjectDumpTruck
{
partial class FormTrackConfig
{
/// <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();
groupBoxAdditionalColors = new GroupBox();
panelPurple = new Panel();
panelBlack = new Panel();
panelGray = new Panel();
panelWhite = new Panel();
panelYellow = new Panel();
panelBlue = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxAwning = new CheckBox();
checkBoxBodywork = new CheckBox();
numericUpDownWeight = new NumericUpDown();
labelWeight = new Label();
numericUpDownSpeed = new NumericUpDown();
labelSpeed = new Label();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
pictureBoxObject = new PictureBox();
panelObject = new Panel();
labelAwning = new Label();
labelBodywork = new Label();
labelBodyColor = new Label();
buttonAdd = new Button();
buttonCancel = new Button();
groupBoxConfig.SuspendLayout();
groupBoxAdditionalColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
panelObject.SuspendLayout();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(groupBoxAdditionalColors);
groupBoxConfig.Controls.Add(checkBoxAwning);
groupBoxConfig.Controls.Add(checkBoxBodywork);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(labelWeight);
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.Margin = new Padding(3, 2, 3, 2);
groupBoxConfig.Name = "groupBoxConfig";
groupBoxConfig.Padding = new Padding(3, 2, 3, 2);
groupBoxConfig.Size = new Size(382, 208);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
groupBoxConfig.Enter += groupBoxConfig_Enter;
//
// groupBoxAdditionalColors
//
groupBoxAdditionalColors.Controls.Add(panelPurple);
groupBoxAdditionalColors.Controls.Add(panelBlack);
groupBoxAdditionalColors.Controls.Add(panelGray);
groupBoxAdditionalColors.Controls.Add(panelWhite);
groupBoxAdditionalColors.Controls.Add(panelYellow);
groupBoxAdditionalColors.Controls.Add(panelBlue);
groupBoxAdditionalColors.Controls.Add(panelGreen);
groupBoxAdditionalColors.Controls.Add(panelRed);
groupBoxAdditionalColors.Location = new Point(194, 26);
groupBoxAdditionalColors.Margin = new Padding(3, 2, 3, 2);
groupBoxAdditionalColors.Name = "groupBoxAdditionalColors";
groupBoxAdditionalColors.Padding = new Padding(3, 2, 3, 2);
groupBoxAdditionalColors.Size = new Size(157, 90);
groupBoxAdditionalColors.TabIndex = 8;
groupBoxAdditionalColors.TabStop = false;
groupBoxAdditionalColors.Text = "Цвета для кузова";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(116, 51);
panelPurple.Margin = new Padding(3, 2, 3, 2);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(32, 27);
panelPurple.TabIndex = 7;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(79, 51);
panelBlack.Margin = new Padding(3, 2, 3, 2);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(32, 27);
panelBlack.TabIndex = 6;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(42, 51);
panelGray.Margin = new Padding(3, 2, 3, 2);
panelGray.Name = "panelGray";
panelGray.Size = new Size(32, 27);
panelGray.TabIndex = 5;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(5, 51);
panelWhite.Margin = new Padding(3, 2, 3, 2);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(32, 27);
panelWhite.TabIndex = 4;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(116, 20);
panelYellow.Margin = new Padding(3, 2, 3, 2);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(32, 27);
panelYellow.TabIndex = 3;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(79, 20);
panelBlue.Margin = new Padding(3, 2, 3, 2);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(32, 27);
panelBlue.TabIndex = 2;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(42, 20);
panelGreen.Margin = new Padding(3, 2, 3, 2);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(32, 27);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(5, 20);
panelRed.Margin = new Padding(3, 2, 3, 2);
panelRed.Name = "panelRed";
panelRed.Size = new Size(32, 27);
panelRed.TabIndex = 0;
//
// checkBoxAwning
//
checkBoxAwning.AutoSize = true;
checkBoxAwning.Location = new Point(10, 98);
checkBoxAwning.Margin = new Padding(3, 2, 3, 2);
checkBoxAwning.Name = "checkBoxAwning";
checkBoxAwning.Size = new Size(155, 19);
checkBoxAwning.TabIndex = 7;
checkBoxAwning.Text = "Признак наличия тента";
checkBoxAwning.UseVisualStyleBackColor = true;
//
// checkBoxBodywork
//
checkBoxBodywork.AutoSize = true;
checkBoxBodywork.Location = new Point(10, 76);
checkBoxBodywork.Margin = new Padding(3, 2, 3, 2);
checkBoxBodywork.Name = "checkBoxBodywork";
checkBoxBodywork.Size = new Size(162, 19);
checkBoxBodywork.TabIndex = 6;
checkBoxBodywork.Text = "Признак наличия кузова";
checkBoxBodywork.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(82, 51);
numericUpDownWeight.Margin = new Padding(3, 2, 3, 2);
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(77, 23);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(10, 52);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(29, 15);
labelWeight.TabIndex = 4;
labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(82, 26);
numericUpDownSpeed.Margin = new Padding(3, 2, 3, 2);
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(77, 23);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(10, 28);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(62, 15);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(194, 169);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(157, 30);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(6, 167);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(153, 30);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(11, 37);
pictureBoxObject.Margin = new Padding(3, 2, 3, 2);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(216, 115);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAwning);
panelObject.Controls.Add(labelBodywork);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(387, 9);
panelObject.Margin = new Padding(3, 2, 3, 2);
panelObject.Name = "panelObject";
panelObject.Size = new Size(235, 154);
panelObject.TabIndex = 2;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelAwning
//
labelAwning.AllowDrop = true;
labelAwning.BorderStyle = BorderStyle.FixedSingle;
labelAwning.Location = new Point(162, 4);
labelAwning.Name = "labelAwning";
labelAwning.Size = new Size(66, 30);
labelAwning.TabIndex = 11;
labelAwning.Text = "Кузов";
labelAwning.TextAlign = ContentAlignment.MiddleCenter;
labelAwning.DragDrop += labelAwning_DragDrop;
labelAwning.DragEnter += labelAwning_DragEnter;
//
// labelBodywork
//
labelBodywork.AllowDrop = true;
labelBodywork.BorderStyle = BorderStyle.FixedSingle;
labelBodywork.Location = new Point(88, 4);
labelBodywork.Name = "labelBodywork";
labelBodywork.Size = new Size(69, 30);
labelBodywork.TabIndex = 10;
labelBodywork.Text = "Тент";
labelBodywork.TextAlign = ContentAlignment.MiddleCenter;
labelBodywork.DragDrop += labelBodywork_DragDrop;
labelBodywork.DragEnter += labelBodywork_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(11, 4);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(71, 30);
labelBodyColor.TabIndex = 9;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
//
// buttonAdd
//
buttonAdd.Location = new Point(387, 167);
buttonAdd.Margin = new Padding(3, 2, 3, 2);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(82, 30);
buttonAdd.TabIndex = 3;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(540, 167);
buttonCancel.Margin = new Padding(3, 2, 3, 2);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(82, 30);
buttonCancel.TabIndex = 4;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// FormTrackConfig
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(625, 208);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(panelObject);
Controls.Add(groupBoxConfig);
Margin = new Padding(3, 2, 3, 2);
Name = "FormTrackConfig";
Text = "Создание объекта";
Load += FormTrackConfig_Load;
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxAdditionalColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
panelObject.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private Label labelSimpleObject;
private Label labelModifiedObject;
private NumericUpDown numericUpDownWeight;
private Label labelWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelSpeed;
private CheckBox checkBoxBodywork;
private CheckBox checkBoxAwning;
private GroupBox groupBoxAdditionalColors;
private Panel panelRed;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelGray;
private Panel panelWhite;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private PictureBox pictureBoxObject;
private Panel panelObject;
private Button buttonAdd;
private Button buttonCancel;
private Label labelBodyColor;
private Label labelAwning;
private Label labelBodywork;
}
}

View File

@ -0,0 +1,202 @@
using ProjectDumpTrack.Drawnings;
using ProjectDumpTrack.Entities;
namespace ProjectDumpTruck
{
/// <summary>
/// Форма конфигурации объекта
/// </summary>
public partial class FormTrackConfig : Form
{
private void FormTrackConfig_Load(object sender, EventArgs e)
{
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;
}
/// <summary>
/// Объект - прорисовка автомобиля
/// </summary>
private DrawningTrack? _track;
/// <summary>
/// Событие для передачи объекта
/// </summary>
public event Action <DrawningTrack>? TrackDelegate;
/// <summary>
/// Конструктор
/// </summary>
public FormTrackConfig()
{
InitializeComponent();
buttonCancel.Click += (sender, e) =>
{
Close();
};
}
/// <summary>
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="trackDelegate"></param>
public void AddEvent(Action<DrawningTrack> trackDelegate)
{
TrackDelegate += trackDelegate;
}
/// <summary>
/// Прорисовка объекта
/// </summary>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_track?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_track?.SetPosition(15, 15);
_track?.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;
}
/// <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":
_track = new DrawningTrack((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.Aqua);
break;
case "labelModifiedObject":
_track = new DrawningDumpTrack((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
Color.Black, Color.Red, checkBoxBodywork.Checked, checkBoxAwning.Checked);
break;
}
DrawObject();
}
/// <summary>
/// Передаем информацию при нажатии на Panel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Panel_MouseDown(object? sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor ?? Color.White, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Передача объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAdd_Click(object sender, EventArgs e)
{
if (_track != null)
{
TrackDelegate?.Invoke(_track);
Close();
}
}
private void groupBoxConfig_Enter(object sender, EventArgs e)
{
}
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_track == null)
{
return;
}
Color color = (Color)e.Data.GetData(typeof(Color));
if (_track is DrawningTrack)
{
_track?.EntityTrack?.SetBodyColor(color);
}
DrawObject();
}
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
private void labelBodywork_DragDrop(object sender, DragEventArgs e)
{
if (_track == null)
{
return;
}
Color color = (Color)e.Data.GetData(typeof(Color));
if (_track is DrawningDumpTrack)
{
var dumpTrack = _track.EntityTrack as EntityDumpTrack;
dumpTrack.SetAdditionalColor(color);
}
DrawObject();
}
private void labelBodywork_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
private void labelAwning_DragDrop(object sender, DragEventArgs e)
{
if (_track == null)
{
return;
}
Color color = (Color)e.Data.GetData(typeof(Color));
if (_track is DrawningDumpTrack)
{
var dumpTrack = _track.EntityTrack as EntityDumpTrack;
dumpTrack.SetAdditionalAwningColor(color);
}
DrawObject();
}
private void labelAwning_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
}
}

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>