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(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; } } public static void ChangeFontInControls(Control parent, Color color) { foreach (Control control in parent.Controls) { if (control is TextBox || control is Button || control is ComboBox || control is Label) { control.BackColor = color; } if (control.HasChildren) { ChangeFontInControls(control, color); } } } } }