更新
This commit is contained in:
@@ -36,6 +36,7 @@ namespace COFTester.Resources
|
||||
// 左侧面板 - 测试控制
|
||||
["TestControl"] = "测试控制",
|
||||
["StartTest"] = "开始测试",
|
||||
["TestInProgress"] = "测试中",
|
||||
["Stop"] = "停止",
|
||||
["ResetSystem"] = "复位",
|
||||
["Resetting"] = "复位中",
|
||||
@@ -186,6 +187,7 @@ namespace COFTester.Resources
|
||||
// Left Panel - Test Control
|
||||
["TestControl"] = "Test Control",
|
||||
["StartTest"] = "Start Test",
|
||||
["TestInProgress"] = "Testing",
|
||||
["Stop"] = "Stop",
|
||||
["ResetSystem"] = "Reset System",
|
||||
["Resetting"] = "Resetting",
|
||||
@@ -346,6 +348,7 @@ namespace COFTester.Resources
|
||||
public string Displacement => GetString("Displacement");
|
||||
public string TestControl => GetString("TestControl");
|
||||
public string StartTest => GetString("StartTest");
|
||||
public string TestInProgress => GetString("TestInProgress");
|
||||
public string Stop => GetString("Stop");
|
||||
public string ResetSystem => GetString("ResetSystem");
|
||||
public string Resetting => GetString("Resetting");
|
||||
@@ -489,6 +492,7 @@ namespace COFTester.Resources
|
||||
OnPropertyChanged(nameof(Displacement));
|
||||
OnPropertyChanged(nameof(TestControl));
|
||||
OnPropertyChanged(nameof(StartTest));
|
||||
OnPropertyChanged(nameof(TestInProgress));
|
||||
OnPropertyChanged(nameof(Stop));
|
||||
OnPropertyChanged(nameof(ResetSystem));
|
||||
OnPropertyChanged(nameof(Resetting));
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace COFTester.ViewModels
|
||||
private bool _disposed = false;
|
||||
private string _selectedDirection = ""; // 选中的方向:Up/Down/Right/Left
|
||||
private string _resetButtonText; // 复位按钮文本
|
||||
private string _testButtonText; // 测试按钮文本
|
||||
|
||||
public MainViewModel(IDataAcquisitionService daqService, DataProcessingService processingService, AppConfig config)
|
||||
{
|
||||
@@ -52,6 +53,7 @@ namespace COFTester.ViewModels
|
||||
// 初始化状态消息
|
||||
_statusMessage = LanguageResources.Instance.SystemReady;
|
||||
_resetButtonText = LanguageResources.Instance.ResetSystem;
|
||||
_testButtonText = LanguageResources.Instance.StartTest;
|
||||
|
||||
// 訂閱數據採集服務事件
|
||||
_daqService.DataReceived += OnDataReceived;
|
||||
@@ -418,6 +420,12 @@ namespace COFTester.ViewModels
|
||||
get => _resetButtonText;
|
||||
set { _resetButtonText = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public string TestButtonText
|
||||
{
|
||||
get => _testButtonText;
|
||||
set { _testButtonText = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -465,6 +473,7 @@ namespace COFTester.ViewModels
|
||||
Application.Current?.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
IsTesting = false;
|
||||
TestButtonText = Lang.StartTest; // 测试完成后恢复按钮文本
|
||||
StatusMessage = Lang.TestCompleted;
|
||||
|
||||
// 数据处理与计算
|
||||
@@ -511,6 +520,7 @@ namespace COFTester.ViewModels
|
||||
if (_isTesting)
|
||||
{
|
||||
IsTesting = false;
|
||||
TestButtonText = Lang.StartTest; // 错误时恢复按钮文本
|
||||
}
|
||||
OnPropertyChanged(nameof(IsConnected));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
@@ -623,7 +633,10 @@ namespace COFTester.ViewModels
|
||||
_realTimePoints.Clear();
|
||||
OnPropertyChanged(nameof(DataPointsCount));
|
||||
LatestResult = null;
|
||||
|
||||
// 更新测试状态和按钮文本
|
||||
IsTesting = true;
|
||||
TestButtonText = Lang.TestInProgress; // 按钮显示"测试中"
|
||||
StatusMessage = $"开始测试 - {_selectedDirection}方向";
|
||||
UpdateScottPlot();
|
||||
|
||||
@@ -643,6 +656,9 @@ namespace COFTester.ViewModels
|
||||
Application.Current?.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
StatusMessage = $"启动测试失败: {ex.Message}";
|
||||
// 启动失败时恢复按钮状态
|
||||
IsTesting = false;
|
||||
TestButtonText = Lang.StartTest;
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -677,6 +693,7 @@ namespace COFTester.ViewModels
|
||||
|
||||
_daqService.StopAcquisition();
|
||||
IsTesting = false;
|
||||
TestButtonText = Lang.StartTest; // 恢复按钮文本为"开始测试"
|
||||
StatusMessage = Lang.TestStopped;
|
||||
}
|
||||
|
||||
@@ -1070,9 +1087,16 @@ namespace COFTester.ViewModels
|
||||
else if (_statusMessage.Contains("分析完成") || _statusMessage.Contains("Analysis Completed"))
|
||||
StatusMessage = Lang.AnalysisCompleted;
|
||||
|
||||
// 更新复位按钮文本
|
||||
if (!_isTesting)
|
||||
// 更新按钮文本
|
||||
if (_isTesting)
|
||||
{
|
||||
TestButtonText = Lang.TestInProgress;
|
||||
}
|
||||
else
|
||||
{
|
||||
TestButtonText = Lang.StartTest;
|
||||
ResetButtonText = Lang.ResetSystem;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenConfig()
|
||||
|
||||
@@ -255,10 +255,23 @@
|
||||
<!-- 分隔线 -->
|
||||
<Separator Width="2" Margin="10,10" Background="#BDC3C7"/>
|
||||
|
||||
<!-- 开始测试按钮 -->
|
||||
<Button Content="{Binding Lang.StartTest}" Command="{Binding StartCommand}"
|
||||
<!-- 开始测试按钮 - 动态显示状态:开始测试 → 测试中(不可点击) → 开始测试 -->
|
||||
<Button Content="{Binding TestButtonText}" Command="{Binding StartCommand}"
|
||||
Height="70" Width="110" Background="#27AE60"
|
||||
Style="{StaticResource IndustrialButtonStyle}" Margin="5"/>
|
||||
Style="{StaticResource IndustrialButtonStyle}" Margin="5">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource IndustrialButtonStyle}">
|
||||
<Setter Property="Background" Value="#27AE60"/>
|
||||
<Style.Triggers>
|
||||
<!-- 测试中时按钮变灰且不可点击 -->
|
||||
<DataTrigger Binding="{Binding IsTesting}" Value="True">
|
||||
<Setter Property="Background" Value="#95A5A6"/>
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
|
||||
<!-- 复位按钮 - 动态显示状态:复位 → 复位中 → 复位 -->
|
||||
<Button Content="{Binding ResetButtonText}" Command="{Binding ResetCommand}"
|
||||
|
||||
Reference in New Issue
Block a user