-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
72 lines (66 loc) · 1.86 KB
/
Copy pathProgram.cs
File metadata and controls
72 lines (66 loc) · 1.86 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
// Program.cs
using System;
using System.Runtime.InteropServices;
using Avalonia;
namespace Libris;
/// <summary>
/// Содержит точку входа и конфигурацию Avalonia-приложения Libris.
/// </summary>
internal static class Program
{
/// <summary>
/// Запускает приложение Libris.
/// </summary>
/// <param name="args">Аргументы командной строки.</param>
[STAThread]
public static void Main(string[] args)
{
try
{
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
}
catch (Exception ex)
{
ShowError(ex);
}
}
/// <summary>
/// Отображает пользователю сообщение о критической ошибке.
/// </summary>
private static void ShowError(Exception ex)
{
var message =
"Libris crashed.\n\n" +
ex + "\n\n" +
"Press OK to close the application.";
MessageBox(
IntPtr.Zero,
message,
"Libris — Critical Error",
0x00000010);
}
/// <summary>
/// Отображает стандартное системное окно Windows.
/// </summary>
[DllImport(
"user32.dll",
CharSet = CharSet.Unicode)]
private static extern int MessageBox(
IntPtr hWnd,
string text,
string caption,
uint type);
/// <summary>
/// Создаёт и настраивает экземпляр Avalonia-приложения.
/// </summary>
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder
.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.WithDeveloperTools()
#endif
.WithInterFont()
.LogToTrace();
}