Compare commits

..

No commits in common. "de6a24973917200e1d62bb8d0c0cc34f81c2da99" and "9164ec396fa9230b70cf06477f5b73b21f251cf8" have entirely different histories.

7 changed files with 412 additions and 511 deletions

View File

@ -95,10 +95,5 @@ namespace ProjectTractor.DrawningObjects
}
}
public void ChangeAdditionalColor(Color color)
{
((EntityBulldoser)EntityTractor).AdditionalColor = color;
}
}
}

View File

@ -6,11 +6,13 @@ using System.Threading.Tasks;
using ProjectTractor.Entities;
using ProjectTractor.MovementStrategy;
namespace ProjectTractor.DrawningObjects {
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningTractor {
namespace ProjectTractor.DrawningObjects {
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningTractor
{
/// <summary>
/// Класс-сущность
/// </summary>
@ -39,16 +41,15 @@ namespace ProjectTractor.DrawningObjects {
/// Высота прорисовки автомобиля
/// </summary>
protected readonly int _tractorHeight = 60;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public DrawningTractor(int speed, double weight, Color bodyColor, int
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public DrawningTractor(int speed, double weight, Color bodyColor, int
width, int height)
{
if (width <= _tractorWidth || height <= _tractorHeight)
@ -227,22 +228,7 @@ namespace ProjectTractor.DrawningObjects {
g.DrawRectangle(pen, _startPosX + 60, _startPosY, 10, 20);
g.DrawRectangle(pen, _startPosX, _startPosY, 40, 20);
}
public void ChangeColor(Color color)
{
if (EntityTractor == null)
{
return;
}
EntityTractor.BodyColor = color;
}
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
{
_pictureWidth = pictureBoxWidth;
_pictureHeight = pictureBoxHeight;
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace ProjectTractor.Entities
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; set; }
public Color AdditionalColor { get; private set; }
/// <summary>
/// Признак (опция) наличия обвеса
/// </summary>

View File

@ -22,7 +22,7 @@ namespace ProjectTractor.Entities
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; set; }
public Color BodyColor { get; private set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>
@ -39,5 +39,6 @@ namespace ProjectTractor.Entities
Weight = weight;
BodyColor = bodyColor;
}
}
}

View File

@ -73,7 +73,7 @@ namespace ProjectTractor
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void listBoxStorages_SelectedIndexChanged(object sender,
private void ListBoxObjects_SelectedIndexChanged(object sender,
EventArgs e)
{
pictureBoxCollection.Image =
@ -113,24 +113,19 @@ namespace ProjectTractor
{
return;
}
FormTractorConfig form = new();
form.Show();
Action<DrawningTractor>? tractorDelegate = new((m) =>
FormTractor form = new();
if (form.ShowDialog() == DialogResult.OK)
{
bool isAdditionSuccessful = (obj + m);
if (isAdditionSuccessful)
if (obj + form.SelectedTractor)
{
MessageBox.Show("Объект добавлен");
m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
pictureBoxCollection.Image = obj.ShowTractors();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
});
form.AddEvent(tractorDelegate);
}
}
/// <summary>
@ -185,6 +180,7 @@ namespace ProjectTractor
}
pictureBoxCollection.Image = obj.ShowTractors();
}
private void InitializeComponent()
{
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
@ -257,7 +253,6 @@ namespace ProjectTractor
this.listBoxStorages.Name = "listBoxStorages";
this.listBoxStorages.Size = new System.Drawing.Size(203, 84);
this.listBoxStorages.TabIndex = 2;
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxStorages_SelectedIndexChanged);
//
// ButtonAddObject
//
@ -343,5 +338,7 @@ namespace ProjectTractor
private Button ButtonAddObject;
private MaskedTextBox textBoxStorageName;
private PictureBox pictureBoxCollection;
}
}

View File

@ -28,204 +28,197 @@
/// </summary>
private void InitializeComponent()
{
this.groupBoxConfig = new System.Windows.Forms.GroupBox();
this.labelModifiedObject = new System.Windows.Forms.Label();
this.labelSimpleObject = new System.Windows.Forms.Label();
this.groupBoxColors = new System.Windows.Forms.GroupBox();
this.panelPurpule = new System.Windows.Forms.Panel();
this.panelBlack = new System.Windows.Forms.Panel();
this.panelGrey = new System.Windows.Forms.Panel();
this.panelYellow = new System.Windows.Forms.Panel();
this.panelBlue = new System.Windows.Forms.Panel();
this.panelWhite = new System.Windows.Forms.Panel();
this.panelGreen = new System.Windows.Forms.Panel();
this.panelRed = new System.Windows.Forms.Panel();
this.checkBoxBlade = new System.Windows.Forms.CheckBox();
this.checkBoxWheelsOrnament = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.panel18 = new System.Windows.Forms.Panel();
this.panel19 = new System.Windows.Forms.Panel();
this.panel20 = new System.Windows.Forms.Panel();
this.panel21 = new System.Windows.Forms.Panel();
this.panel14 = new System.Windows.Forms.Panel();
this.panel22 = new System.Windows.Forms.Panel();
this.panel10 = new System.Windows.Forms.Panel();
this.panel26 = new System.Windows.Forms.Panel();
this.panel6 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.buttonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.labelColor = new System.Windows.Forms.Label();
this.labelAdditionalColor = new System.Windows.Forms.Label();
this.panelObject = new System.Windows.Forms.Panel();
this.groupBoxConfig.SuspendLayout();
this.groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.panelObject.SuspendLayout();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.panel16 = new System.Windows.Forms.Panel();
this.panel17 = new System.Windows.Forms.Panel();
this.panel24 = new System.Windows.Forms.Panel();
this.panel25 = new System.Windows.Forms.Panel();
this.panel12 = new System.Windows.Forms.Panel();
this.panel13 = new System.Windows.Forms.Panel();
this.panel28 = new System.Windows.Forms.Panel();
this.panel29 = new System.Windows.Forms.Panel();
this.panel5 = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.panel8 = new System.Windows.Forms.Panel();
this.panel9 = new System.Windows.Forms.Panel();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.panel18.SuspendLayout();
this.panel19.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// groupBoxConfig
// groupBox1
//
this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
this.groupBoxConfig.Controls.Add(this.checkBoxBlade);
this.groupBoxConfig.Controls.Add(this.checkBoxWheelsOrnament);
this.groupBoxConfig.Controls.Add(this.label2);
this.groupBoxConfig.Controls.Add(this.label1);
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
this.groupBoxConfig.Location = new System.Drawing.Point(12, 0);
this.groupBoxConfig.Name = "groupBoxConfig";
this.groupBoxConfig.Size = new System.Drawing.Size(585, 256);
this.groupBoxConfig.TabIndex = 0;
this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры";
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Controls.Add(this.checkBox2);
this.groupBox1.Controls.Add(this.checkBox1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.numericUpDown2);
this.groupBox1.Controls.Add(this.numericUpDown1);
this.groupBox1.Location = new System.Drawing.Point(12, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(585, 341);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// labelModifiedObject
// groupBox2
//
this.labelModifiedObject.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(449, 171);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(114, 42);
this.labelModifiedObject.TabIndex = 8;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
this.groupBox2.Controls.Add(this.panel18);
this.groupBox2.Controls.Add(this.panel14);
this.groupBox2.Controls.Add(this.panel22);
this.groupBox2.Controls.Add(this.panel10);
this.groupBox2.Controls.Add(this.panel26);
this.groupBox2.Controls.Add(this.panel6);
this.groupBox2.Controls.Add(this.panel2);
this.groupBox2.Controls.Add(this.panel1);
this.groupBox2.Location = new System.Drawing.Point(369, 28);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(194, 120);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "groupBox2";
//
// labelSimpleObject
// panel18
//
this.labelSimpleObject.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(369, 171);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(74, 42);
this.labelSimpleObject.TabIndex = 7;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
this.panel18.BackColor = System.Drawing.Color.Purple;
this.panel18.Controls.Add(this.panel19);
this.panel18.Location = new System.Drawing.Point(144, 69);
this.panel18.Name = "panel18";
this.panel18.Size = new System.Drawing.Size(40, 40);
this.panel18.TabIndex = 1;
//
// groupBoxColors
// panel19
//
this.groupBoxColors.Controls.Add(this.panelPurpule);
this.groupBoxColors.Controls.Add(this.panelBlack);
this.groupBoxColors.Controls.Add(this.panelGrey);
this.groupBoxColors.Controls.Add(this.panelYellow);
this.groupBoxColors.Controls.Add(this.panelBlue);
this.groupBoxColors.Controls.Add(this.panelWhite);
this.groupBoxColors.Controls.Add(this.panelGreen);
this.groupBoxColors.Controls.Add(this.panelRed);
this.groupBoxColors.Location = new System.Drawing.Point(369, 28);
this.groupBoxColors.Name = "groupBoxColors";
this.groupBoxColors.Size = new System.Drawing.Size(194, 120);
this.groupBoxColors.TabIndex = 6;
this.groupBoxColors.TabStop = false;
this.groupBoxColors.Text = "Цвета";
this.panel19.Controls.Add(this.panel20);
this.panel19.Controls.Add(this.panel21);
this.panel19.Location = new System.Drawing.Point(96, 0);
this.panel19.Name = "panel19";
this.panel19.Size = new System.Drawing.Size(40, 40);
this.panel19.TabIndex = 0;
//
// panelPurpule
// panel20
//
this.panelPurpule.AllowDrop = true;
this.panelPurpule.BackColor = System.Drawing.Color.Purple;
this.panelPurpule.Location = new System.Drawing.Point(144, 69);
this.panelPurpule.Name = "panelPurpule";
this.panelPurpule.Size = new System.Drawing.Size(40, 40);
this.panelPurpule.TabIndex = 1;
this.panelPurpule.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelPurpule.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
this.panel20.Location = new System.Drawing.Point(46, 0);
this.panel20.Name = "panel20";
this.panel20.Size = new System.Drawing.Size(40, 40);
this.panel20.TabIndex = 0;
//
// panelBlack
// panel21
//
this.panelBlack.AllowDrop = true;
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(98, 69);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(40, 40);
this.panelBlack.TabIndex = 1;
this.panelBlack.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
this.panel21.Location = new System.Drawing.Point(0, 0);
this.panel21.Name = "panel21";
this.panel21.Size = new System.Drawing.Size(40, 40);
this.panel21.TabIndex = 0;
//
// panelGrey
// panel14
//
this.panelGrey.AllowDrop = true;
this.panelGrey.BackColor = System.Drawing.Color.Silver;
this.panelGrey.Location = new System.Drawing.Point(52, 69);
this.panelGrey.Name = "panelGrey";
this.panelGrey.Size = new System.Drawing.Size(40, 40);
this.panelGrey.TabIndex = 1;
this.panelGrey.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelGrey.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
this.panel14.BackColor = System.Drawing.Color.Black;
this.panel14.Location = new System.Drawing.Point(98, 69);
this.panel14.Name = "panel14";
this.panel14.Size = new System.Drawing.Size(40, 40);
this.panel14.TabIndex = 1;
//
// panelYellow
// panel22
//
this.panelYellow.AllowDrop = true;
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Location = new System.Drawing.Point(145, 23);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(40, 40);
this.panelYellow.TabIndex = 1;
this.panelYellow.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
this.panel22.BackColor = System.Drawing.Color.Silver;
this.panel22.Location = new System.Drawing.Point(52, 69);
this.panel22.Name = "panel22";
this.panel22.Size = new System.Drawing.Size(40, 40);
this.panel22.TabIndex = 1;
//
// panelBlue
// panel10
//
this.panelBlue.AllowDrop = true;
this.panelBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.panelBlue.Location = new System.Drawing.Point(98, 23);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(40, 40);
this.panelBlue.TabIndex = 1;
this.panelBlue.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
this.panel10.BackColor = System.Drawing.Color.Yellow;
this.panel10.Location = new System.Drawing.Point(145, 23);
this.panel10.Name = "panel10";
this.panel10.Size = new System.Drawing.Size(40, 40);
this.panel10.TabIndex = 1;
//
// panelWhite
// panel26
//
this.panelWhite.AllowDrop = true;
this.panelWhite.BackColor = System.Drawing.Color.White;
this.panelWhite.Location = new System.Drawing.Point(6, 69);
this.panelWhite.Name = "panelWhite";
this.panelWhite.Size = new System.Drawing.Size(40, 40);
this.panelWhite.TabIndex = 1;
this.panelWhite.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
this.panel26.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.panel26.Location = new System.Drawing.Point(98, 23);
this.panel26.Name = "panel26";
this.panel26.Size = new System.Drawing.Size(40, 40);
this.panel26.TabIndex = 1;
//
// panelGreen
// panel6
//
this.panelGreen.AllowDrop = true;
this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.panelGreen.Location = new System.Drawing.Point(52, 23);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(40, 40);
this.panelGreen.TabIndex = 0;
this.panelGreen.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
this.panel6.BackColor = System.Drawing.Color.White;
this.panel6.Location = new System.Drawing.Point(6, 69);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(40, 40);
this.panel6.TabIndex = 1;
//
// panelRed
// panel2
//
this.panelRed.AllowDrop = true;
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Location = new System.Drawing.Point(6, 23);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(40, 40);
this.panelRed.TabIndex = 0;
this.panelRed.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelColor_MouseDown);
this.panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.panel2.Location = new System.Drawing.Point(52, 23);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(40, 40);
this.panel2.TabIndex = 0;
//
// checkBoxBlade
// panel1
//
this.checkBoxBlade.AutoSize = true;
this.checkBoxBlade.Location = new System.Drawing.Point(32, 154);
this.checkBoxBlade.Name = "checkBoxBlade";
this.checkBoxBlade.Size = new System.Drawing.Size(205, 24);
this.checkBoxBlade.TabIndex = 5;
this.checkBoxBlade.Text = "Признак наличия отвала";
this.checkBoxBlade.UseVisualStyleBackColor = true;
this.panel1.BackColor = System.Drawing.Color.Red;
this.panel1.Location = new System.Drawing.Point(6, 23);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(40, 40);
this.panel1.TabIndex = 0;
//
// checkBoxWheelsOrnament
// checkBox2
//
this.checkBoxWheelsOrnament.AutoSize = true;
this.checkBoxWheelsOrnament.Location = new System.Drawing.Point(32, 189);
this.checkBoxWheelsOrnament.Name = "checkBoxWheelsOrnament";
this.checkBoxWheelsOrnament.Size = new System.Drawing.Size(305, 24);
this.checkBoxWheelsOrnament.TabIndex = 4;
this.checkBoxWheelsOrnament.Text = "Признак наличия орнамета на колесах";
this.checkBoxWheelsOrnament.UseVisualStyleBackColor = true;
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(32, 227);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(205, 24);
this.checkBox2.TabIndex = 5;
this.checkBox2.Text = "Признак наличия отвала";
this.checkBox2.UseVisualStyleBackColor = true;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(32, 286);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(305, 24);
this.checkBox1.TabIndex = 4;
this.checkBox1.Text = "Признак наличия орнамета на колесах";
this.checkBox1.UseVisualStyleBackColor = true;
//
// label2
//
@ -245,166 +238,255 @@
this.label1.TabIndex = 2;
this.label1.Text = "Скорость";
//
// numericUpDownWeight
// numericUpDown2
//
this.numericUpDownWeight.Location = new System.Drawing.Point(132, 80);
this.numericUpDownWeight.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownWeight.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(109, 27);
this.numericUpDownWeight.TabIndex = 1;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDown2.Location = new System.Drawing.Point(132, 80);
this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(109, 27);
this.numericUpDown2.TabIndex = 1;
//
// numericUpDownSpeed
// numericUpDown1
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(132, 26);
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(109, 27);
this.numericUpDownSpeed.TabIndex = 0;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDown1.Location = new System.Drawing.Point(132, 26);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(109, 27);
this.numericUpDown1.TabIndex = 0;
//
// buttonOk
// panel16
//
this.buttonOk.Location = new System.Drawing.Point(631, 227);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(94, 29);
this.buttonOk.TabIndex = 2;
this.buttonOk.Text = "Добавить";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
this.panel16.Location = new System.Drawing.Point(0, 0);
this.panel16.Name = "panel16";
this.panel16.Size = new System.Drawing.Size(200, 100);
this.panel16.TabIndex = 0;
//
// buttonCancel
// panel17
//
this.buttonCancel.Location = new System.Drawing.Point(746, 227);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.panel17.Location = new System.Drawing.Point(0, 0);
this.panel17.Name = "panel17";
this.panel17.Size = new System.Drawing.Size(200, 100);
this.panel17.TabIndex = 0;
//
// pictureBoxObject
// panel24
//
this.pictureBoxObject.Location = new System.Drawing.Point(3, 50);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(259, 150);
this.pictureBoxObject.TabIndex = 2;
this.pictureBoxObject.TabStop = false;
this.panel24.Location = new System.Drawing.Point(0, 0);
this.panel24.Name = "panel24";
this.panel24.Size = new System.Drawing.Size(200, 100);
this.panel24.TabIndex = 0;
//
// labelColor
// panel25
//
this.labelColor.AllowDrop = true;
this.labelColor.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(2, 15);
this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(119, 32);
this.labelColor.TabIndex = 3;
this.labelColor.Text = "Цвет";
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelColor_DragDrop);
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
this.panel25.Location = new System.Drawing.Point(0, 0);
this.panel25.Name = "panel25";
this.panel25.Size = new System.Drawing.Size(200, 100);
this.panel25.TabIndex = 0;
//
// labelAdditionalColor
// panel12
//
this.labelAdditionalColor.AllowDrop = true;
this.labelAdditionalColor.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAdditionalColor.Location = new System.Drawing.Point(142, 15);
this.labelAdditionalColor.Name = "labelAdditionalColor";
this.labelAdditionalColor.Size = new System.Drawing.Size(120, 32);
this.labelAdditionalColor.TabIndex = 4;
this.labelAdditionalColor.Text = "Доп. цвет";
this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAdditionalColor_DragDrop);
this.labelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
this.panel12.Location = new System.Drawing.Point(0, 0);
this.panel12.Name = "panel12";
this.panel12.Size = new System.Drawing.Size(200, 100);
this.panel12.TabIndex = 0;
//
// panelObject
// panel13
//
this.panelObject.AllowDrop = true;
this.panelObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panelObject.Controls.Add(this.labelAdditionalColor);
this.panelObject.Controls.Add(this.labelColor);
this.panelObject.Controls.Add(this.pictureBoxObject);
this.panelObject.Location = new System.Drawing.Point(603, 12);
this.panelObject.Name = "panelObject";
this.panelObject.Size = new System.Drawing.Size(267, 208);
this.panelObject.TabIndex = 4;
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.panelObject_DragDrop);
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.panelObject_DragEnter);
this.panel13.Location = new System.Drawing.Point(0, 0);
this.panel13.Name = "panel13";
this.panel13.Size = new System.Drawing.Size(200, 100);
this.panel13.TabIndex = 0;
//
// panel28
//
this.panel28.Location = new System.Drawing.Point(0, 0);
this.panel28.Name = "panel28";
this.panel28.Size = new System.Drawing.Size(200, 100);
this.panel28.TabIndex = 0;
//
// panel29
//
this.panel29.Location = new System.Drawing.Point(0, 0);
this.panel29.Name = "panel29";
this.panel29.Size = new System.Drawing.Size(200, 100);
this.panel29.TabIndex = 0;
//
// panel5
//
this.panel5.Location = new System.Drawing.Point(0, 0);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(200, 100);
this.panel5.TabIndex = 0;
//
// panel4
//
this.panel4.Location = new System.Drawing.Point(0, 0);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(200, 100);
this.panel4.TabIndex = 0;
//
// panel8
//
this.panel8.Location = new System.Drawing.Point(0, 0);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(200, 100);
this.panel8.TabIndex = 0;
//
// panel9
//
this.panel9.Location = new System.Drawing.Point(0, 0);
this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(200, 100);
this.panel9.TabIndex = 0;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.label6);
this.groupBox3.Controls.Add(this.label5);
this.groupBox3.Controls.Add(this.pictureBox1);
this.groupBox3.Location = new System.Drawing.Point(603, 12);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(267, 287);
this.groupBox3.TabIndex = 1;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "groupBox3";
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(6, 63);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(255, 218);
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
//
// button5
//
this.button5.Location = new System.Drawing.Point(631, 305);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(94, 29);
this.button5.TabIndex = 2;
this.button5.Text = "Добавить";
this.button5.UseVisualStyleBackColor = true;
//
// button6
//
this.button6.Location = new System.Drawing.Point(744, 305);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(94, 29);
this.button6.TabIndex = 3;
this.button6.Text = "Отмена";
this.button6.UseVisualStyleBackColor = true;
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label3.Location = new System.Drawing.Point(369, 171);
this.label3.Name = "label3";
this.label3.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.label3.Size = new System.Drawing.Size(71, 42);
this.label3.TabIndex = 7;
this.label3.Text = "Простой";
//
// label4
//
this.label4.AutoSize = true;
this.label4.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.label4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label4.Location = new System.Drawing.Point(458, 171);
this.label4.Name = "label4";
this.label4.Padding = new System.Windows.Forms.Padding(0, 10, 0, 10);
this.label4.Size = new System.Drawing.Size(107, 42);
this.label4.TabIndex = 8;
this.label4.Text = "Продвинутый";
//
// label5
//
this.label5.AutoSize = true;
this.label5.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label5.Location = new System.Drawing.Point(28, 23);
this.label5.Name = "label5";
this.label5.Padding = new System.Windows.Forms.Padding(25, 5, 25, 5);
this.label5.Size = new System.Drawing.Size(94, 32);
this.label5.TabIndex = 3;
this.label5.Text = "Цвет";
//
// label6
//
this.label6.AutoSize = true;
this.label6.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.label6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label6.Location = new System.Drawing.Point(141, 23);
this.label6.Name = "label6";
this.label6.Padding = new System.Windows.Forms.Padding(10, 5, 10, 5);
this.label6.Size = new System.Drawing.Size(97, 32);
this.label6.TabIndex = 4;
this.label6.Text = "Доп. цвет";
//
// FormTractorConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(882, 271);
this.Controls.Add(this.panelObject);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.groupBoxConfig);
this.ClientSize = new System.Drawing.Size(882, 353);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox1);
this.Name = "FormTractorConfig";
this.Text = "FormTractorConfig";
this.groupBoxConfig.ResumeLayout(false);
this.groupBoxConfig.PerformLayout();
this.groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.panelObject.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.panel18.ResumeLayout(false);
this.panel19.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private GroupBox groupBoxColors;
private Panel panelRed;
private Panel panelGreen;
private CheckBox checkBoxBlade;
private CheckBox checkBoxWheelsOrnament;
private GroupBox groupBox1;
private GroupBox groupBox2;
private Panel panel1;
private Panel panel2;
private Panel panel5;
private Panel panel4;
private CheckBox checkBox2;
private CheckBox checkBox1;
private Label label2;
private Label label1;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Panel panelPurpule;
private Panel panelBlack;
private Panel panelGrey;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelWhite;
private Label labelModifiedObject;
private Label labelSimpleObject;
private Button buttonOk;
private Button buttonCancel;
private PictureBox pictureBoxObject;
private Label labelColor;
private Label labelAdditionalColor;
private Panel panelObject;
private NumericUpDown numericUpDown2;
private NumericUpDown numericUpDown1;
private Panel panel18;
private Panel panel19;
private Panel panel20;
private Panel panel21;
private Panel panel14;
private Panel panel16;
private Panel panel17;
private Panel panel22;
private Panel panel24;
private Panel panel25;
private Panel panel10;
private Panel panel12;
private Panel panel13;
private Panel panel26;
private Panel panel28;
private Panel panel29;
private Panel panel6;
private Panel panel8;
private Panel panel9;
private Label label4;
private Label label3;
private GroupBox groupBox3;
private Label label6;
private Label label5;
private PictureBox pictureBox1;
private Button button5;
private Button button6;
}
}

View File

@ -7,174 +7,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ProjectTractor.DrawningObjects;
using ProjectTractor.Entities;
namespace ProjectTractor;
public partial class FormTractorConfig : Form
namespace ProjectTractor
{
/// <summary>
/// Переменная-выбранный трактор
/// </summary>
DrawningTractor? _tractor = null;
/// <summary>
/// Событие
/// </summary>
private event Action<DrawningTractor>? EventAddTractor;
/// <summary>
/// Конструктор
/// </summary>
//
public FormTractorConfig()
public partial class FormTractorConfig : Form
{
InitializeComponent();
panelBlack.MouseDown += panelColor_MouseDown;
panelPurpule.MouseDown += panelColor_MouseDown;
panelGrey.MouseDown += panelColor_MouseDown;
panelGreen.MouseDown += panelColor_MouseDown;
panelRed.MouseDown += panelColor_MouseDown;
panelWhite.MouseDown += panelColor_MouseDown;
panelYellow.MouseDown += panelColor_MouseDown;
panelBlue.MouseDown += panelColor_MouseDown;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
buttonCancel.Click += (s, e) => Close();
}
/// <summary>
/// Отрисовать трактор
/// </summary>
private void DrawTractor()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_tractor?.SetPosition(5, 5);
_tractor?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(Action<DrawningTractor> ev)
{
if (EventAddTractor == null)
public FormTractorConfig()
{
EventAddTractor = ev;
InitializeComponent();
}
else
{
EventAddTractor += ev;
}
}
/// <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, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void panelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void panelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
_tractor = new DrawningTractor((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
case "labelModifiedObject":
_tractor = new DrawningBulldoser((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxWheelsOrnament.Checked,
checkBoxBlade.Checked, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
}
labelColor.BackColor = Color.Empty;
labelAdditionalColor.BackColor = Color.Empty;
DrawTractor();
}
/// <summary>
/// Смена цвета
/// </summary>
private void panelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void labelColor_DragDrop(object sender, DragEventArgs e)
{
if (_tractor == null)
{
return;
}
labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
_tractor.ChangeColor(labelColor.BackColor);
DrawTractor();
}
private void labelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if ((_tractor == null) || (_tractor is DrawningBulldoser == false))
{
return;
}
labelAdditionalColor.BackColor = (Color)e.Data.GetData(typeof(Color));
((DrawningBulldoser)_tractor).ChangeAdditionalColor(labelAdditionalColor.BackColor);
DrawTractor();
}
/// <summary>
/// Добавление трактора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
if (_tractor == null)
return;
EventAddTractor?.Invoke(_tractor);
Close();
}
}