语言切换
This commit is contained in:
@@ -33,9 +33,9 @@ namespace COFTester.Models
|
||||
"CSI-H238M", "TestData");
|
||||
|
||||
/// <summary>
|
||||
/// 界面語言:zh-TW(繁體中文)、zh-CN(簡體中文)、en-US(英文)
|
||||
/// 界面語言:zh-CN(簡體中文)、en-US(英文)
|
||||
/// </summary>
|
||||
public string Language { get; set; } = "zh-TW";
|
||||
public string Language { get; set; } = "zh-CN";
|
||||
|
||||
/// <summary>
|
||||
/// 自動保存測試結果
|
||||
|
||||
@@ -94,7 +94,11 @@ namespace COFTester.Resources
|
||||
["EndPosition"] = "结束位置",
|
||||
["ApplyConfig"] = "应用配置",
|
||||
["CancelConfig"] = "取消",
|
||||
["DetailedConfig"] = "详细配置"
|
||||
["DetailedConfig"] = "详细配置",
|
||||
["TestObject"] = "测试对象:",
|
||||
["TestMethod"] = "测试方法:",
|
||||
["KeyIndicators"] = "关键指标:",
|
||||
["KineticWarningMessage"] = "此标准仅测量静摩擦系数,动摩擦计算区间将被忽略"
|
||||
},
|
||||
|
||||
["en-US"] = new Dictionary<string, string>
|
||||
@@ -173,7 +177,11 @@ namespace COFTester.Resources
|
||||
["EndPosition"] = "End Position",
|
||||
["ApplyConfig"] = "Apply",
|
||||
["CancelConfig"] = "Cancel",
|
||||
["DetailedConfig"] = "Detailed Config"
|
||||
["DetailedConfig"] = "Detailed Config",
|
||||
["TestObject"] = "Test Object:",
|
||||
["TestMethod"] = "Test Method:",
|
||||
["KeyIndicators"] = "Key Indicators:",
|
||||
["KineticWarningMessage"] = "This standard only measures static friction coefficient, kinetic calculation range will be ignored"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -248,6 +256,10 @@ namespace COFTester.Resources
|
||||
public string ApplyConfig => GetString("ApplyConfig");
|
||||
public string CancelConfig => GetString("CancelConfig");
|
||||
public string DetailedConfig => GetString("DetailedConfig");
|
||||
public string TestObject => GetString("TestObject");
|
||||
public string TestMethod => GetString("TestMethod");
|
||||
public string KeyIndicators => GetString("KeyIndicators");
|
||||
public string KineticWarningMessage => GetString("KineticWarningMessage");
|
||||
|
||||
private string GetString(string key)
|
||||
{
|
||||
@@ -325,6 +337,10 @@ namespace COFTester.Resources
|
||||
OnPropertyChanged(nameof(ApplyConfig));
|
||||
OnPropertyChanged(nameof(CancelConfig));
|
||||
OnPropertyChanged(nameof(DetailedConfig));
|
||||
OnPropertyChanged(nameof(TestObject));
|
||||
OnPropertyChanged(nameof(TestMethod));
|
||||
OnPropertyChanged(nameof(KeyIndicators));
|
||||
OnPropertyChanged(nameof(KineticWarningMessage));
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
@@ -43,6 +43,15 @@ namespace COFTester.ViewModels
|
||||
|
||||
ApplyCommand = new RelayCommand(Apply);
|
||||
CancelCommand = new RelayCommand(Cancel);
|
||||
|
||||
// 監聽語言切換事件
|
||||
LanguageResources.Instance.PropertyChanged += OnLanguageChanged;
|
||||
}
|
||||
|
||||
private void OnLanguageChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
// 當語言資源變化時,通知 UI 更新 Lang 屬性
|
||||
OnPropertyChanged(nameof(Lang));
|
||||
}
|
||||
|
||||
public LanguageResources Lang => LanguageResources.Instance;
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
<!-- Header -->
|
||||
<Border Grid.Row="0" Style="{StaticResource CardStyle}" Margin="10,10,10,5">
|
||||
<StackPanel>
|
||||
<TextBlock Text="更多配置" FontSize="20" FontWeight="Bold" Foreground="{StaticResource PrimaryBrush}"/>
|
||||
<TextBlock Text="详细测试参数配置与标准选择" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,5,0,0"/>
|
||||
<TextBlock Text="{Binding Lang.ConfigTitle}" FontSize="20" FontWeight="Bold" Foreground="{StaticResource PrimaryBrush}"/>
|
||||
<TextBlock Text="{Binding Lang.ConfigSubtitle}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,5,0,0"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<!-- 测试标准选择 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="测试标准选择" Style="{StaticResource SectionTitle}"/>
|
||||
<TextBlock Text="{Binding Lang.StandardSelection}" Style="{StaticResource SectionTitle}"/>
|
||||
|
||||
<!-- 标准下拉选择 -->
|
||||
<ComboBox ItemsSource="{Binding Standards}"
|
||||
@@ -112,7 +112,7 @@
|
||||
|
||||
<!-- 测试对象 -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Text="测试对象:"
|
||||
Text="{Binding Lang.TestObject}"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="#2C3E50"
|
||||
@@ -125,7 +125,7 @@
|
||||
|
||||
<!-- 测试方法 -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
Text="测试方法:"
|
||||
Text="{Binding Lang.TestMethod}"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="#2C3E50"
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
<!-- 关键指标 -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0"
|
||||
Text="关键指标:"
|
||||
Text="{Binding Lang.KeyIndicators}"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="#2C3E50"
|
||||
@@ -170,7 +170,7 @@
|
||||
Visibility="{Binding ShowKineticWarning, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="⚠️" FontSize="14" Margin="0,0,8,0"/>
|
||||
<TextBlock Text="此标准仅测量静摩擦系数,动摩擦计算区间将被忽略"
|
||||
<TextBlock Text="{Binding Lang.KineticWarningMessage}"
|
||||
FontSize="11"
|
||||
Foreground="#856404"
|
||||
TextWrapping="Wrap"/>
|
||||
@@ -182,9 +182,9 @@
|
||||
<!-- 基本参数 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="基本参数" Style="{StaticResource SectionTitle}"/>
|
||||
<TextBlock Text="{Binding Lang.BasicParameters}" Style="{StaticResource SectionTitle}"/>
|
||||
|
||||
<TextBlock Text="滑块质量 (Sled Mass)" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBlock Text="{Binding Lang.SledMassConfig}" Style="{StaticResource LabelStyle}"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -203,7 +203,7 @@
|
||||
Margin="10,0,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="测试速度 (Test Speed)" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBlock Text="{Binding Lang.TestSpeedConfig}" Style="{StaticResource LabelStyle}"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -222,7 +222,7 @@
|
||||
Margin="10,0,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="测试时长 (Test Duration)" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBlock Text="{Binding Lang.TestDurationConfig}" Style="{StaticResource LabelStyle}"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -241,7 +241,7 @@
|
||||
Margin="10,0,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="测试行程 (Test Stroke)" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBlock Text="{Binding Lang.TestStrokeConfig}" Style="{StaticResource LabelStyle}"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -265,9 +265,9 @@
|
||||
<!-- 计算区间 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="计算区间" Style="{StaticResource SectionTitle}"/>
|
||||
<TextBlock Text="{Binding Lang.CalculationRange}" Style="{StaticResource SectionTitle}"/>
|
||||
|
||||
<TextBlock Text="静摩擦计算区间 (Static COF Range)" Style="{StaticResource LabelStyle}"/>
|
||||
<TextBlock Text="{Binding Lang.StaticCalcRange}" Style="{StaticResource LabelStyle}"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -275,17 +275,17 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="起始位置 (mm)" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBlock Text="{Binding Lang.StartPosition}" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBox Text="{Binding ConfigParams.StaticCalcStart}" Height="30" FontSize="13"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" Text="~" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16"/>
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock Text="结束位置 (mm)" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBlock Text="{Binding Lang.EndPosition}" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBox Text="{Binding ConfigParams.StaticCalcEnd}" Height="30" FontSize="13"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="动摩擦计算区间 (Kinetic COF Range)" Style="{StaticResource LabelStyle}" Margin="0,15,0,4"/>
|
||||
<TextBlock Text="{Binding Lang.KineticCalcRange}" Style="{StaticResource LabelStyle}" Margin="0,15,0,4"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -293,12 +293,12 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="起始位置 (mm)" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBlock Text="{Binding Lang.StartPosition}" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBox Text="{Binding ConfigParams.KineticCalcStart}" Height="30" FontSize="13"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" Text="~" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16"/>
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock Text="结束位置 (mm)" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBlock Text="{Binding Lang.EndPosition}" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBox Text="{Binding ConfigParams.KineticCalcEnd}" Height="30" FontSize="13"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
@@ -316,7 +316,7 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Grid.Column="1" Content="应用配置"
|
||||
<Button Grid.Column="1" Content="{Binding Lang.ApplyConfig}"
|
||||
Command="{Binding ApplyCommand}"
|
||||
Width="120" Height="40" Margin="5"
|
||||
Background="{StaticResource SuccessBrush}"
|
||||
@@ -325,7 +325,7 @@
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Cursor="Hand"/>
|
||||
|
||||
<Button Grid.Column="2" Content="取消"
|
||||
<Button Grid.Column="2" Content="{Binding Lang.CancelConfig}"
|
||||
Command="{Binding CancelCommand}"
|
||||
Width="120" Height="40" Margin="5"
|
||||
Background="{StaticResource GrayBrush}"
|
||||
|
||||
Reference in New Issue
Block a user