-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.xaml.cs
66 lines (63 loc) · 2.28 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
using FishRandomSelector.core.Info;
using FishRandomSelector.Views;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace FishRandomSelector
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
public bool IsConfigFirstUse = false;
public bool HavePeople = true;
public bool IsReset = false;
protected override void OnStartup(StartupEventArgs e)
{
SplashScreen s = new SplashScreen(@"Resource\FishRandomSelector.png");
s.Show(false);
s.Close(TimeSpan.FromSeconds(1.5));
base.OnStartup(e);
if (!System.IO.File.Exists("FishRandomSelector.xml"))
{
FirstUse firstUse = new FirstUse();
firstUse.ShowDialog();
}
if (!System.IO.File.Exists("FishRandomSelectorNameList.xml"))
this.HavePeople = false;
else
Names.ReadPeople();
MainWindow main = new MainWindow();
Application.Current.MainWindow = main;
main.Show();
if (System.IO.File.Exists("FishRandomSelectorNameList.xml"))
Names.ReadPeople();
}
private void Application_Exit(object sender, ExitEventArgs e)
{
if (!IsReset)
{
FishRandomSelector.core.Info.Names.SavePeople();
FishRandomSelector.Settings.UISettings.SaveConfig();
}
}
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
if (FishRandomSelector.Settings.UISettings.UseSystemDefaultErrorDialog)
{
MessageBox.Show("出现了一些奇怪的东西(未经处理的异常):" + e.Exception.Message, "出现了一点“小”问题", MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{
core.Views.ExceptionShower exception = new core.Views.ExceptionShower(e.Exception);
exception.ShowDialog();
}
this.Shutdown();
}
}
}