RegistryDebugWindow.xaml.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Threading;
  4. using TeamAAS.FlowEditor.Execution;
  5. namespace TeamAAS.Views
  6. {
  7. /// <summary>
  8. /// 【调试工具】ResultRegistry 监控窗口:用 PropertyGridLib 并排显示
  9. /// <see cref="ResultRegistry.Main"/>(主页运行态)与 <see cref="ResultRegistry.Debug"/>(编辑/调试态),
  10. /// 便于确认这两个注册表是否被正确管理(缓存是否泄漏、清理是否生效)。
  11. /// 生产发布时把 MainWindow.EnableRegistryMonitorButton 置为 false 即可隐藏入口。
  12. /// </summary>
  13. public partial class RegistryDebugWindow
  14. {
  15. private readonly DispatcherTimer _timer;
  16. public RegistryDebugWindow()
  17. {
  18. InitializeComponent();
  19. UiScaler.Attach(this); // 分辨率/DPI 自适应
  20. RefreshAll();
  21. _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
  22. _timer.Tick += (s, e) => RefreshAll();
  23. if (ChkAutoRefresh.IsChecked == true) _timer.Start();
  24. Closed += (s, e) => _timer.Stop();
  25. }
  26. private void BtnRefresh_Click(object sender, RoutedEventArgs e) => RefreshAll();
  27. private void ChkAutoRefresh_Changed(object sender, RoutedEventArgs e)
  28. {
  29. if (_timer == null) return;
  30. if (ChkAutoRefresh.IsChecked == true) _timer.Start();
  31. else _timer.Stop();
  32. }
  33. /// <summary>
  34. /// 重新拉取快照:PropertyGrid 只在 SelectedObject 变化时重读属性,
  35. /// 故先置 null 再赋回同一实例,强制刷新计算型监控属性(流程数/内容快照等)。
  36. /// </summary>
  37. private void RefreshAll()
  38. {
  39. GridMain.SelectedObject = null;
  40. GridMain.SelectedObject = ResultRegistry.Main._store;
  41. GridDebug.SelectedObject = null;
  42. GridDebug.SelectedObject = ResultRegistry.Debug._store;
  43. }
  44. }
  45. }