5 лаба готова

This commit is contained in:
a.puchkina 2023-11-19 02:21:21 +04:00
parent 329ffa2e48
commit 545ac210cf
6 changed files with 12 additions and 59 deletions

View File

@ -229,6 +229,10 @@ namespace AirplaneWithRadar.DrawningObjects
g.DrawLine(penBlack, new Point(_startPosX + 150, _startPosY + 72), new Point(_startPosX + 150, _startPosY + 55));
g.DrawLine(penBlack, new Point(_startPosX + 150, _startPosY + 72), new Point(_startPosX + 190, _startPosY + 55));
}
public void SetBodyColor(Color color)
{
EntityAirplane.BodyColor = color;
}
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
{
_pictureWidth = pictureBoxWidth;

View File

@ -64,6 +64,10 @@ namespace AirplaneWithRadar.DrawningObjects
g.FillPolygon(additionalBrush, new Point[] { new Point(_startPosX + 115, _startPosY + 65), new Point(_startPosX + 125, _startPosY + 72), new Point(_startPosX + 115, _startPosY + 80) });
}
}
public void SetAddColor(Color color)
{
(EntityAirplane as EntityAirplaneWithRadar).AdditionalColor = color;
}
}
}

View File

@ -22,7 +22,7 @@ namespace AirplaneWithRadar.Entities
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
public Color BodyColor { get; set; }
/// <summary>
/// Шаг перемещения самолета
/// </summary>
@ -39,10 +39,5 @@ namespace AirplaneWithRadar.Entities
Weight = weight;
BodyColor = bodyColor;
}
internal void SetBodyColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -14,7 +14,7 @@ namespace AirplaneWithRadar.Entities
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; private set; }
public Color AdditionalColor { get; set; }
/// <summary>
/// Признак (опция) наличия радара
/// </summary>
@ -45,9 +45,5 @@ namespace AirplaneWithRadar.Entities
Tank = tank;
Pin = pin;
}
internal void SetAdditionalColor(Color color)
{
AdditionalColor = color;
}
}
}

View File

@ -103,25 +103,6 @@ namespace AirplaneWithRadar
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/**private void buttonAdd_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
string.Empty];
if (obj == null)
{
return;
}
var formAirplaneConfig = new FormAirplaneConfig();
formAirplaneConfig.AddEvent(AddAirplane);
formAirplaneConfig.Show();
}
**/
private void buttonAdd_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
@ -154,31 +135,6 @@ namespace AirplaneWithRadar
formAirplaneConfig.AddEvent(airplaneDelegate);
}
/**private void AddAirplane(DrawningAirplane drawningAirplane)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
string.Empty];
if (obj == null)
{
return;
}
if (obj + drawningAirplane)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowAirplanes();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}**/
/// <summary>
/// Удаление объекта из набора
/// </summary>

View File

@ -37,7 +37,6 @@ namespace AirplaneWithRadar
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
// TODO buttonCancel.Click with lambda +
buttonCancel.Click += (s, e) => Close();
}
/// <summary>
@ -116,7 +115,6 @@ namespace AirplaneWithRadar
}
DrawAirplane();
}
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
/// <summary>
/// Добавление самолета
@ -141,12 +139,12 @@ namespace AirplaneWithRadar
switch (((Label)sender).Name)
{
case "labelBodyColor":
_airplane?.EntityAirplane?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
_airplane.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
break;
case "labelAdditionalColor":
if (!(_airplane is DrawningAirplaneWithRadar))
return;
(_airplane.EntityAirplane as EntityAirplaneWithRadar)?.SetAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
(_airplane as DrawningAirplaneWithRadar).SetAddColor((Color)e.Data.GetData(typeof(Color)));
break;
}
DrawAirplane();