-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
107 lines (93 loc) · 2.71 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
107 lines (93 loc) · 2.71 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ReTranslator.Pages;
using ReTranslator.Utilities;
namespace ReTranslator;
public partial class MainWindow : Window
{
private MainPage mainPage;
private SettingsPage settingsPage;
private AboutPage aboutPage;
public MainWindow()
{
InitializeComponent();
mainPage = new MainPage();
settingsPage = new SettingsPage();
aboutPage = new AboutPage();
SwitchPage(mainPage);
checkUpdate();
}
private async void checkUpdate()
{
try
{
Logger.Info("检查更新中...");
bool updateAvailable = await CheckUpdate.IsUpdateAvailableAsync();
if (updateAvailable)
{
MessageBox.Show("发现新版本!", "更新提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
Logger.Info("已经是最新版本");
}
}
catch (Exception ex)
{
Logger.Error("检查更新失败:" + ex);
}
}
private void Window_Drag(object sender, MouseButtonEventArgs e)
{
// 排除交互控件
if (e.Source is TextBox || e.Source is Button || e.Source is ComboBox)
return;
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
private void CloseApp(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show(
"确定要退出吗?",
"确认退出",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
Application.Current.Shutdown();
}
}
private void showMainPage(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var tag = button.Tag as string;
Title.Text = "Retranslator" + tag;
SwitchPage(mainPage);
}
private void showSettingsPage(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var tag = button.Tag as string;
Title.Text = "Retranslator" + tag;
SwitchPage(settingsPage);
}
private void showAboutPage(object sender, RoutedEventArgs e)
{
var button = sender as Button;
var tag = button.Tag as string;
Title.Text = "Retranslator" + tag;
SwitchPage(aboutPage);
}
private void SwitchPage(Page content)
{
ContentFrame.Navigate(content);
}
private void Minimize(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
}