| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Windows;
- using System.Windows.Threading;
- using TeamAAS.FlowEditor.Execution;
- namespace TeamAAS.Views
- {
- /// <summary>
- /// 【调试工具】ResultRegistry 监控窗口:用 PropertyGridLib 并排显示
- /// <see cref="ResultRegistry.Main"/>(主页运行态)与 <see cref="ResultRegistry.Debug"/>(编辑/调试态),
- /// 便于确认这两个注册表是否被正确管理(缓存是否泄漏、清理是否生效)。
- /// 生产发布时把 MainWindow.EnableRegistryMonitorButton 置为 false 即可隐藏入口。
- /// </summary>
- 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();
- }
- /// <summary>
- /// 重新拉取快照:PropertyGrid 只在 SelectedObject 变化时重读属性,
- /// 故先置 null 再赋回同一实例,强制刷新计算型监控属性(流程数/内容快照等)。
- /// </summary>
- private void RefreshAll()
- {
- GridMain.SelectedObject = null;
- GridMain.SelectedObject = ResultRegistry.Main._store;
- GridDebug.SelectedObject = null;
- GridDebug.SelectedObject = ResultRegistry.Debug._store;
- }
- }
- }
|