diff --git a/Lab/BaseTanker.cs b/Lab/BaseTanker.cs
index 3c2005e..56b02d5 100644
--- a/Lab/BaseTanker.cs
+++ b/Lab/BaseTanker.cs
@@ -18,5 +18,10 @@ namespace Lab.Entities
Weight = weight;
BodyColor = bodyColor;
}
+
+ public void ChangeBodyColor(Color bodyColor)
+ {
+ BodyColor = bodyColor;
+ }
}
}
diff --git a/Lab/CollectionsFrame.cs b/Lab/CollectionsFrame.cs
index 33c72f2..93f3118 100644
--- a/Lab/CollectionsFrame.cs
+++ b/Lab/CollectionsFrame.cs
@@ -97,30 +97,34 @@ namespace Lab
///
///
///
+
+ private void AddTanker(DrawTanker tanker)
+ {
+
+ var obj = _storage[CollectionListBox.SelectedItem.ToString() ?? string.Empty];
+ if (obj == null)
+ {
+ return;
+ }
+ if (obj + tanker)
+ {
+ MessageBox.Show("Объект добавлен");
+ DrawTank.Image = obj.ShowCars();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
private void ButtonAddCar_Click(object sender, EventArgs e)
{
if (CollectionListBox.SelectedIndex == -1)
{
return;
}
- var obj = _storage[CollectionListBox.SelectedItem.ToString() ?? string.Empty];
- if (obj == null)
- {
- return;
- }
- Frame form = new();
- if (form.ShowDialog() == DialogResult.OK)
- {
- if (obj + form.SelectedCar)
- {
- MessageBox.Show("Объект добавлен");
- DrawTank.Image = obj.ShowCars();
- }
- else
- {
- MessageBox.Show("Не удалось добавить объект");
- }
- }
+ FormTankerConfig form = new FormTankerConfig();
+ form.Show();
+ form.AddEvent(AddTanker);
}
///
/// Удаление объекта из набора
diff --git a/Lab/DrawGasolineTanker.cs b/Lab/DrawGasolineTanker.cs
index 3c77089..70958f4 100644
--- a/Lab/DrawGasolineTanker.cs
+++ b/Lab/DrawGasolineTanker.cs
@@ -12,14 +12,19 @@ namespace Lab.DrawningObjects
public DrawGasolineTanker(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height) : base(speed, weight, bodyColor, width, height)
{
- if (GasolineTanker != null)
+ if (_gasolineTanker != null)
{
- GasolineTanker = new GasolineTanker(speed, weight, bodyColor, additionalColor, bodyKit, wing, sportLine);
+ _gasolineTanker = new GasolineTanker(speed, weight, bodyColor, additionalColor, bodyKit, wing, sportLine);
}
}
+
+ public void SetAddColor(Color color)
+ {
+ (_gasolineTanker as GasolineTanker).ChangeAddColor(color);
+ }
public override void DrawTransport(Graphics g)
{
- if (GasolineTanker is not GasolineTanker Gasoline)
+ if (_gasolineTanker is not GasolineTanker Gasoline)
return;
base.DrawTransport(g);
if (Gasoline.BodyKit)
diff --git a/Lab/DrawTanker.cs b/Lab/DrawTanker.cs
index 6385a21..11a3d9f 100644
--- a/Lab/DrawTanker.cs
+++ b/Lab/DrawTanker.cs
@@ -11,7 +11,7 @@ namespace Lab.DrawningObjects
{
public class DrawTanker
{
- public BaseTanker? GasolineTanker { get; protected set; }
+ public BaseTanker? _gasolineTanker { get; protected set; }
protected int _pictureWidth;
protected int _pictureHeight;
protected int _startPosX;
@@ -25,14 +25,14 @@ namespace Lab.DrawningObjects
public bool CanMove(Direction direction)
{
- if (GasolineTanker == null)
+ if (_gasolineTanker == null)
return false;
return direction switch
{
- Direction.Left => _startPosX - GasolineTanker.Step > 0,
- Direction.Up => _startPosY - GasolineTanker.Step > 0,
- Direction.Right => _startPosX + _carWidth + GasolineTanker.Step < _pictureWidth,
- Direction.Down => _startPosY + _carHeight + GasolineTanker.Step < _pictureHeight,
+ Direction.Left => _startPosX - _gasolineTanker.Step > 0,
+ Direction.Up => _startPosY - _gasolineTanker.Step > 0,
+ Direction.Right => _startPosX + _carWidth + _gasolineTanker.Step < _pictureWidth,
+ Direction.Down => _startPosY + _carHeight + _gasolineTanker.Step < _pictureHeight,
_ => false
};
@@ -42,7 +42,7 @@ namespace Lab.DrawningObjects
{
_pictureHeight = height;
_pictureWidth = width;
- GasolineTanker = new BaseTanker(speed, weight, bodyColor);
+ _gasolineTanker = new BaseTanker(speed, weight, bodyColor);
}
public DrawTanker(int speed, double weight, Color bodyColor, int width, int height, int carWidth, int carHeight)
@@ -51,7 +51,12 @@ namespace Lab.DrawningObjects
_pictureWidth = width;
_carHeight = carHeight;
_carWidth = carWidth;
- GasolineTanker = new BaseTanker(speed, weight, bodyColor);
+ _gasolineTanker = new BaseTanker(speed, weight, bodyColor);
+ }
+
+ public void SetBaseColor(Color bodyColor)
+ {
+ _gasolineTanker.ChangeBodyColor(bodyColor);
}
public void SetPosition(int x, int y)
@@ -62,39 +67,39 @@ namespace Lab.DrawningObjects
public void MoveTransport(Direction direction)
{
- if (!CanMove(direction) || GasolineTanker == null)
+ if (!CanMove(direction) || _gasolineTanker == null)
return;
switch (direction)
{
case Direction.Left:
{
- if (_startPosX - GasolineTanker.Step > 0)
+ if (_startPosX - _gasolineTanker.Step > 0)
{
- _startPosX -= (int)GasolineTanker.Step;
+ _startPosX -= (int)_gasolineTanker.Step;
}
}
break;
case Direction.Up:
{
- if (_startPosY - GasolineTanker.Step > 0)
+ if (_startPosY - _gasolineTanker.Step > 0)
{
- _startPosY -= (int)GasolineTanker.Step;
+ _startPosY -= (int)_gasolineTanker.Step;
}
}
break;
case Direction.Right:
{
- if (_startPosX + _carWidth + GasolineTanker.Step < _pictureWidth)
+ if (_startPosX + _carWidth + _gasolineTanker.Step < _pictureWidth)
{
- _startPosX += (int)GasolineTanker.Step;
+ _startPosX += (int)_gasolineTanker.Step;
}
}
break;
case Direction.Down:
{
- if (_startPosY + GasolineTanker.Step + _carHeight < _pictureHeight)
+ if (_startPosY + _gasolineTanker.Step + _carHeight < _pictureHeight)
{
- _startPosY += (int)GasolineTanker.Step;
+ _startPosY += (int)_gasolineTanker.Step;
}
}
break;
@@ -103,10 +108,10 @@ namespace Lab.DrawningObjects
public virtual void DrawTransport(Graphics g)
{
- if (GasolineTanker == null)
+ if (_gasolineTanker == null)
return;
- Pen pen = new(GasolineTanker.BodyColor, 2);
- Brush brush = new SolidBrush(GasolineTanker.BodyColor);
+ Pen pen = new(_gasolineTanker.BodyColor, 2);
+ Brush brush = new SolidBrush(_gasolineTanker.BodyColor);
// Отрисовка корпуса
g.FillRectangle(brush, 10 + _startPosX, 40 + _startPosY, 90, 20);
diff --git a/Lab/DrawingObjectTanker.cs b/Lab/DrawingObjectTanker.cs
index a9fdce0..6b6e15b 100644
--- a/Lab/DrawingObjectTanker.cs
+++ b/Lab/DrawingObjectTanker.cs
@@ -19,12 +19,12 @@ namespace Lab.MovementStrategy
{
get
{
- if (_drawTanker == null || _drawTanker.GasolineTanker == null)
+ if (_drawTanker == null || _drawTanker._gasolineTanker == null)
return null;
return new ObjectParameters(_drawTanker.GetPosX, _drawTanker.GetPosY, _drawTanker.GetWidth, _drawTanker.GetHeight);
}
}
- public int GetStep => (int)(_drawTanker?.GasolineTanker?.Step ?? 0);
+ public int GetStep => (int)(_drawTanker?._gasolineTanker?.Step ?? 0);
public bool CheckCanMove(Direction direction) => _drawTanker?.CanMove(direction) ?? false;
public void MoveObject(Direction direction) => _drawTanker?.MoveTransport(direction);
diff --git a/Lab/FormTankerConfig.Designer.cs b/Lab/FormTankerConfig.Designer.cs
new file mode 100644
index 0000000..ffed2a1
--- /dev/null
+++ b/Lab/FormTankerConfig.Designer.cs
@@ -0,0 +1,386 @@
+namespace Lab
+{
+ partial class FormTankerConfig
+ {
+ ///
+ /// 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()
+ {
+ settingPanel = new Panel();
+ UpdateLabel = new Label();
+ BaseLabel = new Label();
+ label4 = new Label();
+ panel1 = new Panel();
+ PurplePanel = new Panel();
+ BlackPanel = new Panel();
+ GrayPanel = new Panel();
+ WhitePanel = new Panel();
+ YellowPanel = new Panel();
+ BluePanel = new Panel();
+ GreenPanel = new Panel();
+ RedPanel = new Panel();
+ SportLineCheck = new CheckBox();
+ WingCheck = new CheckBox();
+ BodyKitCheck = new CheckBox();
+ label3 = new Label();
+ WeightNumeric = new NumericUpDown();
+ label2 = new Label();
+ SpeedNumeric = new NumericUpDown();
+ label1 = new Label();
+ panel10 = new Panel();
+ TankerDraw = new PictureBox();
+ AddColorLabel = new Label();
+ BaseColorLabel = new Label();
+ AddButton = new Button();
+ CancelButton = new Button();
+ settingPanel.SuspendLayout();
+ panel1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)WeightNumeric).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)SpeedNumeric).BeginInit();
+ panel10.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)TankerDraw).BeginInit();
+ SuspendLayout();
+ //
+ // settingPanel
+ //
+ settingPanel.Controls.Add(UpdateLabel);
+ settingPanel.Controls.Add(BaseLabel);
+ settingPanel.Controls.Add(label4);
+ settingPanel.Controls.Add(panel1);
+ settingPanel.Controls.Add(SportLineCheck);
+ settingPanel.Controls.Add(WingCheck);
+ settingPanel.Controls.Add(BodyKitCheck);
+ settingPanel.Controls.Add(label3);
+ settingPanel.Controls.Add(WeightNumeric);
+ settingPanel.Controls.Add(label2);
+ settingPanel.Controls.Add(SpeedNumeric);
+ settingPanel.Controls.Add(label1);
+ settingPanel.Location = new Point(10, 11);
+ settingPanel.Name = "settingPanel";
+ settingPanel.Size = new Size(638, 305);
+ settingPanel.TabIndex = 0;
+ //
+ // UpdateLabel
+ //
+ UpdateLabel.BorderStyle = BorderStyle.FixedSingle;
+ UpdateLabel.Location = new Point(454, 217);
+ UpdateLabel.Name = "UpdateLabel";
+ UpdateLabel.Size = new Size(110, 50);
+ UpdateLabel.TabIndex = 11;
+ UpdateLabel.Text = "Продвинутый";
+ UpdateLabel.TextAlign = ContentAlignment.MiddleCenter;
+ UpdateLabel.MouseDown += LabelObject_MouseDown;
+ //
+ // BaseLabel
+ //
+ BaseLabel.BorderStyle = BorderStyle.FixedSingle;
+ BaseLabel.Location = new Point(321, 217);
+ BaseLabel.Name = "BaseLabel";
+ BaseLabel.Size = new Size(110, 50);
+ BaseLabel.TabIndex = 10;
+ BaseLabel.Text = "Простой";
+ BaseLabel.TextAlign = ContentAlignment.MiddleCenter;
+ BaseLabel.MouseDown += LabelObject_MouseDown;
+ //
+ // label4
+ //
+ label4.AutoSize = true;
+ label4.Location = new Point(321, 25);
+ label4.Name = "label4";
+ label4.Size = new Size(42, 20);
+ label4.TabIndex = 9;
+ label4.Text = "Цвет";
+ //
+ // panel1
+ //
+ panel1.Controls.Add(PurplePanel);
+ panel1.Controls.Add(BlackPanel);
+ panel1.Controls.Add(GrayPanel);
+ panel1.Controls.Add(WhitePanel);
+ panel1.Controls.Add(YellowPanel);
+ panel1.Controls.Add(BluePanel);
+ panel1.Controls.Add(GreenPanel);
+ panel1.Controls.Add(RedPanel);
+ panel1.Location = new Point(321, 48);
+ panel1.Name = "panel1";
+ panel1.Size = new Size(243, 125);
+ panel1.TabIndex = 8;
+ panel1.Tag = "";
+ //
+ // PurplePanel
+ //
+ PurplePanel.BackColor = Color.FromArgb(192, 0, 192);
+ PurplePanel.Location = new Point(182, 65);
+ PurplePanel.Name = "PurplePanel";
+ PurplePanel.Size = new Size(50, 50);
+ PurplePanel.TabIndex = 1;
+ //
+ // BlackPanel
+ //
+ BlackPanel.BackColor = Color.Black;
+ BlackPanel.Location = new Point(126, 65);
+ BlackPanel.Name = "BlackPanel";
+ BlackPanel.Size = new Size(50, 50);
+ BlackPanel.TabIndex = 1;
+ //
+ // GrayPanel
+ //
+ GrayPanel.BackColor = Color.Gray;
+ GrayPanel.Location = new Point(70, 65);
+ GrayPanel.Name = "GrayPanel";
+ GrayPanel.Size = new Size(50, 50);
+ GrayPanel.TabIndex = 1;
+ //
+ // WhitePanel
+ //
+ WhitePanel.BackColor = Color.White;
+ WhitePanel.Location = new Point(14, 65);
+ WhitePanel.Name = "WhitePanel";
+ WhitePanel.Size = new Size(50, 50);
+ WhitePanel.TabIndex = 1;
+ //
+ // YellowPanel
+ //
+ YellowPanel.BackColor = Color.Yellow;
+ YellowPanel.Location = new Point(182, 9);
+ YellowPanel.Name = "YellowPanel";
+ YellowPanel.Size = new Size(50, 50);
+ YellowPanel.TabIndex = 1;
+ //
+ // BluePanel
+ //
+ BluePanel.BackColor = Color.Blue;
+ BluePanel.Location = new Point(126, 9);
+ BluePanel.Name = "BluePanel";
+ BluePanel.Size = new Size(50, 50);
+ BluePanel.TabIndex = 1;
+ //
+ // GreenPanel
+ //
+ GreenPanel.BackColor = Color.FromArgb(0, 192, 0);
+ GreenPanel.Location = new Point(70, 9);
+ GreenPanel.Name = "GreenPanel";
+ GreenPanel.Size = new Size(50, 50);
+ GreenPanel.TabIndex = 1;
+ //
+ // RedPanel
+ //
+ RedPanel.BackColor = Color.Red;
+ RedPanel.Location = new Point(14, 9);
+ RedPanel.Name = "RedPanel";
+ RedPanel.Size = new Size(50, 50);
+ RedPanel.TabIndex = 0;
+ //
+ // SportLineCheck
+ //
+ SportLineCheck.AutoSize = true;
+ SportLineCheck.Location = new Point(43, 243);
+ SportLineCheck.Name = "SportLineCheck";
+ SportLineCheck.Size = new Size(163, 24);
+ SportLineCheck.TabIndex = 7;
+ SportLineCheck.Text = "Гоночные полоски";
+ SportLineCheck.UseVisualStyleBackColor = true;
+ //
+ // WingCheck
+ //
+ WingCheck.AutoSize = true;
+ WingCheck.Location = new Point(43, 196);
+ WingCheck.Name = "WingCheck";
+ WingCheck.Size = new Size(90, 24);
+ WingCheck.TabIndex = 6;
+ WingCheck.Text = "Мигалка";
+ WingCheck.UseVisualStyleBackColor = true;
+ //
+ // BodyKitCheck
+ //
+ BodyKitCheck.AutoSize = true;
+ BodyKitCheck.Location = new Point(43, 149);
+ BodyKitCheck.Name = "BodyKitCheck";
+ BodyKitCheck.Size = new Size(74, 24);
+ BodyKitCheck.TabIndex = 5;
+ BodyKitCheck.Text = "Обвес";
+ BodyKitCheck.UseVisualStyleBackColor = true;
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(43, 91);
+ label3.Name = "label3";
+ label3.Size = new Size(33, 20);
+ label3.TabIndex = 4;
+ label3.Text = "Вес";
+ //
+ // WeightNumeric
+ //
+ WeightNumeric.Location = new Point(122, 89);
+ WeightNumeric.Name = "WeightNumeric";
+ WeightNumeric.Size = new Size(150, 27);
+ WeightNumeric.TabIndex = 3;
+ WeightNumeric.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(43, 48);
+ label2.Name = "label2";
+ label2.Size = new Size(73, 20);
+ label2.TabIndex = 2;
+ label2.Text = "Скорость";
+ //
+ // SpeedNumeric
+ //
+ SpeedNumeric.Location = new Point(122, 46);
+ SpeedNumeric.Name = "SpeedNumeric";
+ SpeedNumeric.Size = new Size(150, 27);
+ SpeedNumeric.TabIndex = 1;
+ SpeedNumeric.Value = new decimal(new int[] { 100, 0, 0, 0 });
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(2, 10);
+ label1.Name = "label1";
+ label1.Size = new Size(90, 20);
+ label1.TabIndex = 0;
+ label1.Text = "Параметры";
+ //
+ // panel10
+ //
+ panel10.AllowDrop = true;
+ panel10.Controls.Add(TankerDraw);
+ panel10.Location = new Point(654, 86);
+ panel10.Name = "panel10";
+ panel10.Size = new Size(318, 172);
+ panel10.TabIndex = 1;
+ panel10.DragDrop += PanelObject_DragDrop;
+ panel10.DragEnter += PanelObject_DragEnter;
+ //
+ // TankerDraw
+ //
+ TankerDraw.Location = new Point(3, 3);
+ TankerDraw.Name = "TankerDraw";
+ TankerDraw.Size = new Size(312, 166);
+ TankerDraw.TabIndex = 14;
+ TankerDraw.TabStop = false;
+ //
+ // AddColorLabel
+ //
+ AddColorLabel.AllowDrop = true;
+ AddColorLabel.BorderStyle = BorderStyle.FixedSingle;
+ AddColorLabel.Location = new Point(849, 16);
+ AddColorLabel.Name = "AddColorLabel";
+ AddColorLabel.Size = new Size(120, 40);
+ AddColorLabel.TabIndex = 13;
+ AddColorLabel.Text = "Доп. цвет";
+ AddColorLabel.TextAlign = ContentAlignment.MiddleCenter;
+ AddColorLabel.DragDrop += LabelColor_DragDrop;
+ AddColorLabel.DragEnter += LabelColor_DragEnter;
+ //
+ // BaseColorLabel
+ //
+ BaseColorLabel.AllowDrop = true;
+ BaseColorLabel.BorderStyle = BorderStyle.FixedSingle;
+ BaseColorLabel.Location = new Point(657, 16);
+ BaseColorLabel.Name = "BaseColorLabel";
+ BaseColorLabel.Size = new Size(120, 40);
+ BaseColorLabel.TabIndex = 12;
+ BaseColorLabel.Text = "Цвет";
+ BaseColorLabel.TextAlign = ContentAlignment.MiddleCenter;
+ BaseColorLabel.DragDrop += LabelColor_DragDrop;
+ BaseColorLabel.DragEnter += LabelColor_DragEnter;
+ //
+ // AddButton
+ //
+ AddButton.Location = new Point(657, 266);
+ AddButton.Name = "AddButton";
+ AddButton.Size = new Size(127, 42);
+ AddButton.TabIndex = 2;
+ AddButton.Text = "Добавить";
+ AddButton.UseVisualStyleBackColor = true;
+ AddButton.Click += ButtonOk_Click;
+ //
+ // CancelButton
+ //
+ CancelButton.Location = new Point(842, 266);
+ CancelButton.Name = "CancelButton";
+ CancelButton.Size = new Size(127, 42);
+ CancelButton.TabIndex = 3;
+ CancelButton.Text = "Отмена";
+ CancelButton.UseVisualStyleBackColor = true;
+ //
+ // FormTankerConfig
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(987, 320);
+ Controls.Add(CancelButton);
+ Controls.Add(AddColorLabel);
+ Controls.Add(AddButton);
+ Controls.Add(BaseColorLabel);
+ Controls.Add(panel10);
+ Controls.Add(settingPanel);
+ Name = "FormTankerConfig";
+ Text = "FormTankerConfig";
+ settingPanel.ResumeLayout(false);
+ settingPanel.PerformLayout();
+ panel1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)WeightNumeric).EndInit();
+ ((System.ComponentModel.ISupportInitialize)SpeedNumeric).EndInit();
+ panel10.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)TankerDraw).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Panel settingPanel;
+ private Label label3;
+ private NumericUpDown WeightNumeric;
+ private Label label2;
+ private NumericUpDown SpeedNumeric;
+ private Label label1;
+ private CheckBox BodyKitCheck;
+ private CheckBox SportLineCheck;
+ private CheckBox WingCheck;
+ private Label label4;
+ private Panel panel1;
+ private Panel PurplePanel;
+ private Panel BlackPanel;
+ private Panel GrayPanel;
+ private Panel WhitePanel;
+ private Panel YellowPanel;
+ private Panel BluePanel;
+ private Panel GreenPanel;
+ private Panel RedPanel;
+ private Label UpdateLabel;
+ private Label BaseLabel;
+ private Panel panel10;
+ private PictureBox TankerDraw;
+ private Label AddColorLabel;
+ private Label BaseColorLabel;
+ private Button AddButton;
+ private Button CancelButton;
+ }
+}
\ No newline at end of file
diff --git a/Lab/FormTankerConfig.cs b/Lab/FormTankerConfig.cs
new file mode 100644
index 0000000..418076b
--- /dev/null
+++ b/Lab/FormTankerConfig.cs
@@ -0,0 +1,144 @@
+using System;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using Lab.DrawningObjects;
+using Lab.Entities;
+using Lab.Generics;
+using Lab.MovementStrategy;
+using Lab.Properties;
+
+
+namespace Lab
+{
+ public partial class FormTankerConfig : Form
+ {
+ DrawTanker? _tanker = null;
+ private event Action EventAddTanker;
+ public FormTankerConfig()
+ {
+ InitializeComponent();
+ BlackPanel.MouseDown += PanelColor_MouseDown;
+ WhitePanel.MouseDown += PanelColor_MouseDown;
+ PurplePanel.MouseDown += PanelColor_MouseDown;
+ YellowPanel.MouseDown += PanelColor_MouseDown;
+ GreenPanel.MouseDown += PanelColor_MouseDown;
+ RedPanel.MouseDown += PanelColor_MouseDown;
+ BluePanel.MouseDown += PanelColor_MouseDown;
+ GrayPanel.MouseDown += PanelColor_MouseDown;
+
+ CancelButton.Click += (s, e) => Close();
+ }
+ public void DrawTanker()
+ {
+ Bitmap bmp = new(TankerDraw.Width, TankerDraw.Height);
+ Graphics g = Graphics.FromImage(bmp);
+ _tanker?.SetPosition(5, 5);
+ if (_tanker is DrawGasolineTanker drawGasolineTanker)
+ drawGasolineTanker.DrawTransport(g);
+ else
+ _tanker?.DrawTransport(g);
+ TankerDraw.Image = bmp;
+ }
+ 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 "BaseLabel":
+ _tanker = new DrawTanker((int)SpeedNumeric.Value,
+ (int)WeightNumeric.Value, Color.White, TankerDraw.Width,
+ TankerDraw.Height);
+ break;
+ case "UpdateLabel":
+ _tanker = new DrawGasolineTanker((int)SpeedNumeric.Value,
+ (int)WeightNumeric.Value, Color.White, Color.Black, BodyKitCheck.Checked,
+ WingCheck.Checked, SportLineCheck.Checked, TankerDraw.Width,
+ TankerDraw.Height);
+ break;
+ }
+ DrawTanker();
+ }
+
+ public void AddEvent(Action ev)
+ {
+ if (EventAddTanker == null)
+ {
+ EventAddTanker = ev;
+ }
+ else
+ {
+ EventAddTanker += ev;
+ }
+ }
+
+ private void ButtonOk_Click(object sender, EventArgs e)
+ {
+ EventAddTanker?.Invoke(_tanker);
+ Close();
+ }
+
+
+ private void PanelColor_MouseDown(object sender, MouseEventArgs e)
+ {
+ (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
+ DragDropEffects.Move | DragDropEffects.Copy);
+ }
+
+ private void LabelColor_DragEnter(object sender, DragEventArgs e)
+ {
+ if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
+ {
+ e.Effect = DragDropEffects.Copy;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.None;
+ }
+ }
+
+ private void LabelColor_DragDrop(object sender, DragEventArgs e)
+ {
+ if (_tanker == null)
+ return;
+
+ ((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
+
+ switch (((Label)sender).Name)
+ {
+ case "BaseColorLabel":
+ _tanker.SetBaseColor((Color)e.Data.GetData(typeof(Color)));
+
+ break;
+ case "AddColorLabel":
+ if (_tanker is DrawGasolineTanker)
+ {
+ (_tanker as DrawGasolineTanker).SetAddColor((Color)e.Data.GetData(typeof(Color)));
+ }
+ break;
+ }
+ DrawTanker();
+ }
+ }
+}
diff --git a/Lab/FormTankerConfig.resx b/Lab/FormTankerConfig.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/Lab/FormTankerConfig.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/Lab/GasolineTanker.cs b/Lab/GasolineTanker.cs
index 984ff73..69a78d4 100644
--- a/Lab/GasolineTanker.cs
+++ b/Lab/GasolineTanker.cs
@@ -20,6 +20,9 @@ namespace Lab.Entities
SportLine = sportLine;
}
-
+ public void ChangeAddColor(Color color)
+ {
+ AdditionalColor = color;
+ }
}
}