-
Notifications
You must be signed in to change notification settings - Fork 99
/
Program.cs
75 lines (69 loc) · 2.53 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
using Advexp;
using Eto.Drawing;
using Eto.Forms;
using System;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Windows.Input;
using OpenTrace.Properties;
namespace OpenTrace
{
class App
{
public static Application app;
}
internal class Program
{
[STAThread]
static void Main(string[] args)
{
UserSettings.LoadSettings();
if (!string.IsNullOrWhiteSpace(UserSettings.language))
{
CultureInfo.CurrentUICulture = new CultureInfo(UserSettings.language);
}
#if NET8_0_OR_GREATER
// 为 macOS 载入正确的 locale
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
var asp = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "/usr/bin/osascript",
ArgumentList = { "-e", "user locale of (get system info)" },
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = false,
CreateNoWindow = true
}
};
asp.Start();
try
{
var line = asp.StandardOutput.ReadLine()?.Replace("_","-");
var curCulture = new CultureInfo(line?.Trim()??"");
CultureInfo.CurrentUICulture = curCulture;
}
catch (Exception e) {}
}
#endif
// 本地化设置
if (CultureInfo.CurrentUICulture.Name == "zh-CN" && TimeZoneInfo.Local.Id == "China Standard Time")
{
if (UserSettings.mapProvider == "" && UserSettings.mapProvider != null) UserSettings.mapProvider = "baidu";
if (UserSettings.POWProvider == "" && UserSettings.POWProvider != null) UserSettings.POWProvider = "sakura";
}
else
{
if (UserSettings.mapProvider == "" && UserSettings.mapProvider != null) UserSettings.mapProvider = "google";
if (UserSettings.POWProvider == "" && UserSettings.POWProvider != null) UserSettings.POWProvider = "api.leo.moe";
}
App.app = new Application(Eto.Platform.Detect);
App.app.Run(new MainForm());
}
}
}