/
MainWindow.xaml.cs
71 lines (65 loc) · 1.44 KB
/
MainWindow.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
using CN_GreenLumaGUI.tools;
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
namespace CN_GreenLumaGUI
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
}
private async void Terminar()
{
Hide();
try
{
// 清理log文件
if (File.Exists(OutAPI.LogFilePath))
File.Delete(OutAPI.LogFilePath);
#region LoadingWindow
//打开读取动画窗口
//var loadingWindow = new LoadingWindow();
//loadingWindow.Show();
//耗时操作
//结束读取动画窗口
//loadingWindow.Close();
#endregion
#region ManagerWindow
//打开管理窗口并等到其结束
await ShowPopup(new ManagerWindow());
#endregion
}
catch (Exception ex)
{
OutAPI.PrintLog(ex.StackTrace);
OutAPI.MsgBox(ex.Message).Wait();
}
finally
{
//GLFileTools.DeleteGreenLumaConfig();
DataSystem.Instance.SaveData();
}
//this.Show();
Close();
}
private void Window_Activated(object? sender, EventArgs e)
{
Activated -= Window_Activated;
Terminar();
}
private static Task ShowPopup<TPopup>(TPopup popup) where TPopup : Window
{
var task = new TaskCompletionSource<object>();
popup.Owner = Application.Current.MainWindow;
popup.Closed += (s, a) => task.SetResult(new());
popup.Show();
popup.Focus();
return task.Task;
}
}
}