diff --git a/PowerAdaptabilityModule/ViewModels/PowerAdaptabilityViewModel.cs b/PowerAdaptabilityModule/ViewModels/PowerAdaptabilityViewModel.cs
index 61331ba..34c471e 100644
--- a/PowerAdaptabilityModule/ViewModels/PowerAdaptabilityViewModel.cs
+++ b/PowerAdaptabilityModule/ViewModels/PowerAdaptabilityViewModel.cs
@@ -57,15 +57,15 @@ namespace PowerAdaptabilityModule.ViewModels
public string ScopeImageDir { get => _scopeImageDir; set => SetProperty(ref _scopeImageDir, value); }
private BitmapImage? _scopeImage;
- /// 最近一次抓取的示波器屏幕图片(供界面 Image 控件显示)
+ /// 当前显示的波形截图(由 LIST / SYNTHESIS 按钮按配置文件同名规则加载)
public BitmapImage? ScopeImage { get => _scopeImage; set => SetProperty(ref _scopeImage, value); }
private bool _hasScopeImage;
- /// 是否已有截图(控制图片区占位提示的显隐)
+ /// 是否已加载波形截图(控制图片区占位提示的显隐)
public bool HasScopeImage { get => _hasScopeImage; set => SetProperty(ref _hasScopeImage, value); }
private string _scopeImageHint = "";
- /// 最近抓取的图片文件提示
+ /// 波形截图查找/加载结果提示
public string ScopeImageHint { get => _scopeImageHint; set => SetProperty(ref _scopeImageHint, value); }
#endregion
@@ -447,6 +447,8 @@ public ICommand CopySynthPhaseToThreeCommand { get; }
public ICommand DeleteSynthPresetCommand { get; }
public ICommand CaptureScopeImageCommand { get; }
public ICommand BrowseScopeImageDirCommand { get; }
+ public ICommand ShowListWaveImageCommand { get; }
+ public ICommand ShowSynthWaveImageCommand { get; }
public ICommand ScopeAcquireRunCommand { get; }
public ICommand ScopeAcquireStopCommand { get; }
public ICommand QueryAcquireStateCommand { get; }
@@ -713,7 +715,7 @@ public ICommand CopySynthPhaseToThreeCommand { get; }
SaveSynthPresetAsCommand = new DelegateCommand(SaveCurrentSynthPresetAs);
DeleteSynthPresetCommand = new DelegateCommand(DeleteCurrentSynthPreset);
- // 示波器抓图:抓取当前屏幕保存为 PNG 到存储位置,成功后自动加载显示
+ // 示波器抓图:抓取当前屏幕保存为 PNG 到存储位置(图片区不自动显示,改由 LIST / SYNTHESIS 按钮按配置文件名加载)
CaptureScopeImageCommand = new DelegateCommand(async () => await ExecScope(async () =>
{
if (string.IsNullOrWhiteSpace(ScopeImageDir))
@@ -728,7 +730,6 @@ public ICommand CopySynthPhaseToThreeCommand { get; }
await _scope!.保存屏幕截图(file, Ct()); // SAVe:IMAGe → *OPC? → READFile → 写盘
- LoadScopeImage(file);
Log($"示波器屏幕图片已抓取:{file}");
}));
@@ -747,6 +748,11 @@ public ICommand CopySynthPhaseToThreeCommand { get; }
Log($"波形图片存储位置已设置:{ScopeImageDir}");
});
+ // 按当前载入的配置文件查看对应波形截图:
+ // LIST → {当前测试项文件名}.png;SYNTHESIS → {当前波形文件名}.png;找不到则清空图片区
+ ShowListWaveImageCommand = new DelegateCommand(() => ShowWaveImage(_currentPresetPath, "LIST"));
+ ShowSynthWaveImageCommand = new DelegateCommand(() => ShowWaveImage(_currentSynthPath, "SYNTHESIS"));
+
// —— 采集控制 ——
ScopeAcquireRunCommand = new DelegateCommand(async () =>
await ExecScope(async () => { await _scope!.设置采集状态(true, Ct()); Log("示波器采集已启动 (RUN)"); }));
@@ -1382,10 +1388,11 @@ public ICommand CopySynthPhaseToThreeCommand { get; }
}
///
- /// 把抓取到的 PNG 加载为 BitmapImage 并刷新界面显示。
+ /// 把指定的 PNG 加载为 BitmapImage 并刷新界面显示。
/// BitmapCacheOption.OnLoad 读完即释放文件句柄,不占用图片文件;Freeze 后跨线程安全。
///
- private void LoadScopeImage(string file)
+ /// 加载成功返回 true;文件缺失/损坏返回 false(提示由调用方给)。
+ private bool LoadScopeImage(string file)
{
try
{
@@ -1398,11 +1405,65 @@ public ICommand CopySynthPhaseToThreeCommand { get; }
ScopeImage = bmp;
HasScopeImage = true;
- ScopeImageHint = $"最近抓取:{Path.GetFileName(file)}";
+ return true;
}
catch (Exception ex)
{
Log($"加载截图失败:{ex.Message}");
+ return false;
+ }
+ }
+
+ /// 清空图片区(没有对应波形截图时不显示任何图片)。
+ private void ClearScopeImage()
+ {
+ ScopeImage = null;
+ HasScopeImage = false;
+ }
+
+ ///
+ /// 按“当前模式已载入配置文件的文件名(去扩展名)+ .png”在波形图片存储位置查找截图并显示。
+ /// LIST 模式取当前打开的测试项文件,SYNTHESIS 模式取当前打开的波形文件;
+ /// 未载入配置或图片不存在时清空图片区,不显示任何图片。
+ ///
+ private void ShowWaveImage(string? configPath, string mode)
+ {
+ if (string.IsNullOrWhiteSpace(ScopeImageDir))
+ {
+ ClearScopeImage();
+ ScopeImageHint = "请先设置波形图片存储位置";
+ Log("请先设置波形图片存储位置");
+ return;
+ }
+
+ if (string.IsNullOrWhiteSpace(configPath))
+ {
+ ClearScopeImage();
+ ScopeImageHint = $"请先载入 {mode} 配置文件,再查看对应波形图片";
+ Log($"请先载入 {mode} 配置文件");
+ return;
+ }
+
+ string stem = Path.GetFileNameWithoutExtension(configPath); // 配置文件名去掉 .json 后缀
+ string file = Path.Combine(ScopeImageDir, stem + ".png");
+
+ if (!File.Exists(file))
+ {
+ ClearScopeImage();
+ ScopeImageHint = $"未找到波形图片:{stem}.png";
+ Log($"[{mode}] 未找到波形图片:{file}");
+ return;
+ }
+
+ if (LoadScopeImage(file))
+ {
+ ScopeImageHint = $"{mode} 波形图片:{stem}.png";
+ Log($"[{mode}] 已显示波形图片:{file}");
+ }
+ else
+ {
+ ClearScopeImage();
+ ScopeImageHint = $"波形图片加载失败:{stem}.png";
}
}
diff --git a/PowerAdaptabilityModule/Views/PowerAdaptabilityView.xaml b/PowerAdaptabilityModule/Views/PowerAdaptabilityView.xaml
index 3f62cb1..e16bea8 100644
--- a/PowerAdaptabilityModule/Views/PowerAdaptabilityView.xaml
+++ b/PowerAdaptabilityModule/Views/PowerAdaptabilityView.xaml
@@ -497,7 +497,18 @@
Style="{StaticResource CmdBtn}"
Background="#388E3C" Foreground="White"
HorizontalAlignment="Left" Margin="0,4"
- ToolTip="抓取示波器当前屏幕保存为 PNG(SAVe:IMAGe),成功后自动加载显示" />
+ ToolTip="抓取示波器当前屏幕保存为 PNG(SAVe:IMAGe),仅保存文件;查看波形图请点下方 LIST / SYNTHESIS" />
+
+
+
+
+
+
+
-