终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

99 linhas
3.0 KiB

  1. using BPASmartClient.Compiler;
  2. using BPASmartClient.SCADAControl;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Linq;
  8. using System.Reflection;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. using System.Windows.Threading;
  21. namespace BPASmartClient.SCADAControl.CustomerControls
  22. {
  23. public class TheTextBlock :TextBlock, IExecutable
  24. {
  25. static TheTextBlock()
  26. {
  27. DefaultStyleKeyProperty.OverrideMetadata(typeof(TheTextBlock),new FrameworkPropertyMetadata(typeof(TheTextBlock)));
  28. }
  29. public TheTextBlock()
  30. {
  31. ResourceDictionary languageResDic = new ResourceDictionary();
  32. languageResDic.Source = new Uri(@"/BPASmartClient.SCADAControl;component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute);
  33. this.Resources.MergedDictionaries.Add(languageResDic);
  34. this.Loaded += TheTextBlock_Loaded;
  35. }
  36. private void TheTextBlock_Loaded(object sender, RoutedEventArgs e)
  37. {
  38. if (this.ActualWidth <= 0)
  39. {
  40. Text = "文本";
  41. Height = 30;
  42. Width = 80;
  43. FontSize = 16;
  44. }
  45. }
  46. public string ControlType => "控件";
  47. private bool isExecuteState;
  48. public bool IsExecuteState
  49. {
  50. get { return isExecuteState; }
  51. set
  52. {
  53. isExecuteState = value;
  54. if (IsExecuteState)
  55. {
  56. Register();
  57. }
  58. }
  59. }
  60. #region 数据绑定模块
  61. /// <summary>
  62. /// 数据模板
  63. /// </summary>
  64. private Dictionary<string, object> DataModel
  65. {
  66. get { return (Dictionary<string, object>)GetValue(DataModelProperty); }
  67. set { SetValue(DataModelProperty, value); }
  68. }
  69. private static readonly DependencyProperty DataModelProperty =
  70. DependencyProperty.Register("DataModel", typeof(Dictionary<string, object>), typeof(TheTextBlock), new PropertyMetadata(new Dictionary<string, object>()));
  71. public event EventHandler PropertyChange; //声明一个事件
  72. /// <summary>
  73. /// 运行事件
  74. /// </summary>
  75. public void Register()
  76. {
  77. Class_DataBus.GetInstance().BindingAction += BindingActionHeader;
  78. }
  79. public void BindingActionHeader(object sender, EventArgs e)
  80. {
  81. this.Dispatcher.Invoke((Action)(() =>
  82. {
  83. DataModel = Class_DataBus.GetInstance().Dic_RedisDataBinding;
  84. PropertyChange?.Invoke(this, EventArgs.Empty);
  85. }));
  86. }
  87. #endregion
  88. }
  89. }