Reworked the JSON serialisation

This commit is contained in:
2023-05-11 14:23:44 +02:00
parent 57028f1fc9
commit 025c2f8d61
6 changed files with 219 additions and 191 deletions
+6 -6
View File
@@ -36,7 +36,7 @@ namespace Test_Merge
public string GrandPrixName { get => _grandPrixName; private set => _grandPrixName = value; }
public int GrandPrixYear { get => _grandPrixYear; private set => _grandPrixYear = value; }
public List<string> DriverList { get => _driverList; private set => _driverList = value; }
public string SelectedConfigFile { get => _selectedConfigFile;private set => _selectedConfigFile = value; }
public string SelectedConfigFile { get => _selectedConfigFile; private set => _selectedConfigFile = value; }
public Settings()
{
@@ -49,7 +49,7 @@ namespace Test_Merge
}
private void RefreshUI()
{
lsbDrivers.DataSource = null;
lsbDrivers.DataSource = DriverList;
@@ -94,7 +94,7 @@ namespace Test_Merge
if (Config != null)
{
pbxMain.Image = Config.MainZone.Draw();
if(Config.MainZone.Zones.Count > 0)
if (Config.MainZone.Zones.Count > 0)
pbxDriverZone.Image = Config.MainZone.Zones[0].Draw();
}
}
@@ -384,7 +384,7 @@ namespace Test_Merge
string presetName = tbxPresetName.Text;
if (Config != null)
{
Config.SaveToJson(DriverList,presetName);
Config.SaveToJson(DriverList, presetName);
}
RefreshUI();
}
@@ -396,17 +396,17 @@ namespace Test_Merge
private void btnLoadPreset_Click(object sender, EventArgs e)
{
//MessageBox.Show(lsbPresets.SelectedIndex.ToString());
if (lsbPresets.SelectedIndex >= 0 && pbxMain.Image != null)
{
try
{
string fileName = lsbPresets.Items[lsbPresets.SelectedIndex].ToString();
Reader reader = new Reader(fileName, (Bitmap)pbxMain.Image,false);
Reader reader = new Reader(fileName, (Bitmap)pbxMain.Image, false);
//MainZones #0 is the big main zone containing driver zones
Config = new ConfigurationTool((Bitmap)pbxMain.Image, reader.MainZones[0].Bounds);
Config.MainZone = reader.MainZones[0];
DriverList = reader.Drivers;
SelectedConfigFile = fileName;
}
catch (Exception ex)