/
Program.cs
76 lines (71 loc) · 2.18 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
using System;
using GLib;
using Gtk;
using log4net;
using log4net.Config;
using MusicData.Configuration;
using Ninject;
using Action = System.Action;
namespace TouchMPCGtk
{
class Program
{
public static IKernel Kernel;
public static MainWindow MainWindow;
[STAThread]
static void Main(string[] args)
{
XmlConfigurator.Configure();
Kernel = new StandardKernel(new LyricsModule(), new TouchMPCModule());
try
{
ExceptionManager.UnhandledException += ExceptionManager_UnhandledException;
Application.Init();
Action run = () =>
{
var win = new MainWindow();
MainWindow = win;
win.Show();
win.Destroyed += (s, ev) =>
{
Application.Quit();
};
};
Exception errorConnect = null;
try
{
MpdClient.GetSharedClient().Status();
}
catch (Exception e)
{
errorConnect = e;
}
if (errorConnect != null)
{
var win = new SettingsWindow {LatestException = errorConnect};
win.Show();
win.Destroyed += (s, ev) =>
{
if (win.Result)
run();
else
Application.Quit();
};
}
else
{
run();
}
Application.Run();
}
catch (Exception e)
{
LogManager.GetLogger(typeof(Program)).Fatal("Unhandled error", e);
}
}
private static void ExceptionManager_UnhandledException(UnhandledExceptionArgs args)
{
LogManager.GetLogger(typeof (Program)).Fatal(string.Format("Unhandled error {0}", args.ExceptionObject), args.ExceptionObject as Exception);
}
}
}