One more commit
This commit is contained in:
parent
cb4f543211
commit
5cdfffaddd
@ -23,11 +23,12 @@ namespace ProjectPlane
|
||||
{
|
||||
Plane = new EntityWarPlane(speed, weight, bodyColor, dopColor, extraCell, superTurbine);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
|
||||
|
||||
if (Plane is not EntityWarPlane warplane)
|
||||
if (Plane is not EntityWarPlane warplane)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -69,5 +70,19 @@ namespace ProjectPlane
|
||||
}
|
||||
|
||||
}
|
||||
public void setDopColor(Color color)
|
||||
{
|
||||
if (Plane is EntityWarPlane)
|
||||
{
|
||||
var p = Plane as EntityWarPlane;
|
||||
if (p is not null)
|
||||
{
|
||||
p = new EntityWarPlane(p.Speed, p.Weight, p.BodyColor, color, p.extraCell, p.SuperTurbine);
|
||||
Plane = p;
|
||||
}
|
||||
else
|
||||
Plane = new EntityPlane(Plane.Speed, Plane.Weight, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,5 +239,19 @@ namespace ProjectPlane
|
||||
{
|
||||
return (_startPosX, _startPosX + _planeWidth, _startPosY , _startPosY + _planeHeight);
|
||||
}
|
||||
public void setBaseColor(Color color)
|
||||
{
|
||||
if (Plane is EntityWarPlane)
|
||||
{
|
||||
var p = Plane as EntityWarPlane;
|
||||
if (p is not null)
|
||||
{
|
||||
p = new EntityWarPlane(p.Speed, p.Weight, color, p.DopColor, p.extraCell, p.SuperTurbine);
|
||||
Plane = p; return;
|
||||
}
|
||||
|
||||
Plane = new EntityPlane(Plane.Speed, Plane.Weight, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -78,25 +78,27 @@ namespace ProjectPlane
|
||||
private void ButtonAddPlane_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formPlaneConfig = new FormPlaneConfig();
|
||||
|
||||
formPlaneConfig.AddEvent(new (AddPlane));
|
||||
formPlaneConfig.Show();
|
||||
}
|
||||
private void AddPlane(DrawingPlane plane)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormPlane form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObject(plane) != -1)
|
||||
{
|
||||
DrawingObject Plane = new(form.SelectedPlane);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + Plane != -1)
|
||||
{
|
||||
MessageBox.Show("Object added");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Error with object adding");
|
||||
}
|
||||
MessageBox.Show("Object added");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
formPlaneConfig.Show();
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Failed to add object");
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
|
@ -93,8 +93,8 @@
|
||||
{
|
||||
dopColor = dialogDop.Color;
|
||||
}
|
||||
//_plane = new DrawingWarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||
// Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
_plane = new DrawingWarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
|
@ -286,6 +286,8 @@
|
||||
this.labelDopColor.TabIndex = 2;
|
||||
this.labelDopColor.Text = "Extra color";
|
||||
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
|
||||
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragEnter);
|
||||
//
|
||||
// labelBaseColor
|
||||
//
|
||||
@ -297,6 +299,8 @@
|
||||
this.labelBaseColor.TabIndex = 1;
|
||||
this.labelBaseColor.Text = "Color";
|
||||
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
|
||||
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
|
@ -139,7 +139,20 @@ namespace ProjectPlane
|
||||
/// <param name="e"></param>
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _Plane and set color
|
||||
_Plane.setBaseColor((Color)e.Data.GetData(typeof(Color)));
|
||||
|
||||
DrawPlane();
|
||||
}
|
||||
private void LabelDopColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Принимаем дополнительный цвет
|
||||
@ -148,7 +161,11 @@ namespace ProjectPlane
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _Plane if _Plane is DrawningSportPlane and set dop color
|
||||
if (_Plane is DrawingWarPlane)
|
||||
{
|
||||
(_Plane as DrawingWarPlane).setDopColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawPlane();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление машины
|
||||
|
@ -9,7 +9,7 @@ namespace ProjectPlane
|
||||
static void Main()
|
||||
{
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormPlaneConfig());
|
||||
Application.Run(new FormMapWithSetPlanes());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user