all done
This commit is contained in:
parent
3be2467d2f
commit
800dd3ae26
@ -4,15 +4,24 @@ namespace ElectricLocomotive;
|
|||||||
|
|
||||||
public class DrawingElectricLocomotiv : DrawingLocomotiv
|
public class DrawingElectricLocomotiv : DrawingLocomotiv
|
||||||
{
|
{
|
||||||
public DrawingElectricLocomotiv(int speed, double weight, int width, int height, Color mainColor, Color dopColor, Color batteryColor, Color rogaColor) : base(speed, weight, width,
|
private bool isBattery;
|
||||||
|
private bool isRoga;
|
||||||
|
public DrawingElectricLocomotiv(bool isBattery, bool isRoga, int speed, double weight, int width, int height, Color mainColor, Color dopColor, Color batteryColor, Color rogaColor) : base(speed, weight, width,
|
||||||
height, mainColor, dopColor)
|
height, mainColor, dopColor)
|
||||||
{
|
{
|
||||||
|
this.isBattery = isBattery;
|
||||||
|
this.isRoga = isRoga;
|
||||||
if (EntityLocomotiv != null)
|
if (EntityLocomotiv != null)
|
||||||
{
|
{
|
||||||
EntityLocomotiv = new EntityElectricLocomotiv(speed, weight, batteryColor, rogaColor, mainColor, dopColor);
|
EntityLocomotiv = new EntityElectricLocomotiv(speed, weight, batteryColor, rogaColor, mainColor, dopColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangeAddColor(Color col)
|
||||||
|
{
|
||||||
|
((EntityElectricLocomotiv)EntityLocomotiv).BatteryColor = col;
|
||||||
|
((EntityElectricLocomotiv)EntityLocomotiv).RogaColor = col;
|
||||||
|
}
|
||||||
public override void DrawLoco(Graphics g)
|
public override void DrawLoco(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityLocomotiv == null) return;
|
if (EntityLocomotiv == null) return;
|
||||||
@ -20,11 +29,16 @@ public class DrawingElectricLocomotiv : DrawingLocomotiv
|
|||||||
if (EntityLocomotiv is not EntityElectricLocomotiv electricLocomotiv) return;
|
if (EntityLocomotiv is not EntityElectricLocomotiv electricLocomotiv) return;
|
||||||
SolidBrush batteryBrush = new(electricLocomotiv.BatteryColor);
|
SolidBrush batteryBrush = new(electricLocomotiv.BatteryColor);
|
||||||
Pen rogaPen = new(electricLocomotiv.RogaColor);
|
Pen rogaPen = new(electricLocomotiv.RogaColor);
|
||||||
//Roga
|
if (this.isRoga)
|
||||||
|
{
|
||||||
g.DrawLine(rogaPen, new Point(_startPosX + _vehicleWidth / 2, _startPosY + 30), new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15));
|
g.DrawLine(rogaPen, new Point(_startPosX + _vehicleWidth / 2, _startPosY + 30), new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15));
|
||||||
g.DrawLine(rogaPen, new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15), new Point(_startPosX + _vehicleWidth / 2, _startPosY));
|
g.DrawLine(rogaPen, new Point(_startPosX + _vehicleWidth / 2 + 10, _startPosY + 15), new Point(_startPosX + _vehicleWidth / 2, _startPosY));
|
||||||
//battery
|
}
|
||||||
|
|
||||||
|
if (this.isBattery)
|
||||||
|
{
|
||||||
Point[] batteryPoints = { new Point(_startPosX + _vehicleWidth - 10,_startPosY + _vehicleHeight - 25), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 20), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 55), new Point(_startPosX + _vehicleWidth - 10, _startPosY + _vehicleHeight - 50) };
|
Point[] batteryPoints = { new Point(_startPosX + _vehicleWidth - 10,_startPosY + _vehicleHeight - 25), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 20), new Point(_startPosX + _vehicleWidth, _startPosY + _vehicleHeight - 55), new Point(_startPosX + _vehicleWidth - 10, _startPosY + _vehicleHeight - 50) };
|
||||||
g.FillPolygon(batteryBrush, batteryPoints);
|
g.FillPolygon(batteryBrush, batteryPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -41,6 +41,14 @@ namespace ElectricLocomotive
|
|||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
EntityLocomotiv = new EntityLocomotiv(speed, weight, mainColor, dopColor);
|
EntityLocomotiv = new EntityLocomotiv(speed, weight, mainColor, dopColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangeColor(Color col)
|
||||||
|
{
|
||||||
|
if (EntityLocomotiv == null)
|
||||||
|
return;
|
||||||
|
EntityLocomotiv.ColorBody = col;
|
||||||
|
EntityLocomotiv.ColorWindow = col;
|
||||||
|
}
|
||||||
public bool CanMove(DirectionType direction)
|
public bool CanMove(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityLocomotiv == null)
|
if (EntityLocomotiv == null)
|
||||||
@ -96,6 +104,11 @@ namespace ElectricLocomotive
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||||
|
{
|
||||||
|
_pictureHeight = pictureBoxHeight;
|
||||||
|
_pictureWidth = pictureBoxWidth;
|
||||||
|
}
|
||||||
public virtual void DrawLoco(Graphics g)
|
public virtual void DrawLoco(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityLocomotiv == null) return;
|
if (EntityLocomotiv == null) return;
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
public class EntityElectricLocomotiv : EntityLocomotiv
|
public class EntityElectricLocomotiv : EntityLocomotiv
|
||||||
{
|
{
|
||||||
public Color BatteryColor { get; private set; }
|
public Color BatteryColor { get; set; }
|
||||||
public Color RogaColor { get; private set; }
|
public Color RogaColor { get; set; }
|
||||||
public EntityElectricLocomotiv(int speed,double weight, Color batteryColor, Color rogaColor, Color mainColor, Color dopColor) : base(speed, weight, mainColor, dopColor)
|
public EntityElectricLocomotiv(int speed,double weight, Color batteryColor, Color rogaColor, Color mainColor, Color dopColor) : base(speed, weight, mainColor, dopColor)
|
||||||
{
|
{
|
||||||
BatteryColor = batteryColor;
|
BatteryColor = batteryColor;
|
||||||
|
@ -9,8 +9,8 @@ namespace ElectricLocomotive
|
|||||||
{
|
{
|
||||||
public class EntityLocomotiv
|
public class EntityLocomotiv
|
||||||
{
|
{
|
||||||
public int Speed { get; private set; }
|
public int Speed { get; set; }
|
||||||
public double Weight { get; private set; }
|
public double Weight { get; set; }
|
||||||
public double Step => (double)Speed * 100 / Weight;
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
public Color ColorBody = Color.Black;
|
public Color ColorBody = Color.Black;
|
||||||
public Color ColorWindow = Color.Blue;
|
public Color ColorWindow = Color.Blue;
|
||||||
|
@ -43,7 +43,7 @@ namespace ElectricLocomotive {
|
|||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
dopColor = dialog.Color;
|
dopColor = dialog.Color;
|
||||||
|
|
||||||
_drawingLocomotiv = new DrawingElectricLocomotiv(random.Next(100, 300), random.Next(1000, 3000), locoBox.Width, locoBox.Height, color, dopColor, batteryColor, rogaColor);
|
_drawingLocomotiv = new DrawingElectricLocomotiv(true, true, random.Next(100, 300), random.Next(1000, 3000), locoBox.Width, locoBox.Height, color, dopColor, batteryColor, rogaColor);
|
||||||
_drawingLocomotiv.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawingLocomotiv.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
@ -30,17 +30,22 @@ public partial class FormLocomotivCollection : Form {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FormLocomotiv form = new();
|
FormLocoConfig form = new();
|
||||||
if (form.ShowDialog() == DialogResult.OK) {
|
form.Show();
|
||||||
if (obj + form.SelectedLocomotiv) {
|
Action<DrawingLocomotiv>? monorailDelegate = new((m) => {
|
||||||
|
bool q = (obj + m);
|
||||||
|
if (q)
|
||||||
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
|
m.ChangePictureBoxSize(collectionPictureBox.Width, collectionPictureBox.Height);
|
||||||
collectionPictureBox.Image = obj.ShowLocos();
|
collectionPictureBox.Image = obj.ShowLocos();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
form.AddEvent(monorailDelegate);
|
||||||
}
|
}
|
||||||
private void deleteLoco_Click(object sender, EventArgs e) {
|
private void deleteLoco_Click(object sender, EventArgs e) {
|
||||||
if (storageListBox.SelectedIndex == -1) {
|
if (storageListBox.SelectedIndex == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user