Редактирования по 5 лабораторной
This commit is contained in:
parent
129ed2e33c
commit
f711ae5b81
@ -17,11 +17,11 @@ namespace RoadTrain.DrawningObjects
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
protected int _pictureWidth;
|
||||
public int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
protected int _pictureHeight;
|
||||
public int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки автомобиля
|
||||
/// </summary>
|
||||
@ -178,5 +178,9 @@ DrawningObjectTrain(this);
|
||||
g.FillEllipse(br, _startPosX + 60, _startPosY + 20, 10, 10);
|
||||
g.FillRectangle(br, _startPosX + 60, _startPosY, 10, 20);
|
||||
}
|
||||
public void SetBodyColor(Color color)
|
||||
{
|
||||
EntityRoadTrain.SetBodyColor(color);
|
||||
}
|
||||
}
|
||||
}
|
@ -50,7 +50,10 @@ namespace RoadTrain.DrawningObjects
|
||||
g.DrawLine(pen, _startPosX + 20, _startPosY + 10, _startPosX + 10, _startPosY + 30);
|
||||
g.DrawLine(pen, _startPosX + 17, _startPosY + 30, _startPosX + 3, _startPosY + 30);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public void SetAdditionalColor(Color color)
|
||||
{
|
||||
(EntityRoadTrain as EntityTrain).SetAdditionalColor(color);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,9 +20,10 @@ namespace RoadTrain.Entities
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; protected set; }
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public void SetBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса поезда
|
||||
|
@ -15,6 +15,10 @@ namespace RoadTrain.Entities
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public void SetAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия обвеса
|
||||
/// </summary>
|
||||
|
@ -44,33 +44,34 @@ pictureBoxCollection.Height);
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddTrain_Click(object sender, EventArgs e)
|
||||
private void AddTrain(DrawningRoadTrain train)
|
||||
{
|
||||
train._pictureWidth = pictureBoxCollection.Width;
|
||||
train._pictureHeight = pictureBoxCollection.Height;
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormRoadTrain form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (obj + train != -1)
|
||||
{
|
||||
if (obj + form.SelectedTrain != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowTrains();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowTrains();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
private void ButtonAddTrain_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formTrainConfig = new FormTrainConfig();
|
||||
formTrainConfig.AddEvent(AddTrain);
|
||||
formTrainConfig.Show();
|
||||
}
|
||||
|
||||
private void ButtonRemoveTrain_Click(object sender, EventArgs e)
|
||||
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using RoadTrain.MovementStrategy;
|
||||
using RoadTrain.DrawningObjects;
|
||||
using RoadTrain.Entities;
|
||||
|
||||
namespace RoadTrain
|
||||
{
|
||||
@ -110,6 +111,7 @@ namespace RoadTrain
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawTrain();
|
||||
}
|
||||
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user