using System;
using System.Windows;
using System.Windows.Threading;
using TeamAAS.FlowEditor.Execution;
namespace TeamAAS.Views
{
///
/// 【调试工具】ResultRegistry 监控窗口:用 PropertyGridLib 并排显示
/// (主页运行态)与 (编辑/调试态),
/// 便于确认这两个注册表是否被正确管理(缓存是否泄漏、清理是否生效)。
/// 生产发布时把 MainWindow.EnableRegistryMonitorButton 置为 false 即可隐藏入口。
///
public partial class RegistryDebugWindow
{
private readonly DispatcherTimer _timer;
public RegistryDebugWindow()
{
InitializeComponent();
UiScaler.Attach(this); // 分辨率/DPI 自适应
RefreshAll();
_timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
_timer.Tick += (s, e) => RefreshAll();
if (ChkAutoRefresh.IsChecked == true) _timer.Start();
Closed += (s, e) => _timer.Stop();
}
private void BtnRefresh_Click(object sender, RoutedEventArgs e) => RefreshAll();
private void ChkAutoRefresh_Changed(object sender, RoutedEventArgs e)
{
if (_timer == null) return;
if (ChkAutoRefresh.IsChecked == true) _timer.Start();
else _timer.Stop();
}
///
/// 重新拉取快照:PropertyGrid 只在 SelectedObject 变化时重读属性,
/// 故先置 null 再赋回同一实例,强制刷新计算型监控属性(流程数/内容快照等)。
///
private void RefreshAll()
{
GridMain.SelectedObject = null;
GridMain.SelectedObject = ResultRegistry.Main._store;
GridDebug.SelectedObject = null;
GridDebug.SelectedObject = ResultRegistry.Debug._store;
}
}
}