92 lines
2.6 KiB
C#
92 lines
2.6 KiB
C#
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.Shapes;
|
|
|
|
namespace ShanghaiEnvironmentalTechnology
|
|
{
|
|
/// <summary>
|
|
/// Main.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class Main : Window
|
|
{
|
|
public Main()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
string imagePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources/sleep2.jpg");
|
|
ImageBrush brush = new ImageBrush();
|
|
brush.ImageSource = new BitmapImage(new Uri(imagePath, UriKind.Absolute));
|
|
this.Background = brush;
|
|
|
|
|
|
// 设置语言选择框的默认选中项
|
|
string currentLanguage = ConfigurationManager.AppSettings["Language"] ?? "zh-CN";
|
|
|
|
foreach (ComboBoxItem item in cmbMaterial.Items)
|
|
{
|
|
if ((currentLanguage == "zh-CN" && item.Content.ToString() == "中文") ||
|
|
(currentLanguage == "en-US" && item.Content.ToString() == "English"))
|
|
{
|
|
cmbMaterial.SelectedItem = item;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(currentLanguage))
|
|
ResourceManager.SwitchLanguage(currentLanguage);
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 进入主窗体事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
|
|
MainWindow mainWindow = MainWindow.Instance;
|
|
mainWindow.ShowDialog(); // 显示 MainWindow
|
|
|
|
|
|
this.Close(); // 如果您希望在打开新窗口时关闭当前窗口
|
|
}
|
|
|
|
|
|
private void cmbMaterial_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
string selectedText = (cmbMaterial.SelectedItem as ComboBoxItem)?.Content.ToString();
|
|
|
|
if (string.IsNullOrEmpty(selectedText))
|
|
return;
|
|
|
|
if (selectedText == "中文" || selectedText == "Chinese")
|
|
{
|
|
ResourceManager.SwitchLanguage("zh-CN");
|
|
}
|
|
else if (selectedText == "English")
|
|
{
|
|
ResourceManager.SwitchLanguage("en-US");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|