Функционал
This commit is contained in:
parent
6b25163fc1
commit
16f6e435d5
@ -44,5 +44,15 @@ namespace Ship
|
||||
g.FillEllipse(dopBrush, _startPosX + 40, _startPosY + 55, 20, 10);
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetColor(Color color)
|
||||
{
|
||||
Ship = new EntityMotorShip(Ship.Speed, Ship.Weight, color, (Ship as EntityMotorShip).DopColor, (Ship as EntityMotorShip).Pipes, (Ship as EntityMotorShip).Fueltank);
|
||||
}
|
||||
|
||||
public void SetDopColor(Color color)
|
||||
{
|
||||
Ship = new EntityMotorShip(Ship.Speed, Ship.Weight, (Ship as EntityMotorShip).BodyColor, color, (Ship as EntityMotorShip).Pipes, (Ship as EntityMotorShip).Fueltank);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +178,11 @@ namespace Ship
|
||||
}
|
||||
}
|
||||
|
||||
virtual public void SetColor(Color color)
|
||||
{
|
||||
Ship = new EntityShip(Ship.Speed, Ship.Weight, color);
|
||||
}
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosX + _shipWidth, _startPosY, _startPosY + _shipHeight);
|
||||
|
@ -124,15 +124,14 @@ namespace Ship
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
FormShipConfig form = new FormShipConfig();
|
||||
form.AddEvent((ship) =>
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormShip form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DrawingObject car = new(form.SelectedShip);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + car != -1)
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObject(ship) != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
@ -141,7 +140,10 @@ namespace Ship
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
|
||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].ShowSet();
|
||||
});
|
||||
form.Show();
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
|
2
Ship/Ship/FormShipConfig.Designer.cs
generated
2
Ship/Ship/FormShipConfig.Designer.cs
generated
@ -298,6 +298,7 @@
|
||||
this.buttonOk.TabIndex = 5;
|
||||
this.buttonOk.Text = "Добавить";
|
||||
this.buttonOk.UseVisualStyleBackColor = true;
|
||||
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
@ -328,6 +329,7 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -19,7 +19,7 @@ namespace Ship
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event ShipDelegate EventAddShip;
|
||||
private event Action<DrawingShip> EventAddShip;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -35,7 +35,7 @@ namespace Ship
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
// TODO buttonCancel.Click with lambda
|
||||
buttonCancel.Click += (sender, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать машину
|
||||
@ -52,11 +52,11 @@ namespace Ship
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev"></param>
|
||||
public void AddEvent(ShipDelegate ev)
|
||||
public void AddEvent(Action<DrawingShip> ev)
|
||||
{
|
||||
if (EventAddShip == null)
|
||||
{
|
||||
EventAddShip = new ShipDelegate(ev);
|
||||
EventAddShip = new Action<DrawingShip>(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -139,6 +139,8 @@ namespace Ship
|
||||
/// <param name="e"></param>
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
_ship.SetColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawShip();
|
||||
}
|
||||
/// <summary>
|
||||
/// Принимаем дополнительный цвет
|
||||
@ -147,7 +149,11 @@ namespace Ship
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
// TODO Call method from object _car if _car is DrawningSportCar and set dop color
|
||||
if(_ship is DrawingMotorShip ship)
|
||||
{
|
||||
ship.SetDopColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawShip();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление машины
|
||||
|
Loading…
x
Reference in New Issue
Block a user