-
Notifications
You must be signed in to change notification settings - Fork 7
/
Program.cs
95 lines (89 loc) · 3.63 KB
/
Program.cs
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Globalization;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace NVGE
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
string mutexName = "NVGE";
System.Threading.Mutex mutex = new(false, mutexName);
bool hasHandle = false;
try
{
if (!File.Exists(Common.xmlpath))
{
Common.InitConfig();
}
try
{
hasHandle = mutex.WaitOne(0, false);
}
catch (System.Threading.AbandonedMutexException)
{
hasHandle = true;
}
if (hasHandle == false)
{
MessageBox.Show("Multiple launch of applications is not allowed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\engines\waifu2x\waifu2x-ncnn-vulkan.exe"))
{
MessageBox.Show("The required file 'waifu2x-ncnn-vulkan.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\engines\realcugan\realcugan-ncnn-vulkan.exe"))
{
MessageBox.Show("The required file 'realcugan-ncnn-vulkan.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\engines\realesrgan\realesrgan-ncnn-vulkan.exe"))
{
MessageBox.Show("The required file 'realesrgan-ncnn-vulkan.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!File.Exists(Directory.GetCurrentDirectory() + @"\res\updater.exe"))
{
MessageBox.Show("The required file 'updater.exe' does not exist.\nClose the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Config.Load(Common.xmlpath);
switch (int.Parse(Config.Entry["ApplicationLanguage"].Value))
{
case 0:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("");
break;
case 1:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja");
break;
case 2:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh");
break;
default:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("");
break;
}
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}
finally
{
if (hasHandle)
{
mutex.ReleaseMutex();
}
mutex.Close();
}
}
}
}