-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
70 lines (60 loc) · 1.91 KB
/
Copy pathProgram.cs
File metadata and controls
70 lines (60 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Configuration;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using static MainLibrary.MainLib;
namespace AutoPixelArt
{
static class Program
{
private static readonly Properties.Settings settings = Properties.Settings.Default;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
if (ProcessSettings())
{
Lang = settings.lang;
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Lang == "ru" ? "ru" : "en-US");
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
static bool ProcessSettings()
{
try
{
if (string.IsNullOrEmpty(settings.appVersion))
{
string settingsPath = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;
if (File.Exists($@"{Path.GetDirectoryName(settingsPath)}\restoreSettings"))
{
settings.Reset();
File.Delete($@"{Path.GetDirectoryName(settingsPath)}\restoreSettings");
Warning("Âîññòàíîâëåíû íàñòðîéêè ïî óìîë÷àíèþ.\n" +
"Restored default settings.", false);
}
else
settings.Upgrade();
settings.appVersion = Application.ProductVersion;
settings.Save();
}
}
catch (ConfigurationErrorsException exception)
{
string settingsPath = ((ConfigurationErrorsException)exception.InnerException).Filename;
File.Delete(settingsPath);
_ = File.Create($@"{Path.GetDirectoryName(settingsPath)}\restoreSettings");
Error("Ôàéë íàñòðîåê ïîâðåæä¸í. Îòêðîéòå ïðîãðàììó åù¸ ðàç, ÷òîáû âîññòàíîâèòü íàñòðîéêè ïî óìîë÷àíèþ.\n" +
"Settings file is damaged. Open the program again to restore default settings.", true);
return false;
}
return true;
}
}
}