Для сдачи

This commit is contained in:
Samecoins 2024-05-13 09:59:48 +04:00
parent e3e5ebdb58
commit 05ce3a4b36
8 changed files with 765 additions and 138 deletions

View File

@ -9,11 +9,19 @@ public class EntityDumpTruck : EntityTruck
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; private set; }
public void SetAdditionalColor(Color color)
{
AdditionalColor = color;
}
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color Additional2Color { get; private set; }
public void SetAdditional2Color(Color color)
{
Additional2Color = color;
}
/// <summary>
/// Признак (опция) наличия кузова
@ -36,7 +44,7 @@ public class EntityDumpTruck : EntityTruck
/// <param name="bodywork">Признак наличия кузова</param>
/// <param name="awning">Признак наличия тента</param>
public EntityDumpTruck(int speed, double weight, Color bodyColor, Color additionalColor, Color additional2Color, bool bodywork, bool awning) : base(speed, weight, bodyColor)
public EntityDumpTruck(int speed, double weight, Color bodyColor, Color additionalColor, Color additional2Color, bool bodywork, bool awning) : base(5, 45, bodyColor)
{
AdditionalColor = additionalColor;
Additional2Color = additional2Color;

View File

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

View File

@ -29,6 +29,12 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonAddTruck = new Button();
maskedTextBoxPosition = new MaskedTextBox();
buttonRefresh = new Button();
buttonRemoveTruck = new Button();
buttonGoToCheck = 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();
buttonRemoveTruck = new Button();
maskedTextBoxPosition = new MaskedTextBox();
buttonAddDumpTruck = new Button();
buttonAddTruck = 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,74 @@
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Интсрументы";
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddTruck);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonRemoveTruck);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 381);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(173, 276);
panelCompanyTools.TabIndex = 8;
//
// buttonAddTruck
//
buttonAddTruck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddTruck.Location = new Point(3, 3);
buttonAddTruck.Name = "buttonAddTruck";
buttonAddTruck.Size = new Size(167, 42);
buttonAddTruck.TabIndex = 1;
buttonAddTruck.Text = "Добавить грузовик";
buttonAddTruck.UseVisualStyleBackColor = true;
buttonAddTruck.Click += ButtonAddTruck_Click;
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
maskedTextBoxPosition.Location = new Point(3, 99);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(167, 23);
maskedTextBoxPosition.TabIndex = 3;
maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(3, 224);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(167, 42);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonRemoveTruck
//
buttonRemoveTruck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveTruck.Location = new Point(3, 128);
buttonRemoveTruck.Name = "buttonRemoveTruck";
buttonRemoveTruck.Size = new Size(167, 42);
buttonRemoveTruck.TabIndex = 4;
buttonRemoveTruck.Text = "Удалить грузовик";
buttonRemoveTruck.UseVisualStyleBackColor = true;
buttonRemoveTruck.Click += ButtonRemoveTruck_Click;
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(3, 176);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(167, 42);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Отправить на проверку";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(6, 307);
@ -159,71 +226,6 @@
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции: ";
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(3, 224);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(167, 42);
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(3, 176);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(167, 42);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Отправить на проверку";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// buttonRemoveTruck
//
buttonRemoveTruck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveTruck.Location = new Point(3, 128);
buttonRemoveTruck.Name = "buttonRemoveTruck";
buttonRemoveTruck.Size = new Size(167, 42);
buttonRemoveTruck.TabIndex = 4;
buttonRemoveTruck.Text = "Удалить грузовик";
buttonRemoveTruck.UseVisualStyleBackColor = true;
buttonRemoveTruck.Click += ButtonRemoveTruck_Click;
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
maskedTextBoxPosition.Location = new Point(3, 99);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(167, 23);
maskedTextBoxPosition.TabIndex = 3;
maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonAddDumpTruck
//
buttonAddDumpTruck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddDumpTruck.Location = new Point(3, 51);
buttonAddDumpTruck.Name = "buttonAddDumpTruck";
buttonAddDumpTruck.Size = new Size(167, 42);
buttonAddDumpTruck.TabIndex = 2;
buttonAddDumpTruck.Text = "Добавить самосвал";
buttonAddDumpTruck.UseVisualStyleBackColor = true;
buttonAddDumpTruck.Click += ButtonAddDumpTruck_Click;
//
// buttonAddTruck
//
buttonAddTruck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddTruck.Location = new Point(3, 3);
buttonAddTruck.Name = "buttonAddTruck";
buttonAddTruck.Size = new Size(167, 42);
buttonAddTruck.TabIndex = 1;
buttonAddTruck.Text = "Добавить грузовик";
buttonAddTruck.UseVisualStyleBackColor = true;
buttonAddTruck.Click += ButtonAddTruck_Click;
//
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@ -245,21 +247,6 @@
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddTruck);
panelCompanyTools.Controls.Add(buttonAddDumpTruck);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonRemoveTruck);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 381);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(173, 276);
panelCompanyTools.TabIndex = 8;
//
// FormTruckCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
@ -270,11 +257,11 @@
Name = "FormTruckCollection";
Text = "FormTruckCollection";
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);
}
@ -284,7 +271,6 @@
private Button buttonAddTruck;
private ComboBox comboBoxSelectorCompany;
private MaskedTextBox maskedTextBoxPosition;
private Button buttonAddDumpTruck;
private PictureBox pictureBox;
private Button buttonRefresh;
private Button buttonGoToCheck;

View File

@ -38,33 +38,35 @@ public partial class FormTruckCollection : Form
panelCompanyTools.Enabled = false;
}
/// <summary>
/// Создание объекта класса-перемещения
/// Добавление грузовика
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddTruck_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
FormTruckConfig form = new();
form.TruckDelegate += SetTruck;
form.Show();
}
Random random = new();
DrawningTruck drawningTruck;
switch (type)
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void SetTruck(DrawningTruck truck)
{
if (_company == null || truck == null)
{
case nameof(DrawningTruck):
drawningTruck = new DrawningTruck(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningDumpTruck):
// TODO Выбор цвета
drawningTruck = new DrawningDumpTruck(random.Next(100, 300), random.Next(1000, 3000), GetColor(random), GetColor(random), GetColor(random),
Convert.ToBoolean(random.Next(2, 2)), Convert.ToBoolean(random.Next(1, 2)));
break;
default:
return;
}
if (_company + drawningTruck != -1)
if (_company + truck != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -75,36 +77,7 @@ public partial class FormTruckCollection : 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>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddTruck_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTruck));
/// <summary>
/// Добавление самосвала
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddDumpTruck_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningDumpTruck));
/// <summary>
/// Удаление объекта

View File

@ -0,0 +1,358 @@
namespace ProjectDumpTruck
{
partial class FormTruckConfig
{
/// <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();
groupBoxColors = 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();
labelModifiedObject = new Label();
numericUpDownWeight = new NumericUpDown();
labelSimpleObject = new Label();
labelWeight = new Label();
numericUpDownSpeed = new NumericUpDown();
labelSpeed = new Label();
pictureBoxObject = new PictureBox();
buttonAdd = new Button();
buttonCancel = new Button();
panelObject = new Panel();
labelAdditionalColor = new Label();
labelBodyColor = new Label();
groupBoxConfig.SuspendLayout();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
panelObject.SuspendLayout();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(groupBoxColors);
groupBoxConfig.Controls.Add(checkBoxAwning);
groupBoxConfig.Controls.Add(checkBoxBodywork);
groupBoxConfig.Controls.Add(labelModifiedObject);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(labelSimpleObject);
groupBoxConfig.Controls.Add(labelWeight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(labelSpeed);
groupBoxConfig.Dock = DockStyle.Left;
groupBoxConfig.Location = new Point(0, 0);
groupBoxConfig.Name = "groupBoxConfig";
groupBoxConfig.Size = new Size(552, 344);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelPurple);
groupBoxColors.Controls.Add(panelBlack);
groupBoxColors.Controls.Add(panelGray);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(238, 53);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(284, 146);
groupBoxColors.TabIndex = 6;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(214, 95);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(45, 45);
panelPurple.TabIndex = 1;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(142, 95);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(45, 45);
panelBlack.TabIndex = 1;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(87, 95);
panelGray.Name = "panelGray";
panelGray.Size = new Size(45, 45);
panelGray.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(16, 95);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(45, 45);
panelWhite.TabIndex = 1;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(214, 34);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(45, 45);
panelYellow.TabIndex = 1;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(142, 34);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(45, 45);
panelBlue.TabIndex = 1;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(87, 34);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(45, 45);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(16, 34);
panelRed.Name = "panelRed";
panelRed.Size = new Size(45, 45);
panelRed.TabIndex = 0;
panelRed.MouseDown += Panel_MouseDown;
//
// checkBoxAwning
//
checkBoxAwning.AutoSize = true;
checkBoxAwning.Location = new Point(21, 180);
checkBoxAwning.Name = "checkBoxAwning";
checkBoxAwning.Size = new Size(155, 19);
checkBoxAwning.TabIndex = 5;
checkBoxAwning.Text = "Признак наличия тента";
checkBoxAwning.UseVisualStyleBackColor = true;
//
// checkBoxBodywork
//
checkBoxBodywork.AutoSize = true;
checkBoxBodywork.Location = new Point(20, 146);
checkBoxBodywork.Name = "checkBoxBodywork";
checkBoxBodywork.Size = new Size(162, 19);
checkBoxBodywork.TabIndex = 4;
checkBoxBodywork.Text = "Признак наличия кузова";
checkBoxBodywork.UseVisualStyleBackColor = true;
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(325, 286);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(100, 23);
labelModifiedObject.TabIndex = 2;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(94, 109);
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(120, 23);
numericUpDownWeight.TabIndex = 3;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(219, 286);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(100, 23);
labelSimpleObject.TabIndex = 1;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(20, 111);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(35, 15);
labelWeight.TabIndex = 2;
labelWeight.Text = "Вес : ";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(94, 74);
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(120, 23);
numericUpDownSpeed.TabIndex = 1;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(20, 76);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(68, 15);
labelSpeed.TabIndex = 0;
labelSpeed.Text = "Скорость : ";
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(15, 46);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(195, 175);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// buttonAdd
//
buttonAdd.Location = new Point(573, 256);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(693, 261);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 3;
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(558, 12);
panelObject.Name = "panelObject";
panelObject.Size = new Size(230, 238);
panelObject.TabIndex = 4;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(121, 10);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(100, 23);
labelAdditionalColor.TabIndex = 7;
labelAdditionalColor.Text = "Доп цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(15, 10);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(100, 23);
labelBodyColor.TabIndex = 7;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += LabelBodyColor_DragDrop;
labelBodyColor.DragEnter += LabelBodyColor_DragEnter;
//
// FormTruckConfig
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 344);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
Name = "FormTruckConfig";
Text = "FormTruckConfig";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColors.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 labelWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelSpeed;
private Label labelModifiedObject;
private CheckBox checkBoxBodywork;
private NumericUpDown numericUpDownWeight;
private CheckBox checkBoxAwning;
private GroupBox groupBoxColors;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelGray;
private Panel panelWhite;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private Panel panelRed;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
private Panel panelObject;
private Label labelAdditionalColor;
private Label labelBodyColor;
}
}

View File

@ -0,0 +1,169 @@
using ProjectDumpTruck.Drawnings;
using ProjectDumpTruck.Entities;
namespace ProjectDumpTruck;
/// <summary>
/// Форма конфигурации объекта
/// </summary>
public partial class FormTruckConfig : Form
{
/// <summary>
/// Объект - прорисовка
/// </summary>
private DrawningTruck? _truck;
/// <summary>
/// Констурктор
/// </summary>
public FormTruckConfig()
{
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;
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Событие для передачи объекта
/// </summary>
public event Action<DrawningTruck>? TruckDelegate;
// <summary>
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="trackDelegate"></param>
public void AddEvent(Action<DrawningTruck> truckDelegate)
{
TruckDelegate += truckDelegate;
}
/// <summary>
/// Прорисовка объекта
/// </summary>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_truck?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_truck?.SetPosition(15, 15);
_truck?.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":
_truck = new DrawningTruck((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.Aqua);
break;
case "labelModifiedObject":
_truck = new DrawningDumpTruck((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, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Передача объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAdd_Click(object sender, EventArgs e)
{
if (_truck != null)
{
TruckDelegate?.Invoke(_truck);
Close();
}
}
private void LabelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_truck == null)
{
return;
}
Color color = (Color)e.Data.GetData(typeof(Color));
if (_truck is DrawningTruck)
{
_truck?.EntityTruck?.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 LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_truck == null)
{
return;
}
Color color = (Color)e.Data.GetData(typeof(Color));
if (_truck is DrawningDumpTruck)
{
var dumpTruck = _truck.EntityTruck as EntityDumpTruck;
dumpTruck.SetAdditionalColor(color);
}
DrawObject();
}
private void LabelAdditionalColor_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>

View File

@ -0,0 +1,9 @@
using ProjectDumpTruck.Drawnings;
namespace ProjectDumpTruck;
/// <summary>
/// Делегат передачи объекта класса-прорисовки
/// </summary>
/// <param name="truck"></param>
public delegate void TruckDelegate(DrawningTruck truck);