diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs
index ca3eb8a..42d7618 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningBulldoser.cs
@@ -95,5 +95,10 @@ namespace ProjectTractor.DrawningObjects
}
}
+ public void ChangeAdditionalColor(Color color)
+ {
+ ((EntityBulldoser)EntityTractor).AdditionalColor = color;
+ }
+
}
}
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs
index 99015c2..39e7239 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/DrawningTractor.cs
@@ -6,13 +6,11 @@ using System.Threading.Tasks;
using ProjectTractor.Entities;
using ProjectTractor.MovementStrategy;
-namespace ProjectTractor.DrawningObjects {
-
-///
-/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
-///
- public class DrawningTractor
-{
+namespace ProjectTractor.DrawningObjects {
+ ///
+ /// Класс, отвечающий за прорисовку и перемещение объекта-сущности
+ ///
+ public class DrawningTractor {
///
/// Класс-сущность
///
@@ -41,15 +39,16 @@ namespace ProjectTractor.DrawningObjects {
/// Высота прорисовки автомобиля
///
protected readonly int _tractorHeight = 60;
- ///
- /// Конструктор
- ///
- /// Скорость
- /// Вес
- /// Основной цвет
- /// Ширина картинки
- /// Высота картинки
- public DrawningTractor(int speed, double weight, Color bodyColor, int
+
+ ///
+ /// Конструктор
+ ///
+ /// Скорость
+ /// Вес
+ /// Основной цвет
+ /// Ширина картинки
+ /// Высота картинки
+ public DrawningTractor(int speed, double weight, Color bodyColor, int
width, int height)
{
if (width <= _tractorWidth || height <= _tractorHeight)
@@ -228,7 +227,22 @@ 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;
+ }
+ }
}
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs
index b71fcd3..c0e5211 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityBulldoser.cs
@@ -14,7 +14,7 @@ namespace ProjectTractor.Entities
///
/// Дополнительный цвет (для опциональных элементов)
///
- public Color AdditionalColor { get; private set; }
+ public Color AdditionalColor { get; set; }
///
/// Признак (опция) наличия обвеса
///
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs
index 17d046f..0de2fbe 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/EntityTractor.cs
@@ -22,7 +22,7 @@ namespace ProjectTractor.Entities
///
/// Основной цвет
///
- public Color BodyColor { get; private set; }
+ public Color BodyColor { get; set; }
///
/// Шаг перемещения автомобиля
///
@@ -39,6 +39,5 @@ namespace ProjectTractor.Entities
Weight = weight;
BodyColor = bodyColor;
}
-
}
}
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
index e8c12e9..5da1835 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
@@ -73,7 +73,7 @@ namespace ProjectTractor
///
///
///
- private void ListBoxObjects_SelectedIndexChanged(object sender,
+ private void listBoxStorages_SelectedIndexChanged(object sender,
EventArgs e)
{
pictureBoxCollection.Image =
@@ -102,6 +102,7 @@ namespace ProjectTractor
///
///
///
+
private void ButtonAddTractor_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
@@ -113,19 +114,24 @@ namespace ProjectTractor
{
return;
}
- FormTractor form = new();
- if (form.ShowDialog() == DialogResult.OK)
+
+ FormTractorConfig form = new();
+ form.Show();
+ Action? tractorDelegate = new((m) =>
{
- if (obj + form.SelectedTractor)
+ bool isAdditionSuccessful = (obj + m);
+ if (isAdditionSuccessful)
{
MessageBox.Show("Объект добавлен");
+ m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
pictureBoxCollection.Image = obj.ShowTractors();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
- }
+ });
+ form.AddEvent(tractorDelegate);
}
///
@@ -180,7 +186,6 @@ namespace ProjectTractor
}
pictureBoxCollection.Image = obj.ShowTractors();
}
-
private void InitializeComponent()
{
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
@@ -204,7 +209,7 @@ namespace ProjectTractor
this.pictureBoxCollection.Dock = System.Windows.Forms.DockStyle.Left;
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
this.pictureBoxCollection.Name = "pictureBoxCollection";
- this.pictureBoxCollection.Size = new System.Drawing.Size(620, 536);
+ this.pictureBoxCollection.Size = new System.Drawing.Size(645, 536);
this.pictureBoxCollection.TabIndex = 1;
this.pictureBoxCollection.TabStop = false;
//
@@ -215,7 +220,7 @@ namespace ProjectTractor
this.groupBox.Controls.Add(this.ButtonRemoveTractor);
this.groupBox.Controls.Add(this.ButtonAddTractor);
this.groupBox.Controls.Add(this.maskedTextBoxNumber);
- this.groupBox.Location = new System.Drawing.Point(626, 12);
+ this.groupBox.Location = new System.Drawing.Point(651, 14);
this.groupBox.Name = "groupBox";
this.groupBox.Size = new System.Drawing.Size(255, 522);
this.groupBox.TabIndex = 2;
@@ -253,6 +258,7 @@ 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
//
@@ -310,7 +316,7 @@ namespace ProjectTractor
//
// FormTractorCollection
//
- this.ClientSize = new System.Drawing.Size(893, 536);
+ this.ClientSize = new System.Drawing.Size(918, 536);
this.Controls.Add(this.groupBox);
this.Controls.Add(this.pictureBoxCollection);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
@@ -338,7 +344,5 @@ namespace ProjectTractor
private Button ButtonAddObject;
private MaskedTextBox textBoxStorageName;
private PictureBox pictureBoxCollection;
-
-
}
}
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.Designer.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.Designer.cs
new file mode 100644
index 0000000..31df060
--- /dev/null
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.Designer.cs
@@ -0,0 +1,410 @@
+namespace ProjectTractor
+{
+ partial class FormTractorConfig
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ 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.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.SuspendLayout();
+ //
+ // groupBoxConfig
+ //
+ 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 = "Параметры";
+ //
+ // labelModifiedObject
+ //
+ 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);
+ //
+ // labelSimpleObject
+ //
+ 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);
+ //
+ // groupBoxColors
+ //
+ 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 = "Цвета";
+ //
+ // panelPurpule
+ //
+ 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);
+ //
+ // panelBlack
+ //
+ 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);
+ //
+ // panelGrey
+ //
+ 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);
+ //
+ // panelYellow
+ //
+ 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);
+ //
+ // panelBlue
+ //
+ 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);
+ //
+ // panelWhite
+ //
+ 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);
+ //
+ // panelGreen
+ //
+ 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);
+ //
+ // panelRed
+ //
+ 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);
+ //
+ // checkBoxBlade
+ //
+ 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;
+ //
+ // checkBoxWheelsOrnament
+ //
+ 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;
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(32, 82);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(33, 20);
+ this.label2.TabIndex = 3;
+ this.label2.Text = "Вес";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(32, 28);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(73, 20);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "Скорость";
+ //
+ // numericUpDownWeight
+ //
+ 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});
+ //
+ // numericUpDownSpeed
+ //
+ 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});
+ //
+ // buttonOk
+ //
+ 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);
+ //
+ // buttonCancel
+ //
+ 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;
+ //
+ // pictureBoxObject
+ //
+ 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;
+ //
+ // labelColor
+ //
+ 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);
+ //
+ // labelAdditionalColor
+ //
+ 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);
+ //
+ // panelObject
+ //
+ 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);
+ //
+ // 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.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.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBoxConfig;
+ private GroupBox groupBoxColors;
+ private Panel panelRed;
+ private Panel panelGreen;
+ private CheckBox checkBoxBlade;
+ private CheckBox checkBoxWheelsOrnament;
+ 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;
+ }
+}
\ No newline at end of file
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.cs
new file mode 100644
index 0000000..66fc72e
--- /dev/null
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.cs
@@ -0,0 +1,184 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using ProjectTractor.DrawningObjects;
+using ProjectTractor.Entities;
+using ProjectTractor.Generics;
+using ProjectTractor.MovementStrategy;
+
+namespace ProjectTractor;
+
+
+
+
+public partial class FormTractorConfig : Form
+{
+ ///
+ /// Переменная-выбранный трактор
+ ///
+ DrawningTractor? _tractor = null;
+ ///
+ /// Событие
+ ///
+ private event Action? EventAddTractor;
+ ///
+ /// Конструктор
+ ///
+ //
+ public delegate void TractorDelegate(DrawningTractor tractor);
+ public FormTractorConfig()
+ {
+ 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();
+ }
+
+ ///
+ /// Отрисовать трактор
+ ///
+ 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;
+ }
+ ///
+ /// Добавление события
+ ///
+ /// Привязанный метод
+ public void AddEvent(Action ev)
+ {
+ if (EventAddTractor == null)
+ {
+ EventAddTractor = ev;
+ }
+ else
+ {
+ EventAddTractor += ev;
+ }
+ }
+ ///
+ /// Передаем информацию при нажатии на Label
+ ///
+ ///
+ ///
+ private void LabelObject_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
+ }
+ ///
+ /// Проверка получаемой информации (ее типа на соответствие требуемому)
+ ///
+ ///
+ ///
+ private void panelObject_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+ ///
+ /// Действия при приеме перетаскиваемой информации
+ ///
+ ///
+ ///
+ 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();
+ }
+ ///
+ /// Смена цвета
+ ///
+ 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();
+ }
+
+
+ ///
+ /// Добавление трактора
+ ///
+ ///
+ ///
+ ///
+ private void ButtonOk_Click(object sender, EventArgs e)
+ {
+ if (_tractor == null)
+ return;
+ EventAddTractor?.Invoke(_tractor);
+ Close();
+ }
+}
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.resx b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorConfig.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericCollection.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericCollection.cs
index d978071..3151dfd 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericCollection.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericCollection.cs
@@ -134,7 +134,7 @@ namespace ProjectTractor.Generics
if (tractor != null)
{
int countRows = _pictureWidth / _placeSizeWidth;
- tractor.SetPosition(_pictureWidth - _placeSizeWidth * 2 - (i % countRows * _placeSizeWidth) + 20, _pictureHeight - i / countRows * _placeSizeHeight - 160);
+ tractor.SetPosition(_pictureWidth - _placeSizeWidth - (i % countRows * _placeSizeWidth), _pictureHeight - i / countRows * _placeSizeHeight - 160);
tractor.DrawTransport(g);
}
i++;