From 25b16cfdf9ac6f0483b1d90a86a27272b2393e58 Mon Sep 17 00:00:00 2001 From: "evasina2312@gmail.com" Date: Thu, 24 Nov 2022 01:00:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectMachine/ProjectMachine/DrawningMachine.cs | 5 +++++ ProjectMachine/ProjectMachine/DrawningTank.cs | 9 +++++++-- ProjectMachine/ProjectMachine/EntityTank.cs | 4 +--- ProjectMachine/ProjectMachine/FormTankConfig.cs | 14 +++++++++----- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ProjectMachine/ProjectMachine/DrawningMachine.cs b/ProjectMachine/ProjectMachine/DrawningMachine.cs index be8ed7e..dc37083 100644 --- a/ProjectMachine/ProjectMachine/DrawningMachine.cs +++ b/ProjectMachine/ProjectMachine/DrawningMachine.cs @@ -177,5 +177,10 @@ namespace ProjectMachine { return (_startPosX, _startPosX + _machineWidth, _startPosY, _startPosY + _machineHeight); } + + public virtual void SetBaseColor(Color color) + { + Machine = new EntityMachine(Machine.Speed, Machine.Weight, color); + } } } diff --git a/ProjectMachine/ProjectMachine/DrawningTank.cs b/ProjectMachine/ProjectMachine/DrawningTank.cs index 9b54b99..dfb9813 100644 --- a/ProjectMachine/ProjectMachine/DrawningTank.cs +++ b/ProjectMachine/ProjectMachine/DrawningTank.cs @@ -17,10 +17,10 @@ namespace ProjectMachine /// Дополнительный цвет /// Признак наличия башни с орудием /// Признак наличия зенитного пулемета - public DrawningTank(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool turret, bool gun) : + public DrawningTank(int speed, float weight, Color bodyColor, Color dopColor, bool turret, bool gun) : base(speed, weight, bodyColor, 90, 50) { - Machine = new EntityTank(speed, weight, bodyColor, dopColor, bodyKit, turret, gun); + Machine = new EntityTank(speed, weight, bodyColor, dopColor, turret, gun); } public override void DrawTransport(Graphics g) { @@ -50,5 +50,10 @@ namespace ProjectMachine _startPosX -= 10; _startPosY -= 5; } + public void SetDopColor(Color color) + { + Machine = new EntityTank(Machine.Speed, Machine.Weight, Machine.BodyColor, + color, (Machine as EntityTank).Turret, (Machine as EntityTank).Gun); + } } } diff --git a/ProjectMachine/ProjectMachine/EntityTank.cs b/ProjectMachine/ProjectMachine/EntityTank.cs index 342293a..2ea3184 100644 --- a/ProjectMachine/ProjectMachine/EntityTank.cs +++ b/ProjectMachine/ProjectMachine/EntityTank.cs @@ -34,14 +34,12 @@ namespace ProjectMachine /// Вес автомобиля /// Цвет кузова /// Дополнительный цвет - /// /// Признак наличия обвеса /// Признак наличия башни с орудием /// Признак наличия зенитного пулемета - public EntityTank(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool turret, bool gun) : + public EntityTank(int speed, float weight, Color bodyColor, Color dopColor, bool turret, bool gun) : base(speed, weight, bodyColor) { DopColor = dopColor; - BodyKit = bodyKit; Turret = turret; Gun = gun; } diff --git a/ProjectMachine/ProjectMachine/FormTankConfig.cs b/ProjectMachine/ProjectMachine/FormTankConfig.cs index 86d8b72..cecfc87 100644 --- a/ProjectMachine/ProjectMachine/FormTankConfig.cs +++ b/ProjectMachine/ProjectMachine/FormTankConfig.cs @@ -34,8 +34,7 @@ namespace ProjectMachine panelWhite.MouseDown += PanelColor_MouseDown; panelYellow.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown; - - // TODO buttonCancel.Click with lambda + buttonCancel.Click += (s, e) => Close(); } /// /// Отрисовать машину @@ -102,7 +101,7 @@ namespace ProjectMachine break; case "labelModifiedObject": _tank = new DrawningTank((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, - checkBoxBodyKit.Checked, checkBoxTurret.Checked, checkBoxGun.Checked); + checkBoxTurret.Checked, checkBoxGun.Checked); break; } DrawTank(); @@ -139,7 +138,7 @@ namespace ProjectMachine /// private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - // TODO Call method from object _car and set color + } /// /// Принимаем дополнительный цвет @@ -148,7 +147,12 @@ namespace ProjectMachine /// private void LabelDopColor_DragDrop(object sender, DragEventArgs e) { - // TODO Call method from object _car if _car is DrawningSportCar and set dop color + if (_tank is DrawningTank) + { + var tank = _tank as DrawningTank; + tank.SetDopColor((Color)e.Data.GetData(typeof(Color))); + } + DrawTank(); } /// /// Добавление машины