Еще изменения

This commit is contained in:
ArtemEmelyanov 2022-11-10 21:40:24 +04:00
parent f8259e6949
commit f186addd69
8 changed files with 24 additions and 50 deletions

View File

@ -77,11 +77,5 @@ namespace Airbus
}
}
public DrawningAirbus SetDopColor(int? speed = null, float? weight = null, Color? bodyColor = null, Color? dopColor = null, bool? bodyKit = null, bool? wing = null, bool? sportLine = null)
{
var b = (EntityAirbus)Plane;
return new DrawningAirbus(speed ?? b.Speed, weight ?? b.Weight, bodyColor ?? b.BodyColor, dopColor ?? b.DopColor,bodyKit ?? b.BodyKit, wing ?? b.Wing, sportLine ?? b.SportLine);
}
}
}

View File

@ -185,10 +185,5 @@ namespace Airbus
{
return (_startPosX, _startPosY, _startPosX + _PlaneWidth, _startPosY + _PlaneHeight);
}
public DrawningPlane SetBaseColor(int? speed = null, float? weight = null, Color? bodyColor = null)
{
return new DrawningPlane(speed ?? Plane.Speed, weight ?? Plane.Weight, bodyColor ?? Plane.BodyColor);
}
}
}

View File

@ -11,7 +11,7 @@ namespace Airbus
/// <summary>
/// Дополнительный цвет
/// </summary>
public Color DopColor { get; private set; }
public Color DopColor { get; set; }
/// <summary>
/// Признак наличия обвеса
/// </summary>

View File

@ -19,7 +19,7 @@ namespace Airbus
/// <summary>
/// Цвет кузова
/// </summary>
public Color BodyColor { get; private set; }
public Color BodyColor { get; set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>

View File

@ -113,7 +113,7 @@ namespace Airbus
private void buttonAddPlane_Click_1(object sender, EventArgs e)
{
var formPlaneConfig = new FormPlaneConfig();
formPlaneConfig.AddEvent(new PlaneDelegate(AddPlane));
formPlaneConfig.AddEvent(AddPlane);
// TODO
formPlaneConfig.Show();
}

View File

@ -75,7 +75,7 @@
this.groupBoxConfig.Controls.Add(this.labelSpeed);
this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
this.groupBoxConfig.Name = "groupBoxConfig";
this.groupBoxConfig.Size = new System.Drawing.Size(469, 175);
this.groupBoxConfig.Size = new System.Drawing.Size(498, 175);
this.groupBoxConfig.TabIndex = 0;
this.groupBoxConfig.TabStop = false;
this.groupBoxConfig.Text = "Параметры";
@ -83,7 +83,7 @@
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(361, 130);
this.labelModifiedObject.Location = new System.Drawing.Point(396, 130);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(96, 35);
this.labelModifiedObject.TabIndex = 7;
@ -94,7 +94,7 @@
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(263, 130);
this.labelSimpleObject.Location = new System.Drawing.Point(298, 130);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(92, 35);
this.labelSimpleObject.TabIndex = 1;
@ -112,7 +112,7 @@
this.groupBoxColor.Controls.Add(this.panelYellow);
this.groupBoxColor.Controls.Add(this.panelGreen);
this.groupBoxColor.Controls.Add(this.panelRed);
this.groupBoxColor.Location = new System.Drawing.Point(263, 15);
this.groupBoxColor.Location = new System.Drawing.Point(298, 15);
this.groupBoxColor.Name = "groupBoxColor";
this.groupBoxColor.Size = new System.Drawing.Size(194, 112);
this.groupBoxColor.TabIndex = 1;
@ -196,9 +196,9 @@
this.checkBoxSportLine.AutoSize = true;
this.checkBoxSportLine.Location = new System.Drawing.Point(17, 146);
this.checkBoxSportLine.Name = "checkBoxSportLine";
this.checkBoxSportLine.Size = new System.Drawing.Size(226, 19);
this.checkBoxSportLine.Size = new System.Drawing.Size(254, 19);
this.checkBoxSportLine.TabIndex = 6;
this.checkBoxSportLine.Text = "Признак наличия гоночной полосы";
this.checkBoxSportLine.Text = "Признак наличия отсека для пассажиров";
this.checkBoxSportLine.UseVisualStyleBackColor = true;
//
// checkBoxWing
@ -216,9 +216,9 @@
this.checkBoxBodyKit.AutoSize = true;
this.checkBoxBodyKit.Location = new System.Drawing.Point(17, 96);
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
this.checkBoxBodyKit.Size = new System.Drawing.Size(164, 19);
this.checkBoxBodyKit.Size = new System.Drawing.Size(210, 19);
this.checkBoxBodyKit.TabIndex = 4;
this.checkBoxBodyKit.Text = "Признак наличия обвеса";
this.checkBoxBodyKit.Text = "Признак наличия доп.двигателей";
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
@ -267,7 +267,7 @@
this.panelObject.Controls.Add(this.labelBaseColor);
this.panelObject.Controls.Add(this.labelDopColor);
this.panelObject.Controls.Add(this.pictureBoxObject);
this.panelObject.Location = new System.Drawing.Point(500, 12);
this.panelObject.Location = new System.Drawing.Point(522, 12);
this.panelObject.Name = "panelObject";
this.panelObject.Size = new System.Drawing.Size(251, 150);
this.panelObject.TabIndex = 1;
@ -302,7 +302,7 @@
//
// buttonOk
//
this.buttonOk.Location = new System.Drawing.Point(516, 168);
this.buttonOk.Location = new System.Drawing.Point(522, 168);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(100, 23);
this.buttonOk.TabIndex = 2;
@ -312,7 +312,7 @@
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(639, 168);
this.buttonCancel.Location = new System.Drawing.Point(677, 168);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(96, 23);
this.buttonCancel.TabIndex = 3;
@ -323,7 +323,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(764, 193);
this.ClientSize = new System.Drawing.Size(785, 193);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.panelObject);

View File

@ -19,7 +19,7 @@ namespace Airbus
/// <summary>
/// Событие
/// </summary>
private event PlaneDelegate EventAddPlane;
private event Action<DrawningPlane> EventAddPlane;
/// <summary>
/// Конструктор
/// </summary>
@ -52,11 +52,11 @@ namespace Airbus
/// Добавление события
/// </summary>
/// <param name="ev"></param>
public void AddEvent(PlaneDelegate ev)
public void AddEvent(Action<DrawningPlane> ev)
{
if (EventAddPlane == null)
{
EventAddPlane = new PlaneDelegate(ev);
EventAddPlane = new Action<DrawningPlane>(ev);
}
else
{
@ -142,16 +142,11 @@ namespace Airbus
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
{
// TODO Call method from object _car and set color
var color = (Color)e.Data.GetData(typeof(Color));
if (_plane is DrawningAirbus)
if (_plane == null)
{
_plane = ((DrawningAirbus)_plane).SetBaseColor(bodyColor: color);
}
else if (_plane is DrawningAirbus)
{
_plane = _plane.SetBaseColor(bodyColor: color);
return;
}
_plane.Plane.BodyColor = (Color)e.Data.GetData(typeof(Color));
DrawPlane();
}
/// <summary>
@ -161,11 +156,11 @@ namespace Airbus
/// <param name="e"></param>
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
{
var color = (Color)e.Data.GetData(typeof(Color));
if (_plane is DrawningAirbus)
if (_plane == null || _plane.Plane is not EntityAirbus airbus)
{
_plane = ((DrawningAirbus)_plane).SetDopColor(dopColor: color);
return;
}
airbus.DopColor = (Color)e.Data.GetData(typeof(Color));
DrawPlane();
}
/// <summary>

View File

@ -1,10 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Airbus
{
public delegate void PlaneDelegate(DrawningPlane plane);
}