Files
MetroGauges-Old/MetroGauges/WpfStartup.xaml.cs
2026-02-23 17:02:55 +08:00

201 lines
5.3 KiB
C#

using System;
using System.Configuration;
using System.Windows;
using System.Windows.Input;
namespace MetroGauges
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class WpfStartup
{
public WpfStartup()
{
InitializeComponent();
}
WpfKine kinematicDlg;
WpfCurEqui CurveDlg;
WpfLiEqui LineDlg;
WpfConst ConstructionDlg;
WpfTurnout ForksDlg;
WpfOthers OthersDlg;
#region
private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
{
new PaletteHelper().ReplacePrimaryColor(ConfigurationManager.AppSettings["Primary"]);
new PaletteHelper().ReplaceAccentColor(ConfigurationManager.AppSettings["Accent"]);
if (ConfigurationManager.AppSettings["Intensity"]=="Dark")
{
new PaletteHelper().SetLightDark(true);
}
else
{
new PaletteHelper().SetLightDark(false);
}
}
private void WindowMinimize_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void WindowClose_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void VG_Click(object sender, RoutedEventArgs e)
{
//if (kinematicDlg == null)
//{
kinematicDlg = new WpfKine() { ParentWindow = this };
//}
try
{
Hide();
kinematicDlg.ShowDialog();
//Show();
}
catch (Exception ex)
{
kinematicDlg = null;
//kinematicDlg = new WpfKine();
//kinematicDlg.ShowDialog();
LogManager.WriteLog("error", "VG_Click:" + ex.Message);
}
}
#endregion
private void CG_Click(object sender, RoutedEventArgs e)
{
if (CurveDlg == null)
{
CurveDlg = new WpfCurEqui();
}
try
{
Hide();
CurveDlg.ShowDialog();
Show();
}
catch (Exception)
{
CurveDlg = null;
CurveDlg = new WpfCurEqui();
CurveDlg.ShowDialog();
}
}
private void LG_Click(object sender, RoutedEventArgs e)
{
if (LineDlg == null)
{
LineDlg = new WpfLiEqui();
}
try
{
Hide();
LineDlg.ShowDialog();
Show();
}
catch (Exception)
{
LineDlg = null;
LineDlg = new WpfLiEqui();
LineDlg.ShowDialog();
}
}
private void CtG_Click(object sender, RoutedEventArgs e)
{
if (ConstructionDlg == null)
{
ConstructionDlg = new WpfConst();
}
try
{
Hide();
ConstructionDlg.ShowDialog();
Show();
}
catch (Exception)
{
ConstructionDlg = null;
ConstructionDlg = new WpfConst();
ConstructionDlg.ShowDialog();
}
}
private void DcG_Click(object sender, RoutedEventArgs e)
{
if (ForksDlg == null)
{
ForksDlg = new WpfTurnout();
}
try
{
Hide();
ForksDlg.ShowDialog();
Show();
}
catch (Exception)
{
ForksDlg = null;
ForksDlg = new WpfTurnout();
ForksDlg.ShowDialog();
}
}
private void OtG_Click(object sender, RoutedEventArgs e)
{
if (OthersDlg == null)
{
OthersDlg = new WpfOthers();
}
try
{
Hide();
OthersDlg.ShowDialog();
Show();
}
catch (Exception)
{
OthersDlg = null;
OthersDlg = new WpfOthers();
OthersDlg.ShowDialog();
}
}
//private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
//{
// e.Cancel = true;
//DialogsBeforeExit();
//}
/// <summary>
/// 关闭窗体之前的提示对话框
/// </summary>
//private async void DialogsBeforeExit()
//{
//MessageDialogResult result = await this.ShowMessageAsync(this.Title, "确定退出程序吗?", MessageDialogStyle.AffirmativeAndNegative);
//if (result == MessageDialogResult.Negative)
//{
// return;
//}
//else//确认退出
//{
// App.Current.Shutdown();
// //系统退出需要修改的
//}
//}
}
}