Добавлено изменение цвета панели определенного автомобиля

This commit is contained in:
2024-10-10 13:47:29 +03:00
parent 5dc3e6269c
commit 7f178888a5
42 changed files with 644 additions and 399 deletions

View File

@@ -0,0 +1,64 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GtaVUsersInfo.Sources
{
[Serializable]
public class PanelColorSettings
{
public Color leftPanel;
public Color rightPanel;
public Color centerPanel;
public Color upDownPanel;
public PanelColorSettings() { }
public PanelColorSettings(Color left, Color right, Color center, Color upDown)
{
leftPanel = left;
rightPanel = right;
centerPanel = center;
upDownPanel = upDown;
}
public static void SavePanelSettings(PanelColorSettings color)
{
string json = JsonConvert.SerializeObject(color, Formatting.Indented);
if (!Directory.Exists(Path.GetDirectoryName(Resources.paneColorlSettingsJsonPath)))
{
Directory.CreateDirectory(Path.GetDirectoryName(Resources.paneColorlSettingsJsonPath));
}
File.WriteAllText(Resources.paneColorlSettingsJsonPath, json);
}
public static PanelColorSettings LoadPanelSettings()
{
try
{
string json = File.ReadAllText(Resources.paneColorlSettingsJsonPath);
return JsonConvert.DeserializeObject<PanelColorSettings>(json);
}
catch (FileNotFoundException)
{
Console.WriteLine($"Файл с цветами панелей не найден: {Resources.paneColorlSettingsJsonPath}");
return null;
}
catch (JsonException ex)
{
Console.WriteLine($"Ошибка при десериализации JSON с цветами панелей: {ex.Message}");
return null;
}
catch (Exception ex)
{
Console.WriteLine($"Произошла неожиданная ошибка при открытии файла с цветами панелей: {ex.Message}");
return null;
}
}
}
}

View File

@@ -14,24 +14,27 @@ namespace GtaVUsersInfo.Sources
public int height;
public int leftPos;
public int rightPos;
public bool isFullScreen;
public string? prevFile;
public WindowParameters() { }
public WindowParameters(Size window, Size pos)
public WindowParameters(Size window, Size pos, bool isfull)
{
width = window.Width;
height = window.Height;
leftPos = pos.Width;
rightPos = pos.Height;
isFullScreen = isfull;
}
public WindowParameters(Size window, Size pos, string file)
public WindowParameters(Size window, Size pos, bool isfull, string file)
{
width = window.Width;
height = window.Height;
leftPos = pos.Width;
rightPos = pos.Height;
isFullScreen = isfull;
prevFile = file;
}