# Conflicts:
#	ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.Designer.cs
#	ProjectGasolineTanker/ProjectGasolineTanker/FormTankerCollection.cs
This commit is contained in:
Roman-Klemendeev 2024-05-26 22:02:03 +04:00
parent e0295b4b65
commit 0d79940c46
8 changed files with 751 additions and 221 deletions

View File

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

View File

@ -9,6 +9,8 @@ public class EntityGasolineTanker : EntityTanker
/// Дополниетльный цвет
/// </summary>
public Color AdditionalColor { get; private set; }
public void SetAdditionalColor(Color color) => AdditionalColor = color;
/// <summary>
/// Наличие безнобака
/// </summary>

View File

@ -16,6 +16,8 @@ public class EntityTanker
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
public void SetBodyColor(Color color) => BodyColor = color;
/// <summary>
/// Перемещение бензовоза
/// </summary>

View File

@ -30,94 +30,52 @@ namespace ProjectGasolineTanker
/// </summary>
private void InitializeComponent()
{
Инструменты = new GroupBox();
panelCompanyTools = new Panel();
buttonAddTanker = new Button();
buttonAddGasolineTanker = new Button();
maskedTextBoxPosition = new MaskedTextBox();
groupBoxTools = new GroupBox();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonRemoveTanker = new Button();
buttonRefresh = new Button();
buttonCreateCompany = new Button();
panelStorage = new Panel();
buttonCollectionDel = new Button();
listBoxCollection = new ListBox();
buttonCollectionAdd = new Button();
radioButtonList = new RadioButton();
radioButtonMassive = new RadioButton();
textBoxCollectionName = new TextBox();
labelCollectionName = new Label();
maskedTextBoxPosition = new MaskedTextBox();
buttonAddGasolineTanker = new Button();
buttonAddTanker = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
Инструменты.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
panelCompanyTools.SuspendLayout();
SuspendLayout();
//
// Инструменты
//
Инструменты.Controls.Add(panelCompanyTools);
Инструменты.Controls.Add(buttonCreateCompany);
Инструменты.Controls.Add(panelStorage);
Инструменты.Controls.Add(comboBoxSelectorCompany);
Инструменты.Dock = DockStyle.Right;
Инструменты.Location = new Point(861, 0);
Инструменты.Name = "Инструменты";
Инструменты.Size = new Size(225, 651);
Инструменты.TabIndex = 0;
Инструменты.TabStop = false;
Инструменты.Text = "Инструменты";
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddTanker);
panelCompanyTools.Controls.Add(buttonAddGasolineTanker);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(buttonRemoveTanker);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Location = new Point(3, 383);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(219, 265);
panelCompanyTools.TabIndex = 8;
//
// buttonAddTanker
//
buttonAddTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddTanker.Location = new Point(3, 3);
buttonAddTanker.Name = "buttonAddTanker";
buttonAddTanker.Size = new Size(213, 37);
buttonAddTanker.TabIndex = 1;
buttonAddTanker.Text = "Добавление грузовика";
buttonAddTanker.UseVisualStyleBackColor = true;
buttonAddTanker.Click += buttonAddTanker_Click;
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonGoToCheck);
groupBoxTools.Controls.Add(buttonRemoveTanker);
groupBoxTools.Controls.Add(maskedTextBoxPosition);
groupBoxTools.Controls.Add(buttonAddGasolineTanker);
groupBoxTools.Controls.Add(buttonAddTanker);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(783, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(179, 616);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonAddGasolineTanker
//
buttonAddGasolineTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddGasolineTanker.Location = new Point(3, 43);
buttonAddGasolineTanker.Name = "buttonAddGasolineTanker";
buttonAddGasolineTanker.Size = new Size(213, 37);
buttonAddGasolineTanker.TabIndex = 2;
buttonAddGasolineTanker.Text = "Добавление бензовоза\r\n";
buttonAddGasolineTanker.UseVisualStyleBackColor = true;
buttonAddGasolineTanker.Click += buttonAddGasolineTanker_Click;
//
// maskedTextBoxPosition
//
maskedTextBoxPosition.Location = new Point(3, 86);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(213, 23);
maskedTextBoxPosition.TabIndex = 3;
maskedTextBoxPosition.ValidatingType = typeof(int);
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(6, 499);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(167, 40);
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, 161);
buttonGoToCheck.Location = new Point(6, 361);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(213, 40);
buttonGoToCheck.TabIndex = 6;
@ -128,116 +86,45 @@ namespace ProjectGasolineTanker
// buttonRemoveTanker
//
buttonRemoveTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveTanker.Location = new Point(3, 115);
buttonRemoveTanker.Location = new Point(6, 251);
buttonRemoveTanker.Name = "buttonRemoveTanker";
buttonRemoveTanker.Size = new Size(213, 40);
buttonRemoveTanker.TabIndex = 4;
buttonRemoveTanker.Text = "Удаление машины";
buttonRemoveTanker.UseVisualStyleBackColor = true;
buttonRemoveTanker.Click += ButtonRemoveTanker_Click;
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(3, 207);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(213, 40);
buttonRefresh.TabIndex = 5;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
maskedTextBoxPosition.Location = new Point(6, 222);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(167, 23);
maskedTextBoxPosition.TabIndex = 3;
maskedTextBoxPosition.ValidatingType = typeof(int);
//
// buttonCreateCompany
// buttonAddGaslineTanker
//
buttonCreateCompany.Location = new Point(6, 350);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(213, 24);
buttonCreateCompany.TabIndex = 7;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
buttonCreateCompany.Click += ButtonCreateCompany_Click;
buttonAddGasolineTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddGasolineTanker.Location = new Point(6, 137);
buttonAddGasolineTanker.Name = "buttonAddGasolineTanker";
buttonAddGasolineTanker.Size = new Size(167, 40);
buttonAddGasolineTanker.TabIndex = 2;
buttonAddGasolineTanker.Text = "Добавление бензовоза";
buttonAddGasolineTanker.UseVisualStyleBackColor = true;
buttonAddGasolineTanker.Click += ButtonAddGasolineTanker_Click;
//
// panelStorage
// buttonAddTanker
//
panelStorage.Controls.Add(buttonCollectionDel);
panelStorage.Controls.Add(listBoxCollection);
panelStorage.Controls.Add(buttonCollectionAdd);
panelStorage.Controls.Add(radioButtonList);
panelStorage.Controls.Add(radioButtonMassive);
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 19);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(219, 296);
panelStorage.TabIndex = 7;
//
// buttonCollectionDel
//
buttonCollectionDel.Location = new Point(3, 267);
buttonCollectionDel.Name = "buttonCollectionDel";
buttonCollectionDel.Size = new Size(213, 24);
buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удалить коллекцию";
buttonCollectionDel.UseVisualStyleBackColor = true;
buttonCollectionDel.Click += ButtonCollectionDel_Click;
//
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 15;
listBoxCollection.Location = new Point(3, 122);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(213, 139);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
buttonCollectionAdd.Location = new Point(3, 85);
buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(213, 24);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
//
// radioButtonList
//
radioButtonList.AutoSize = true;
radioButtonList.Location = new Point(139, 60);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(66, 19);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
radioButtonList.UseVisualStyleBackColor = true;
//
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Location = new Point(19, 60);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(67, 19);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "Массив";
radioButtonMassive.UseVisualStyleBackColor = true;
//
// textBoxCollectionName
//
textBoxCollectionName.Location = new Point(3, 31);
textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(213, 23);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
labelCollectionName.Location = new Point(47, 13);
labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(125, 15);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции:";
buttonAddTanker.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddTanker.Location = new Point(6, 91);
buttonAddTanker.Name = "buttonAddTanker";
buttonAddTanker.Size = new Size(167, 40);
buttonAddTanker.TabIndex = 1;
buttonAddTanker.Text = "Добавление грузовика";
buttonAddTanker.UseVisualStyleBackColor = true;
buttonAddTanker.Click += ButtonAddTanker_Click;
//
// comboBoxSelectorCompany
//
@ -245,7 +132,7 @@ namespace ProjectGasolineTanker
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(6, 321);
comboBoxSelectorCompany.Location = new Point(6, 22);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(213, 23);
comboBoxSelectorCompany.TabIndex = 0;
@ -260,6 +147,20 @@ namespace ProjectGasolineTanker
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddTanker);
panelCompanyTools.Controls.Add(maskedTextBoxPosition);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonRemoveTanker);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Dock = DockStyle.Bottom;
panelCompanyTools.Enabled = false;
panelCompanyTools.Location = new Point(3, 360);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(173, 253);
panelCompanyTools.TabIndex = 9;
//
// FormTankerCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
@ -268,13 +169,13 @@ namespace ProjectGasolineTanker
Controls.Add(pictureBox);
Controls.Add(Инструменты);
Name = "FormTankerCollection";
Text = "Коллекция лодок";
Инструменты.ResumeLayout(false);
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
Text = "Коллекция автомобилей";
groupBoxTools.ResumeLayout(false);
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
panelCompanyTools.ResumeLayout(false);
panelCompanyTools.PerformLayout();
ResumeLayout(false);
}
@ -284,20 +185,13 @@ namespace ProjectGasolineTanker
private Button buttonAddTanker;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddGasolineTanker;
private Button buttonAddTanker;
private Button buttonRemoveTanker;
private MaskedTextBox maskedTextBoxPosition;
private PictureBox pictureBox;
private Button buttonRefresh;
private Button buttonRemoveTanker;
private Button buttonGoToCheck;
private Panel panelStorage;
private Label labelCollectionName;
private RadioButton radioButtonMassive;
private TextBox textBoxCollectionName;
private Button buttonCollectionDel;
private ListBox listBoxCollection;
private Button buttonCollectionAdd;
private RadioButton radioButtonList;
private Button buttonCreateCompany;
private Panel panelCompanyTools;
private Button buttonRefresh;
}
}

View File

@ -43,31 +43,32 @@ public partial class FormTankerCollection : Form
}
}
/// <summary>
/// Добавление обычного автомобиля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTanker));
/// <summary>
/// Добавление спортивного автомобиля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddGasolineTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningGasolineTanker));
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{
if (_company == null)
if (_company == null || tank == null)
{
return;
}
DrawningTanker _drawningTanker;
Random random = new();
switch (type)
{
case nameof(DrawningTanker):
_drawningTanker = new DrawningTanker(random.Next(30, 70), random.Next(100, 500),
GetColor(random));
break;
case nameof(DrawningGasolineTanker):
_drawningTanker = new DrawningGasolineTanker(random.Next(30, 70), random.Next(100, 500),
GetColor(random), GetColor(random),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + _drawningTanker != -1)
if (_company + tank != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -79,25 +80,11 @@ public partial class FormTankerCollection : Form
}
/// <summary>
/// Добавление обычного автомобиля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTanker));
/// <summary>
/// Добавление спортивного автомобиля
/// Получение цвета
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddGasolineTanker_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningGasolineTanker));
/// <summary>
/// Получение цвета
/// </summary>
/// <param name="random">Генератор случайных чисел</param>
/// <returns></returns>
private static Color GetColor(Random random)
/// <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();

View File

@ -0,0 +1,357 @@
namespace ProjectGasolineTanker
{
partial class FormTankerConfig
{
/// <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();
panelYellow = new Panel();
panelBlack = new Panel();
panelGray = new Panel();
panelBlue = new Panel();
panelWhite = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxSignalbeacon = new CheckBox();
checkBoxTanker = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
labelWeight = new Label();
labelSpeed = new Label();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
panelObject = new Panel();
labelAdditionalColor = new Label();
labelBodyColor = new Label();
pictureBoxObject = new PictureBox();
buttonAdd = new Button();
buttonCancel = new Button();
groupBoxConfig.SuspendLayout();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(groupBoxColors);
groupBoxConfig.Controls.Add(checkBoxSignalbeacon);
groupBoxConfig.Controls.Add(checkBoxTanker);
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(574, 219);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelPurple);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlack);
groupBoxColors.Controls.Add(panelGray);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(315, 12);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(227, 112);
groupBoxColors.TabIndex = 10;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(176, 66);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(34, 34);
panelPurple.TabIndex = 3;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(176, 22);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(34, 34);
panelYellow.TabIndex = 1;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(120, 66);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(34, 34);
panelBlack.TabIndex = 4;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(67, 66);
panelGray.Name = "panelGray";
panelGray.Size = new Size(34, 34);
panelGray.TabIndex = 5;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(120, 22);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(34, 34);
panelBlue.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(15, 66);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(34, 34);
panelWhite.TabIndex = 2;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(67, 22);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(34, 34);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(15, 22);
panelRed.Name = "panelRed";
panelRed.Size = new Size(34, 34);
panelRed.TabIndex = 0;
//
// checkBoxSignalbeacon
//
checkBoxSignalbeacon.AutoSize = true;
checkBoxSignalbeacon.Location = new Point(12, 168);
checkBoxSignalbeacon.Name = "checkBoxSignalbeacon";
checkBoxSignalbeacon.Size = new Size(232, 34);
checkBoxSignalbeacon.TabIndex = 9;
checkBoxSignalbeacon.Text = "Признак наличия сигнального маяка\r\n\r\n";
checkBoxSignalbeacon.UseVisualStyleBackColor = true;
//
// checkBoxTanker
//
checkBoxTanker.AutoSize = true;
checkBoxTanker.Location = new Point(12, 125);
checkBoxTanker.Name = "checkBoxTanker";
checkBoxTanker.Size = new Size(154, 19);
checkBoxTanker.TabIndex = 8;
checkBoxTanker.Text = "Признак наличия бака \r\n";
checkBoxTanker.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(80, 65);
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(96, 23);
numericUpDownWeight.TabIndex = 7;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(80, 36);
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(96, 23);
numericUpDownSpeed.TabIndex = 6;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(12, 73);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(29, 15);
labelWeight.TabIndex = 5;
labelWeight.Text = "Вес:";
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(12, 38);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(62, 15);
labelSpeed.TabIndex = 3;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(442, 160);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(100, 33);
labelModifiedObject.TabIndex = 2;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(315, 160);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(100, 33);
labelSimpleObject.TabIndex = 1;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(594, 0);
panelObject.Name = "panelObject";
panelObject.Size = new Size(194, 164);
panelObject.TabIndex = 5;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(108, 9);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(75, 33);
labelAdditionalColor.TabIndex = 3;
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(13, 9);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(75, 33);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(13, 52);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(170, 99);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// buttonAdd
//
buttonAdd.Location = new Point(607, 184);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(702, 184);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// FormTankerConfig
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 219);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(panelObject);
Controls.Add(groupBoxConfig);
Name = "FormTankerConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
panelObject.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelWeight;
private Label labelSpeed;
private Label labelModifiedObject;
private Label labelSimpleObject;
private CheckBox checkBoxTanker;
private CheckBox checkBoxSignalbeacon;
private GroupBox groupBoxColors;
private Panel panelPurple;
private Panel panelYellow;
private Panel panelBlack;
private Panel panelGray;
private Panel panelBlue;
private Panel panelWhite;
private Panel panelGreen;
private Panel panelRed;
private Panel panelObject;
private Label labelAdditionalColor;
private Label labelBodyColor;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,160 @@
using ProjectGasolineTanker.Drawnings;
using ProjectGasolineTanker.Entities;
namespace ProjectGasolineTanker;
public partial class FormTankerConfig : Form
{
private DrawningTanker? _tanker = null;
private event Action<DrawningTanker>? _TankerDelegate;
public FormTankerConfig()
{
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>
/// <param name="tankerDelegate"></param>
public void AddEvent(Action<DrawningTanker> TankerDelegate)
{
_TankerDelegate += TankerDelegate;
}
/// <summary>
/// Прорисовка объекта
/// </summary>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_tanker?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_tanker?.SetPosition(15, 15);
_tanker?.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":
_tanker = new DrawningTanker((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
_tanker = new DrawningGasolineTanker((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
Color.Black, checkBoxTanker.Checked, checkBoxSignalbeacon.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)
{
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor ?? Color.Black, DragDropEffects.Move | DragDropEffects.Copy);
}
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_tanker != null)
{
_tanker.EntityTanker.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
}
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (_tanker is DrawningGasolineTanker)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_tanker?.EntityTanker is EntityGasolineTanker _gasolinetanker)
{
_gasolinetanker.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 (_tanker != null)
{
_TankerDelegate?.Invoke(_tanker);
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>