WinTraceView.xaml.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Forms.VisualStyles;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. using System.Windows.Threading;
  18. using DevExpress.Xpf.Editors.Helpers;
  19. namespace SAGA.MBI.WinView.TraceView
  20. {
  21. /// <summary>
  22. /// WinTraceView.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class WinTraceView : INotifyPropertyChanged
  25. {
  26. public WinTraceView()
  27. {
  28. InitializeComponent();
  29. this.DataContext = this;
  30. }
  31. private string m_TraceText;
  32. public event PropertyChangedEventHandler PropertyChanged;
  33. public string TraceText
  34. {
  35. get { return m_TraceText; }
  36. set
  37. {
  38. m_TraceText = value;
  39. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TraceText"));
  40. }
  41. }
  42. public void Refrush(string txt)
  43. {
  44. TraceText = txt;
  45. DoEvents();
  46. }
  47. public void DoEvents()
  48. {
  49. var frame = new DispatcherFrame();
  50. Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
  51. new DispatcherOperationCallback(ExitFrames), frame);
  52. try
  53. {
  54. Dispatcher.PushFrame(frame);
  55. }
  56. catch (InvalidOperationException)
  57. {
  58. }
  59. }
  60. private object ExitFrames(object frame)
  61. {
  62. ((DispatcherFrame)frame).Continue = false;
  63. return null;
  64. }
  65. }
  66. }