diff --git a/GtaVUsersInfo.csproj b/GtaVUsersInfo.csproj
index dab492c..d787df4 100644
--- a/GtaVUsersInfo.csproj
+++ b/GtaVUsersInfo.csproj
@@ -151,6 +151,7 @@
True
Resources.resx
+
CarItemMenuStrip.cs
@@ -206,6 +207,7 @@
+
diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index f8a742d..47d9760 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -38,8 +38,8 @@
this.addCar = new System.Windows.Forms.Button();
this.addParametrLabel = new System.Windows.Forms.Label();
this.parametersPanel = new System.Windows.Forms.Panel();
- this.menuStrip1 = new System.Windows.Forms.MenuStrip();
- this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.menuStrip = new System.Windows.Forms.MenuStrip();
+ this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsКакToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -47,11 +47,10 @@
this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.стилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.styleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.colorTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.styleTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.sizeTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.colorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonPanelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.parameterPanelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -61,9 +60,11 @@
this.splitterRigth = new System.Windows.Forms.Splitter();
this.carsPanel = new System.Windows.Forms.Panel();
this.carsItems = new System.Windows.Forms.FlowLayoutPanel();
+ this.defaultToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.panel1.SuspendLayout();
this.buttonsPanel.SuspendLayout();
- this.menuStrip1.SuspendLayout();
+ this.menuStrip.SuspendLayout();
this.carsPanel.SuspendLayout();
this.SuspendLayout();
//
@@ -178,9 +179,11 @@
//
this.addParametrLabel.AutoSize = true;
this.addParametrLabel.Dock = System.Windows.Forms.DockStyle.Top;
+ this.addParametrLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.addParametrLabel.Location = new System.Drawing.Point(3, 3);
this.addParametrLabel.Name = "addParametrLabel";
this.addParametrLabel.Padding = new System.Windows.Forms.Padding(3);
+ this.addParametrLabel.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.addParametrLabel.Size = new System.Drawing.Size(66, 19);
this.addParametrLabel.TabIndex = 1;
this.addParametrLabel.Text = "Добавить:";
@@ -196,21 +199,21 @@
this.parametersPanel.Size = new System.Drawing.Size(200, 419);
this.parametersPanel.TabIndex = 3;
//
- // menuStrip1
+ // menuStrip
//
- this.menuStrip1.BackColor = System.Drawing.Color.White;
- this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.файлToolStripMenuItem,
- this.стилиToolStripMenuItem});
- this.menuStrip1.Location = new System.Drawing.Point(0, 0);
- this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(764, 24);
- this.menuStrip1.TabIndex = 5;
- this.menuStrip1.Text = "menuStrip1";
+ this.menuStrip.BackColor = System.Drawing.Color.White;
+ this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.fileToolStripMenuItem,
+ this.styleToolStripMenuItem});
+ this.menuStrip.Location = new System.Drawing.Point(0, 0);
+ this.menuStrip.Name = "menuStrip";
+ this.menuStrip.Size = new System.Drawing.Size(764, 24);
+ this.menuStrip.TabIndex = 5;
+ this.menuStrip.Text = "menuStrip1";
//
- // файлToolStripMenuItem
+ // fileToolStripMenuItem
//
- this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.openFileToolStripMenuItem,
this.saveToolStripMenuItem,
this.saveAsКакToolStripMenuItem,
@@ -218,9 +221,9 @@
this.newToolStripMenuItem,
this.toolStripSeparator1,
this.exitToolStripMenuItem});
- this.файлToolStripMenuItem.Name = "файлToolStripMenuItem";
- this.файлToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
- this.файлToolStripMenuItem.Text = "Файл";
+ this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
+ this.fileToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
+ this.fileToolStripMenuItem.Text = "Файл";
//
// openFileToolStripMenuItem
//
@@ -241,6 +244,7 @@
this.saveAsКакToolStripMenuItem.Name = "saveAsКакToolStripMenuItem";
this.saveAsКакToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.saveAsКакToolStripMenuItem.Text = "Сохранить как";
+ this.saveAsКакToolStripMenuItem.Click += new System.EventHandler(this.saveAsКакToolStripMenuItem_Click);
//
// toolStripSeparator2
//
@@ -266,42 +270,39 @@
this.exitToolStripMenuItem.Text = "Выйти";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
- // стилиToolStripMenuItem
+ // styleToolStripMenuItem
//
- this.стилиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.styleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.textToolStripMenuItem,
this.colorToolStripMenuItem});
- this.стилиToolStripMenuItem.Name = "стилиToolStripMenuItem";
- this.стилиToolStripMenuItem.Size = new System.Drawing.Size(53, 20);
- this.стилиToolStripMenuItem.Text = "Стили";
+ this.styleToolStripMenuItem.Name = "styleToolStripMenuItem";
+ this.styleToolStripMenuItem.Size = new System.Drawing.Size(53, 20);
+ this.styleToolStripMenuItem.Text = "Стили";
//
// textToolStripMenuItem
//
this.textToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.colorTextToolStripMenuItem,
this.styleTextToolStripMenuItem,
- this.sizeTextToolStripMenuItem});
+ this.toolStripSeparator3,
+ this.defaultToolStripMenuItem});
this.textToolStripMenuItem.Name = "textToolStripMenuItem";
- this.textToolStripMenuItem.Size = new System.Drawing.Size(106, 22);
+ this.textToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.textToolStripMenuItem.Text = "Текст";
//
// colorTextToolStripMenuItem
//
this.colorTextToolStripMenuItem.Name = "colorTextToolStripMenuItem";
- this.colorTextToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+ this.colorTextToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.colorTextToolStripMenuItem.Text = "Цвет";
+ this.colorTextToolStripMenuItem.Click += new System.EventHandler(this.colorTextToolStripMenuItem_Click);
//
// styleTextToolStripMenuItem
//
this.styleTextToolStripMenuItem.Name = "styleTextToolStripMenuItem";
- this.styleTextToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+ this.styleTextToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.styleTextToolStripMenuItem.Text = "Стиль";
- //
- // sizeTextToolStripMenuItem
- //
- this.sizeTextToolStripMenuItem.Name = "sizeTextToolStripMenuItem";
- this.sizeTextToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
- this.sizeTextToolStripMenuItem.Text = "Размер";
+ this.styleTextToolStripMenuItem.Click += new System.EventHandler(this.styleTextToolStripMenuItem_Click);
//
// colorToolStripMenuItem
//
@@ -311,7 +312,7 @@
this.carPanelToolStripMenuItem,
this.top_downPanelToolStripMenuItem});
this.colorToolStripMenuItem.Name = "colorToolStripMenuItem";
- this.colorToolStripMenuItem.Size = new System.Drawing.Size(106, 22);
+ this.colorToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.colorToolStripMenuItem.Text = "Цвета";
//
// buttonPanelToolStripMenuItem
@@ -361,7 +362,6 @@
this.carsPanel.Controls.Add(this.carsItems);
this.carsPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.carsPanel.Location = new System.Drawing.Point(121, 44);
- this.carsPanel.MinimumSize = new System.Drawing.Size(300, 100);
this.carsPanel.Name = "carsPanel";
this.carsPanel.Size = new System.Drawing.Size(438, 419);
this.carsPanel.TabIndex = 8;
@@ -375,6 +375,18 @@
this.carsItems.Size = new System.Drawing.Size(436, 417);
this.carsItems.TabIndex = 0;
//
+ // defaultToolStripMenuItem
+ //
+ this.defaultToolStripMenuItem.Name = "defaultToolStripMenuItem";
+ this.defaultToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.defaultToolStripMenuItem.Text = "Стандартные";
+ this.defaultToolStripMenuItem.Click += new System.EventHandler(this.defaultToolStripMenuItem_Click);
+ //
+ // toolStripSeparator3
+ //
+ this.toolStripSeparator3.Name = "toolStripSeparator3";
+ this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6);
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -388,8 +400,8 @@
this.Controls.Add(this.buttonsPanel);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
- this.Controls.Add(this.menuStrip1);
- this.MainMenuStrip = this.menuStrip1;
+ this.Controls.Add(this.menuStrip);
+ this.MainMenuStrip = this.menuStrip;
this.MinimumSize = new System.Drawing.Size(526, 365);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@@ -400,8 +412,8 @@
this.panel1.PerformLayout();
this.buttonsPanel.ResumeLayout(false);
this.buttonsPanel.PerformLayout();
- this.menuStrip1.ResumeLayout(false);
- this.menuStrip1.PerformLayout();
+ this.menuStrip.ResumeLayout(false);
+ this.menuStrip.PerformLayout();
this.carsPanel.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -414,18 +426,17 @@
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel buttonsPanel;
private System.Windows.Forms.Panel parametersPanel;
- private System.Windows.Forms.MenuStrip menuStrip1;
- private System.Windows.Forms.ToolStripMenuItem файлToolStripMenuItem;
+ private System.Windows.Forms.MenuStrip menuStrip;
+ private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveAsКакToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem стилиToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem styleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem textToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem colorTextToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem styleTextToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem sizeTextToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem colorToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem buttonPanelToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem parameterPanelToolStripMenuItem;
@@ -443,6 +454,8 @@
private System.Windows.Forms.Button readJsonButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
+ private System.Windows.Forms.ToolStripMenuItem defaultToolStripMenuItem;
}
}
diff --git a/MainForm.cs b/MainForm.cs
index 3ad2714..220654c 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -17,6 +17,8 @@ using System.Data.Common;
using GtaVUsersInfo.Forms;
using System.Collections;
using System.Security.Cryptography;
+using GtaVUsersInfo.Sources;
+using OpenQA.Selenium.DevTools.V127.Page;
namespace GtaVUsersInfo
{
@@ -29,10 +31,20 @@ namespace GtaVUsersInfo
private List parameters;
private List cars;
+ private FontSettings fontSettings;
+
+ private Font defaultFont;
+ private Color defaultColor;
+
+ private List dtControls;
+
public MainForm()
{
InitializeComponent();
+ defaultFont = new Font("Arial", 11, FontStyle.Regular);
+ defaultColor = Color.Black;
+
debugControlsList = new List { parserButton, readJsonButton };
this.visible(debugControlsList, false);
@@ -44,6 +56,22 @@ namespace GtaVUsersInfo
carsItems.ContextMenuStrip = new CarPanelMenuStrip(addNewCar).Menu;
parametersPanel.ContextMenuStrip = new ParameterPanelMenuStrip(addNewParameter).Menu;
+
+ dtControls = new List { parserButton, readJsonButton };
+
+ fontSettings = FontSettings.LoadFontSettings();
+ if (fontSettings != null)
+ {
+ fontSettings.FontSettingsEdit(dtControls);
+ FontSettings.ChangeFontInControls(this, fontSettings);
+ }
+ else
+ {
+ fontSettings = new FontSettings(defaultFont, defaultColor, dtControls);
+ FontSettings.ChangeFontInControls(this, fontSettings);
+
+ FontSettings.SaveFontSettings(fontSettings);
+ }
}
private void MainForm_Load(object sender, EventArgs e)
@@ -55,6 +83,8 @@ namespace GtaVUsersInfo
{
ParameterPanelCreate();
CarPanelCreate();
+
+ FontSettings.ChangeFontInControls(this, fontSettings);
}
private void ParameterPanelCreate()
@@ -91,9 +121,7 @@ namespace GtaVUsersInfo
}
catch (FileNotFoundException)
{
- string message = $"Файл с автомобилями не найден: {filePath}";
- Console.WriteLine(message);
- MessageBox.Show(message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ ErrorsShow.ShowErrorMessage($"Файл с автомобилями не найден: {filePath}");
return new List();
}
catch (JsonException ex)
@@ -161,7 +189,7 @@ namespace GtaVUsersInfo
CarControl item = new CarControl(car);
item.MenuStrip = new CarItemMenuStrip(addNewCar, editCar, deleteCar, item).Menu;
cars.Add(item);
- CarPanelCreate();
+ AllPanelCreate();
}
}
@@ -231,7 +259,7 @@ namespace GtaVUsersInfo
) == DialogResult.Yes)
{
cars.Remove(carItem);
- CarPanelCreate();
+ AllPanelCreate();
}
}
}
@@ -297,11 +325,7 @@ namespace GtaVUsersInfo
#endregion
- private void saveToolStripMenuItem_Click(object sender, EventArgs e)
- {
- SaveDataToFile();
- AllPanelCreate();
- }
+ #region Раскрывающийся список "Файл"
private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -315,11 +339,22 @@ namespace GtaVUsersInfo
AllPanelCreate();
}
- public void SaveDataToFile()
+ private void saveToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ SaveDataToFile("JSON files (*.json)|*.json|All files (*.*)|*.*");
+ AllPanelCreate();
+ }
+
+ private void saveAsКакToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ SaveDataToFile("All files (*.*)|*.*");
+ }
+
+ public void SaveDataToFile(string filter)
{
Cars_Parameters data = new Cars_Parameters(Car.ConvertToCarList(cars), Parameter.ConvertToParameterList(parameters));
SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.Filter = "JSON files (*.json)|*.json|All files (*.*)|*.*";
+ saveFileDialog.Filter = filter;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
@@ -352,7 +387,7 @@ namespace GtaVUsersInfo
{
if (ErrorsShow.ShowQuestMessage("Хотите сохранить текущего персонажа?") == DialogResult.Yes)
{
- SaveDataToFile();
+ SaveDataToFile("JSON files (*.json)|*.json|All files (*.*)|*.*");
}
cars = new List();
@@ -369,8 +404,54 @@ namespace GtaVUsersInfo
{
if (ErrorsShow.ShowQuestMessage("Хотите сохранить текущего персонажа?") == DialogResult.Yes)
{
- SaveDataToFile();
+ SaveDataToFile("JSON files (*.json)|*.json|All files (*.*)|*.*");
}
}
+
+ #endregion
+
+ #region Раскрывающийся список "Стили"
+
+ private void colorTextToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using (ColorDialog colorDialog = new ColorDialog())
+ {
+ if (colorDialog.ShowDialog() == DialogResult.OK)
+ {
+ fontSettings.FontSettingsEdit(colorDialog.Color);
+
+ FontSettings.ChangeFontInControls(this, fontSettings);
+
+ FontSettings.SaveFontSettings(fontSettings);
+ }
+ }
+ }
+
+ private void styleTextToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using (FontDialog fontDialog = new FontDialog())
+ {
+ if (fontDialog.ShowDialog() == DialogResult.OK)
+ {
+ fontSettings.FontSettingsEdit(fontDialog.Font);
+
+ FontSettings.ChangeFontInControls(this, fontSettings);
+
+ FontSettings.SaveFontSettings(fontSettings);
+ }
+ }
+ }
+
+ private void defaultToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ fontSettings.FontSettingsEdit(defaultFont);
+ fontSettings.FontSettingsEdit(defaultColor);
+
+ FontSettings.ChangeFontInControls(this, fontSettings);
+
+ FontSettings.SaveFontSettings(fontSettings);
+ }
+
+ #endregion
}
}
diff --git a/MainForm.resx b/MainForm.resx
index d5494e3..9d84515 100644
--- a/MainForm.resx
+++ b/MainForm.resx
@@ -117,7 +117,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
17, 17
\ No newline at end of file
diff --git a/Resources.Designer.cs b/Resources.Designer.cs
index f4056ad..23a9d73 100644
--- a/Resources.Designer.cs
+++ b/Resources.Designer.cs
@@ -60,6 +60,24 @@ namespace GtaVUsersInfo {
}
}
+ ///
+ /// Ищет локализованную строку, похожую на 204.
+ ///
+ internal static string CarControlHeight {
+ get {
+ return ResourceManager.GetString("CarControlHeight", resourceCulture);
+ }
+ }
+
+ ///
+ /// Ищет локализованную строку, похожую на 210.
+ ///
+ internal static string CarControlWidth {
+ get {
+ return ResourceManager.GetString("CarControlWidth", resourceCulture);
+ }
+ }
+
///
/// Ищет локализованную строку, похожую на data/cars.json.
///
@@ -77,5 +95,14 @@ namespace GtaVUsersInfo {
return ResourceManager.GetString("carUrl", resourceCulture);
}
}
+
+ ///
+ /// Ищет локализованную строку, похожую на data/fontsettings.json.
+ ///
+ internal static string fontSettingsJsonPath {
+ get {
+ return ResourceManager.GetString("fontSettingsJsonPath", resourceCulture);
+ }
+ }
}
}
diff --git a/Resources.resx b/Resources.resx
index 5ce87d6..1e79aed 100644
--- a/Resources.resx
+++ b/Resources.resx
@@ -117,10 +117,19 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 204
+
+
+ 210
+
data/cars.json
https://gtacars.net/
+
+ data/fontsettings.json
+
\ No newline at end of file
diff --git a/Resources/CarIcon.ico b/Resources/CarIcon.ico
new file mode 100644
index 0000000..7b5f86d
Binary files /dev/null and b/Resources/CarIcon.ico differ
diff --git a/Sources/FontSettings.cs b/Sources/FontSettings.cs
new file mode 100644
index 0000000..0c29a5f
--- /dev/null
+++ b/Sources/FontSettings.cs
@@ -0,0 +1,142 @@
+using GtaVUsersInfo.Helpers;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace GtaVUsersInfo.Sources
+{
+ [Serializable]
+ public class FontSettings
+ {
+ public string FontFamily { get; set; }
+ public float FontSize { get; set; }
+ public FontStyle FontStyle { get; set; }
+ public Color FontColor { get; set; }
+ private static List DTControls { get; set; }
+
+ public FontSettings() { }
+
+ public FontSettings(Font font, Color color)
+ {
+ FontFamily = font.FontFamily.Name;
+ FontSize = font.Size;
+ FontStyle = font.Style;
+ FontColor = color;
+ }
+
+ public FontSettings(Font font, Color color, List controls)
+ {
+ FontFamily = font.FontFamily.Name;
+ FontSize = font.Size;
+ FontStyle = font.Style;
+ FontColor = color;
+ DTControls = controls;
+ }
+
+ public void FontSettingsEdit(Font font)
+ {
+ FontFamily = font.FontFamily.Name;
+ FontSize = font.Size;
+ FontStyle = font.Style;
+ }
+
+ public void FontSettingsEdit(Color color)
+ {
+ FontColor = color;
+ }
+
+ public void FontSettingsEdit(List controls)
+ {
+ DTControls = controls;
+ }
+
+ public static void ChangeFontInControls(Control parent, FontSettings fontSettings)
+ {
+ Font font = CreateFontFromSettings(fontSettings);
+ Color color = fontSettings.FontColor;
+
+ foreach (Control control in parent.Controls)
+ {
+ if (DTControls.Contains(control))
+ {
+ continue;
+ }
+
+ if (control.Parent is FlowLayoutPanel)
+ {
+ int newWidth = (int)(int.Parse(Resources.CarControlWidth) * (font.Size / 11));
+ int newHeight = (int)(int.Parse(Resources.CarControlHeight) * (font.Size / 11));
+
+ control.Size = new Size(newWidth, newHeight);
+ }
+
+ if (control is TextBox || control is Button)
+ {
+ control.Font = font;
+ control.ForeColor = color;
+ }
+ else if (control is Label)
+ {
+ control.Font = font.Size >= 8 ? new Font(font.FontFamily, font.Size - 2) : new Font(font.FontFamily, 8);
+ control.ForeColor = color;
+ }
+ else if (control is MenuStrip)
+ {
+ control.Font = font.Size >= 8 ? new Font(font.FontFamily, font.Size - 1) : new Font(font.FontFamily, 8);
+ control.ForeColor = color;
+ }
+ if (control.HasChildren)
+ {
+ ChangeFontInControls(control, fontSettings);
+ }
+ }
+ }
+
+ public static Font CreateFontFromSettings(FontSettings settings)
+ {
+ return new Font(settings.FontFamily, settings.FontSize, settings.FontStyle);
+ }
+
+ public static void SaveFontSettings(FontSettings fontSettings)
+ {
+ string json = JsonConvert.SerializeObject(fontSettings, Formatting.Indented);
+
+ if (!Directory.Exists(Path.GetDirectoryName(Resources.fontSettingsJsonPath)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(Resources.fontSettingsJsonPath));
+ }
+
+ File.WriteAllText(Resources.fontSettingsJsonPath, json);
+ }
+
+ public static FontSettings LoadFontSettings()
+ {
+ try
+ {
+ string json = File.ReadAllText(Resources.fontSettingsJsonPath);
+ return JsonConvert.DeserializeObject(json);
+ }
+ catch (FileNotFoundException)
+ {
+ Console.WriteLine($"Файл со стилями не найден: {Resources.fontSettingsJsonPath}");
+ return null;
+ }
+ catch (JsonException ex)
+ {
+ Console.WriteLine($"Ошибка при десериализации JSON стилей: {ex.Message}");
+ return null;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Произошла неожиданная ошибка при открытии файла со стилями: {ex.Message}");
+ return null;
+ }
+ }
+ }
+}