Создан класс ExtentionLocomotive, решена проблема с именами цветов в FormLocomotiveConfig
This commit is contained in:
parent
75190e8594
commit
032bf5d2a2
48
Locomotive/Locomotive/ExtentionLocomotive.cs
Normal file
48
Locomotive/Locomotive/ExtentionLocomotive.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Locomotive
|
||||||
|
{
|
||||||
|
internal static class ExtentionLocomotive
|
||||||
|
{
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
|
public static string getDataForSave(this DrawningLocomotive drawningLocomotive)
|
||||||
|
{
|
||||||
|
var locomotive = drawningLocomotive.Locomotive;
|
||||||
|
var str = $"{locomotive.Speed}{_separatorForObject}{locomotive.Weight}{_separatorForObject}{locomotive.BodyColor.Name}";
|
||||||
|
if (locomotive is not EntityWarmlyLocomotive warmlyLocomotive)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return $"{str}{_separatorForObject}{warmlyLocomotive.ExtraColor.Name}{_separatorForObject}{warmlyLocomotive.Pipe}{_separatorForObject}{warmlyLocomotive.FuelStorage}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DrawningLocomotive createDrawningLocomotive(this string info)
|
||||||
|
{
|
||||||
|
string[] strs = info.Split(_separatorForObject);
|
||||||
|
if (strs.Length == 3)
|
||||||
|
{
|
||||||
|
return new DrawningLocomotive(
|
||||||
|
Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]),
|
||||||
|
Color.FromName(strs[2])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (strs.Length == 6)
|
||||||
|
{
|
||||||
|
return new DrawningWarmlyLocomotive(
|
||||||
|
Convert.ToInt32(strs[0]),
|
||||||
|
Convert.ToInt32(strs[1]),
|
||||||
|
Color.FromName(strs[2]),
|
||||||
|
Color.FromName(strs[3]),
|
||||||
|
Convert.ToBoolean(strs[4]),
|
||||||
|
Convert.ToBoolean(strs[5])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -159,7 +159,7 @@
|
|||||||
//
|
//
|
||||||
// panelGreen
|
// panelGreen
|
||||||
//
|
//
|
||||||
this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
|
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||||
this.panelGreen.Location = new System.Drawing.Point(72, 31);
|
this.panelGreen.Location = new System.Drawing.Point(72, 31);
|
||||||
this.panelGreen.Name = "panelGreen";
|
this.panelGreen.Name = "panelGreen";
|
||||||
this.panelGreen.Size = new System.Drawing.Size(43, 40);
|
this.panelGreen.Size = new System.Drawing.Size(43, 40);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user