forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Program.cs
83 lines (69 loc) · 2.09 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
// MonoGame - Copyright (C) MonoGame Foundation, Inc
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
using Eto;
using Eto.Forms;
namespace MonoGame.Tools.Pipeline
{
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main(string[] args)
{
string project = null;
if (args.Length == 1)
project = args[0];
Styles.Load();
#if GTK
var app = new Application(Platforms.Gtk);
#elif WPF
var app = new Application(Platforms.Wpf);
#else
var app = new Application(Platforms.macOS);
#endif
app.Style = "PipelineTool";
PipelineSettings.Default.Load();
if (!string.IsNullOrEmpty(PipelineSettings.Default.ErrorMessage))
{
var logwin = new LogWindow();
logwin.LogText = PipelineSettings.Default.ErrorMessage;
app.Run(logwin);
return;
}
#if !DEBUG
try
#endif
{
var win = new MainWindow();
var controller = PipelineController.Create(win);
#if GTK
Global.Application.AddWindow(win.ToNative() as Gtk.Window);
#endif
#if GTK && !DEBUG
GLib.ExceptionManager.UnhandledException += (e) =>
{
var logwin = new LogWindow();
logwin.LogText = e.ExceptionObject.ToString();
logwin.Show();
win.Close();
};
#endif
if (!string.IsNullOrEmpty(project))
controller.OpenProject(project);
app.Run(win);
}
#if !DEBUG
catch (Exception ex)
{
PipelineSettings.Default.ErrorMessage = ex.ToString();
PipelineSettings.Default.Save();
app.Restart();
}
#endif
}
}
}