2024-10-10 13:47:29 +03:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-10 14:40:22 +03:00
|
|
|
|
|
|
|
|
|
public static void ChangeFontInControls(Control parent, Color color)
|
|
|
|
|
{
|
|
|
|
|
foreach (Control control in parent.Controls)
|
|
|
|
|
{
|
|
|
|
|
if (control is TextBox ||
|
|
|
|
|
control is Button ||
|
|
|
|
|
control is ComboBox ||
|
2024-10-10 14:52:29 +03:00
|
|
|
|
control is Label)
|
2024-10-10 14:40:22 +03:00
|
|
|
|
{
|
|
|
|
|
control.BackColor = color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (control.HasChildren)
|
|
|
|
|
{
|
|
|
|
|
ChangeFontInControls(control, color);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-10 13:47:29 +03:00
|
|
|
|
}
|
|
|
|
|
}
|