-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
107 lines (91 loc) · 3.01 KB
/
Program.cs
File metadata and controls
107 lines (91 loc) · 3.01 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
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
96
97
98
99
100
101
102
103
104
105
106
107
using Avalonia;
using Avalonia.Svg.Skia;
using Newtonsoft.Json;
using System;
using System.Diagnostics;
using System.Linq;
namespace ZXBasicStudio
{
internal class Program
{
public static string Version
{
get
{
if(string.IsNullOrEmpty(_Version))
{
SetVersion();
}
return _Version;
}
}
private static string _Version = "";
public static string VersionDate { get
{
if (string.IsNullOrEmpty(_VersionDate))
{
SetVersion();
}
return _VersionDate;
}
}
public static string _VersionDate = "";
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
SetVersion();
if (args.Contains("--version"))
{
Console.WriteLine($"{Version}");
return;
}
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Formatting= Formatting.Indented,
TypeNameHandling = TypeNameHandling.Auto,
};
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
}
public static void SetVersion()
{
try
{
var assembly = System.Reflection.Assembly.GetEntryAssembly();
var version = assembly.GetName().Version;
_Version = $"{version.Major}.{version.Minor}.{version.Build}";
if (version.Revision != 0)
{
_Version = $"{_Version} - beta {version.Revision}";
}
string path = assembly.Location;
if (string.IsNullOrEmpty(path))
path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
var buildDate = System.IO.File.GetLastWriteTime(path);
_VersionDate = buildDate.ToString("yyyy.MM.dd");
}
catch
{
_Version = "Unknown";
_VersionDate = "Unknown";
}
}
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
{
//Debugger.Launch();
GC.KeepAlive(typeof(SvgImageExtension).Assembly);
GC.KeepAlive(typeof(Avalonia.Svg.Skia.Svg).Assembly);
return AppBuilder.Configure<App>()
.UsePlatformDetect()
.With(new X11PlatformOptions
{
EnableIme = true,
})
.LogToTrace();
}
}
}