Забыл закомититть
This commit is contained in:
parent
4cac5d627c
commit
de6a249739
@ -95,5 +95,10 @@ namespace ProjectTractor.DrawningObjects
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeAdditionalColor(Color color)
|
||||
{
|
||||
((EntityBulldoser)EntityTractor).AdditionalColor = color;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,11 @@ 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>
|
||||
@ -41,15 +39,16 @@ 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)
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@ namespace ProjectTractor.Entities
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия обвеса
|
||||
/// </summary>
|
||||
|
@ -22,7 +22,7 @@ namespace ProjectTractor.Entities
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения автомобиля
|
||||
/// </summary>
|
||||
@ -39,6 +39,5 @@ namespace ProjectTractor.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -113,19 +113,24 @@ namespace ProjectTractor
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormTractor form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
|
||||
FormTractorConfig form = new();
|
||||
form.Show();
|
||||
Action<DrawningTractor>? 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -180,7 +185,6 @@ namespace ProjectTractor
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowTractors();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
|
@ -30,7 +30,7 @@
|
||||
{
|
||||
this.groupBoxConfig = new System.Windows.Forms.GroupBox();
|
||||
this.labelModifiedObject = new System.Windows.Forms.Label();
|
||||
this.labelSimleObject = 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();
|
||||
@ -46,11 +46,11 @@
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.buttonAddCar = new System.Windows.Forms.Button();
|
||||
this.button6 = new System.Windows.Forms.Button();
|
||||
this.buttonOk = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
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();
|
||||
@ -63,7 +63,7 @@
|
||||
// groupBoxConfig
|
||||
//
|
||||
this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSimleObject);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxBlade);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxWheelsOrnament);
|
||||
@ -73,7 +73,7 @@
|
||||
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, 341);
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(585, 256);
|
||||
this.groupBoxConfig.TabIndex = 0;
|
||||
this.groupBoxConfig.TabStop = false;
|
||||
this.groupBoxConfig.Text = "Параметры";
|
||||
@ -82,7 +82,6 @@
|
||||
//
|
||||
this.labelModifiedObject.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelModifiedObject.Enabled = false;
|
||||
this.labelModifiedObject.Location = new System.Drawing.Point(449, 171);
|
||||
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||
this.labelModifiedObject.Size = new System.Drawing.Size(114, 42);
|
||||
@ -91,17 +90,17 @@
|
||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// labelSimleObject
|
||||
// labelSimpleObject
|
||||
//
|
||||
this.labelSimleObject.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.labelSimleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelSimleObject.Location = new System.Drawing.Point(369, 171);
|
||||
this.labelSimleObject.Name = "labelSimleObject";
|
||||
this.labelSimleObject.Size = new System.Drawing.Size(74, 42);
|
||||
this.labelSimleObject.TabIndex = 7;
|
||||
this.labelSimleObject.Text = "Простой";
|
||||
this.labelSimleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelSimleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
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
|
||||
//
|
||||
@ -128,6 +127,7 @@
|
||||
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
|
||||
@ -138,6 +138,7 @@
|
||||
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
|
||||
@ -148,6 +149,7 @@
|
||||
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
|
||||
@ -158,6 +160,7 @@
|
||||
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
|
||||
@ -168,6 +171,7 @@
|
||||
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
|
||||
@ -178,6 +182,7 @@
|
||||
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
|
||||
@ -188,6 +193,7 @@
|
||||
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
|
||||
@ -198,12 +204,13 @@
|
||||
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, 227);
|
||||
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;
|
||||
@ -213,7 +220,7 @@
|
||||
// checkBoxWheelsOrnament
|
||||
//
|
||||
this.checkBoxWheelsOrnament.AutoSize = true;
|
||||
this.checkBoxWheelsOrnament.Location = new System.Drawing.Point(32, 286);
|
||||
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;
|
||||
@ -282,67 +289,71 @@
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// buttonAddCar
|
||||
// buttonOk
|
||||
//
|
||||
this.buttonAddCar.Location = new System.Drawing.Point(631, 305);
|
||||
this.buttonAddCar.Name = "buttonAddCar";
|
||||
this.buttonAddCar.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonAddCar.TabIndex = 2;
|
||||
this.buttonAddCar.Text = "Добавить";
|
||||
this.buttonAddCar.UseVisualStyleBackColor = true;
|
||||
this.buttonAddCar.Click += new System.EventHandler(this.buttonAddCar_Click);
|
||||
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);
|
||||
//
|
||||
// button6
|
||||
// buttonCancel
|
||||
//
|
||||
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;
|
||||
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, 232);
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(259, 150);
|
||||
this.pictureBoxObject.TabIndex = 2;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// label5
|
||||
// labelColor
|
||||
//
|
||||
this.label5.AllowDrop = true;
|
||||
this.label5.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.label5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.label5.Location = new System.Drawing.Point(2, 15);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(119, 32);
|
||||
this.label5.TabIndex = 3;
|
||||
this.label5.Text = "Цвет";
|
||||
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
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);
|
||||
//
|
||||
// label6
|
||||
// labelAdditionalColor
|
||||
//
|
||||
this.label6.AllowDrop = true;
|
||||
this.label6.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.label6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.label6.Location = new System.Drawing.Point(142, 15);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(120, 32);
|
||||
this.label6.TabIndex = 4;
|
||||
this.label6.Text = "Доп. цвет";
|
||||
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
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.label6);
|
||||
this.panelObject.Controls.Add(this.label5);
|
||||
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, 287);
|
||||
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);
|
||||
@ -351,10 +362,10 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(882, 353);
|
||||
this.ClientSize = new System.Drawing.Size(882, 271);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.button6);
|
||||
this.Controls.Add(this.buttonAddCar);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOk);
|
||||
this.Controls.Add(this.groupBoxConfig);
|
||||
this.Name = "FormTractorConfig";
|
||||
this.Text = "FormTractorConfig";
|
||||
@ -388,12 +399,12 @@
|
||||
private Panel panelBlue;
|
||||
private Panel panelWhite;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimleObject;
|
||||
private Button buttonAddCar;
|
||||
private Button button6;
|
||||
private Label labelSimpleObject;
|
||||
private Button buttonOk;
|
||||
private Button buttonCancel;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Label label5;
|
||||
private Label label6;
|
||||
private Label labelColor;
|
||||
private Label labelAdditionalColor;
|
||||
private Panel panelObject;
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ProjectTractor.DrawningObjects;
|
||||
using ProjectTractor.Entities;
|
||||
|
||||
namespace ProjectTractor;
|
||||
|
||||
@ -17,19 +18,13 @@ namespace ProjectTractor;
|
||||
public partial class FormTractorConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранная машина
|
||||
/// Переменная-выбранный трактор
|
||||
/// </summary>
|
||||
DrawningTractor? _tractor = null;
|
||||
/// <summary>
|
||||
/// Делегат для передачи объекта-автомобиля
|
||||
/// </summary>
|
||||
/// <param name="car"></param>
|
||||
public delegate void TractorDelegate(DrawningTractor tractor);
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event TractorDelegate? EventAddTractor;
|
||||
|
||||
private event Action<DrawningTractor>? EventAddTractor;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -45,14 +40,28 @@ public partial class FormTractorConfig : Form
|
||||
panelWhite.MouseDown += panelColor_MouseDown;
|
||||
panelYellow.MouseDown += panelColor_MouseDown;
|
||||
panelBlue.MouseDown += panelColor_MouseDown;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
|
||||
// TODO buttonCancel.Click with lambda
|
||||
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(TractorDelegate ev)
|
||||
public void AddEvent(Action<DrawningTractor> ev)
|
||||
{
|
||||
if (EventAddTractor == null)
|
||||
{
|
||||
@ -64,38 +73,19 @@ public partial class FormTractorConfig : Form
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление машины
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddTractor?.Invoke(_tractor);
|
||||
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>
|
||||
/// Передаем информацию при нажатии на 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);
|
||||
(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)
|
||||
@ -107,7 +97,11 @@ public partial class FormTractorConfig : Form
|
||||
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())
|
||||
@ -119,31 +113,68 @@ public partial class FormTractorConfig : Form
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_tractor = new DrawningBulldoser((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBlade.Checked,
|
||||
checkBoxWheelsOrnament.Checked, pictureBoxObject.Width,
|
||||
(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 panelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
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 buttonAddCar_Click(object sender, EventArgs e)
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formTractorConfig = new FormTractorConfig();
|
||||
// TODO Call method AddEvent from formCarConfig
|
||||
formTractorConfig.Show();
|
||||
|
||||
if (_tractor == null)
|
||||
return;
|
||||
EventAddTractor?.Invoke(_tractor);
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user