终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

99 line
3.0 KiB

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