You can now save presets to JSON and load them
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Test_Merge
|
||||
private List<Zone> _zones;
|
||||
private List<Window> _windows;
|
||||
private Bitmap _image;
|
||||
private string _name;
|
||||
|
||||
public Bitmap ZoneImage
|
||||
{
|
||||
@@ -46,11 +47,13 @@ namespace Test_Merge
|
||||
public Rectangle Bounds { get => _bounds; protected set => _bounds = value; }
|
||||
public List<Zone> Zones { get => _zones; protected set => _zones = value; }
|
||||
public List<Window> Windows { get => _windows; protected set => _windows = value; }
|
||||
public string Name { get => _name; protected set => _name = value; }
|
||||
|
||||
public Zone(Bitmap image, Rectangle bounds)
|
||||
public Zone(Bitmap image, Rectangle bounds, string name)
|
||||
{
|
||||
Windows = new List<Window>();
|
||||
Zones = new List<Zone>();
|
||||
Name = name;
|
||||
|
||||
//You cant set the image in the CTOR because the processing is impossible at first initiation
|
||||
_image = image;
|
||||
@@ -97,13 +100,13 @@ namespace Test_Merge
|
||||
if (w is DriverSectorWindow)
|
||||
{
|
||||
sectorCount++;
|
||||
if (sectorCount == 1)
|
||||
if (sectorCount == 1)
|
||||
result.Sector1 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
if (sectorCount == 2)
|
||||
result.Sector2 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
if (sectorCount == 3)
|
||||
result.Sector3 = (int)await (w as DriverSectorWindow).DecodePng();
|
||||
}
|
||||
}
|
||||
if (w is DriverTyresWindow)
|
||||
result.CurrentTyre = (Tyre)await (w as DriverTyresWindow).DecodePng();
|
||||
});
|
||||
@@ -122,16 +125,16 @@ namespace Test_Merge
|
||||
{
|
||||
img = ZoneImage;
|
||||
}
|
||||
|
||||
|
||||
Graphics g = Graphics.FromImage(img);
|
||||
|
||||
//If its the main zone we need to visualize the Zone bounds displayed
|
||||
if (Zones.Count > 0)
|
||||
g.DrawRectangle(new Pen(Brushes.Violet,5),Bounds);
|
||||
g.DrawRectangle(new Pen(Brushes.Violet, 5), Bounds);
|
||||
|
||||
foreach (Zone z in Zones)
|
||||
{
|
||||
Rectangle newBounds = new Rectangle(z.Bounds.X,z.Bounds.Y + Bounds.Y,z.Bounds.Width,z.Bounds.Height);
|
||||
Rectangle newBounds = new Rectangle(z.Bounds.X, z.Bounds.Y + Bounds.Y, z.Bounds.Width, z.Bounds.Height);
|
||||
g.DrawRectangle(Pens.Red, newBounds);
|
||||
}
|
||||
foreach (Window w in Windows)
|
||||
@@ -155,7 +158,7 @@ namespace Test_Merge
|
||||
public virtual string ToJSON()
|
||||
{
|
||||
string result = "";
|
||||
result += "\"" + "Zone" + "\":{" + Environment.NewLine;
|
||||
result += "\"" + Name + "\":{" + Environment.NewLine;
|
||||
result += "\t" + "\"x\":" + Bounds.X + "," + Environment.NewLine;
|
||||
result += "\t" + "\"y\":" + Bounds.Y + "," + Environment.NewLine;
|
||||
result += "\t" + "\"width\":" + Bounds.Width + "," + Environment.NewLine;
|
||||
|
||||
Reference in New Issue
Block a user