This repository has been archived by the owner on Oct 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
83 lines (73 loc) · 2.49 KB
/
App.xaml.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using MetroRadiance.UI;
using Ruminoid.Dashboard.Windows;
using Squirrel;
namespace Ruminoid.Dashboard
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
public App()
{
DispatcherUnhandledException += (sender, args) =>
{
args.Handled = true;
MessageBox.Show(
args.Exception.Message,
"灾难性故障",
MessageBoxButton.OK,
MessageBoxImage.Error,
MessageBoxResult.OK);
};
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
MessageBox.Show(
((Exception)args.ExceptionObject)?.Message ?? "Exception",
"灾难性故障",
MessageBoxButton.OK,
MessageBoxImage.Error,
MessageBoxResult.OK);
};
// SquirrelAware
using (var mgr = new UpdateManager(Config.Current.UpdateServer + Config.Current.UpdateChannel))
{
SquirrelAwareApp.HandleEvents(
onInitialInstall: v =>
{
mgr.CreateShortcutForThisExe();
Current.Shutdown(0);
},
onAppUpdate: v =>
{
mgr.CreateShortcutForThisExe();
Current.Shutdown(0);
},
onAppUninstall: v =>
{
mgr.RemoveShortcutForThisExe();
Current.Shutdown(0);
});
}
Dashboard.Properties.Resources.Culture = CultureInfo.CurrentUICulture;
if (MainWindow is null) MainWindow = new MainWindow();
MainWindow.Show();
Current.Dispatcher?.Invoke(() => ThemeService.Current.ChangeTheme(Theme.Dark));
Current.Dispatcher?.Invoke(() => ThemeService.Current.ChangeAccent(Accent.Blue));
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
ThemeService.Current.Register(this, Theme.Windows, Accent.Windows);
}
}
}