152 lines
4.5 KiB
C#
152 lines
4.5 KiB
C#
|
|
using ControlzEx.Theming;
|
|
using MahApps.Metro.Controls;
|
|
using MahApps.Metro.Controls.Dialogs;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
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;
|
|
using ViewModel;
|
|
using Views;
|
|
using Community;
|
|
using Model;
|
|
|
|
namespace FeiYu
|
|
{
|
|
/// <summary>
|
|
/// MainWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MainWindow : MetroWindow
|
|
{
|
|
|
|
/// <summary>
|
|
/// 主逻辑对象
|
|
/// </summary>
|
|
MainWindowVM MVM { get; set; }
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
MyMessageBox.MetroWin = this;
|
|
MVM = new MainWindowVM(this);
|
|
this.DataContext = MVM;
|
|
ThemeManager.Current.ChangeTheme(this, BackgroundThemeList[0] + "." + ThemeList[MVM.SystemPar.SystemTheme]);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 切换系统设置模式
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void menSystemSet_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MVM.AllVis == Visibility.Collapsed)
|
|
{
|
|
PwdInput pwdInput = new PwdInput();
|
|
pwdInput.DataContext = this.DataContext;
|
|
pwdInput.ShowDialog();
|
|
}
|
|
else
|
|
{
|
|
MVM.AllVis = Visibility.Collapsed;
|
|
MVM.SelectTabItem = MVM.TabItemList[0];
|
|
}
|
|
|
|
}
|
|
|
|
PwdAlter pwdAlter { get; set; }
|
|
/// <summary>
|
|
/// 密码修改
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void menPwdAlter_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
pwdAlter = new PwdAlter();
|
|
pwdAlter.DataContext = this.DataContext;
|
|
pwdAlter.ShowDialog();
|
|
}
|
|
|
|
#region 切换主题
|
|
//主题色
|
|
List<string> ThemeList = new List<string>() { "Red", "Green", "Blue", "Purple", "Orange", "Lime", "Emerald", "Teal", "Cyan", "Cobalt", "Indigo", "Violet", "Pink", "Magenta", "Crimson", "Amber", "Yellow", "Brown", "Olive", "Steel", "Mauve", "Taupe", "Sienna" };
|
|
//背景色
|
|
List<string> BackgroundThemeList = new List<string>() { "Light", "Dark" };
|
|
/// <summary>
|
|
/// 切换主题
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SubjectSwitch(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MVM.SystemPar.SystemTheme == ThemeList.Count - 1)
|
|
{
|
|
MVM.SystemPar.SystemTheme = 0;
|
|
}
|
|
|
|
ThemeManager.Current.ChangeTheme(this, BackgroundThemeList[0] + "." + ThemeList[MVM.SystemPar.SystemTheme]);
|
|
MVM.SystemPar.SystemTheme++;
|
|
|
|
}
|
|
|
|
|
|
int systemBackgroundNumber = 0;
|
|
/// <summary>
|
|
/// 切换背景
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void BackgroundSwitch(object sender, RoutedEventArgs e)
|
|
{
|
|
systemBackgroundNumber++;
|
|
MVM.SystemPar.SystemBackgroundPath = @"Resources/" + systemBackgroundNumber + ".jpg";
|
|
|
|
if (systemBackgroundNumber >= 32)
|
|
{
|
|
systemBackgroundNumber = 0;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
MVM.Close(0);
|
|
if (MVM.CloseRes == MessageDialogResult.Negative)
|
|
{
|
|
e.Cancel = true;
|
|
}
|
|
|
|
}
|
|
|
|
bool el = true;
|
|
/// <summary>
|
|
/// 切换语言
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (el)
|
|
{
|
|
Application.Current.Resources.MergedDictionaries[4].Source = new Uri(@"./Language/zh-cn.xaml", UriKind.RelativeOrAbsolute);
|
|
}
|
|
else
|
|
{
|
|
Application.Current.Resources.MergedDictionaries[4].Source = new Uri(@"./Language/en-us.xaml", UriKind.RelativeOrAbsolute);
|
|
}
|
|
el = !el;
|
|
}
|
|
}
|
|
}
|