-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
153 lines (136 loc) · 4.28 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using CamShar.Model;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CamShar.View
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
//获取页面单例
MainPage mainPage;
MyFile myFile;
FindFile findFile;
Setting setting;
DownloadPageView downloadPageView;
//初始窗体
public MainWindow(string userName)
{
LoginModel.SetUerName(userName);
InitializeComponent();
SerachPart.Visibility = Visibility.Hidden;
//初始化页面
mainPage = SingletonPage.GetInstanc1();
MainF.Content = mainPage;
UserName.Text = "你好! "+LoginModel.GetUserName();
//写入配置文件默认下载路径
ConfigurationManager.AppSettings.Set("SearchNum","10");
ConfigurationManager.AppSettings.Set("SavePath", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads\");
}
//拖动窗口
private void MoveWindows(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
//关闭窗口
private void CloseMainWindow(object sender, RoutedEventArgs e)
{
if(setting != null)
{
if (setting.IsLoaded)
{
setting.Close();
}
}
this.Close();
Environment.Exit(0);
}
//最小化窗口
private void MinMainWindow(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
//最大化窗口
private void MaxMainWindow(object sender, RoutedEventArgs e)
{
if (this.WindowState != WindowState.Maximized)
{
this.WindowState = WindowState.Maximized;
this.MaxHeight = SystemParameters.WorkArea.Height;
this.MaxWidth = SystemParameters.WorkArea.Width;
}
else
{
this.WindowState = WindowState.Normal;
}
}
//我的文件页面
private void ChangeMyFilePage(object sender, RoutedEventArgs e)
{
myFile = SingletonPage.GetInstanc2();
myFile.Refresh();
MainF.Content = myFile;
SerachPart.Visibility = Visibility.Hidden;
}
//首页
private void MainPageChanged(object sender, RoutedEventArgs e)
{
if (mainPage == null)
{
SerachPart.Visibility = Visibility.Hidden;
}
else
{
MainF.Content = mainPage;
SerachPart.Visibility = Visibility.Hidden;
}
}
//查找资源页面
private void FindFileChanged(object sender, RoutedEventArgs e)
{
findFile = SingletonPage.GetInstanc3();
findFile.Refresh();
MainF.Content = findFile;
SerachPart.Visibility = Visibility.Visible;
}
//打开设置页面
private void SettingWindow(object sender, RoutedEventArgs e)
{
setting = SingletonPage.GetInstanc4();
setting.Show();
}
//显示下载记录页
private void DownLoadPage(object sender, RoutedEventArgs e)
{
downloadPageView = SingletonPage.GetInstanc5();
MainF.Content= downloadPageView;
}
//搜索指定文件
private void SerachFile(object sender, RoutedEventArgs e)
{
if (fileContent.Text == "")
{
MessageBox.Show("请输入搜索内容");
}
else
{
//模糊搜索
findFile.Refresh(fileContent.Text);
}
}
}
}