终端一体化运控平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

145 lignes
5.0 KiB

  1. using BPASmartClient.Compiler;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  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. namespace BPASmartClient.SCADAControl.CustomerControls
  18. {
  19. /// <summary>
  20. /// TheEllipse.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class TheEllipse : UserControl, IExecutable
  23. {
  24. Ellipse LeftTog = null;
  25. public TheEllipse()
  26. {
  27. InitializeComponent();
  28. this.Loaded += TheEllipse_Loaded; ; ;
  29. this.SizeChanged += TheEllipse_SizeChanged; ; ;
  30. }
  31. private void TheEllipse_SizeChanged(object sender, SizeChangedEventArgs e)
  32. {
  33. if (LeftTog == null)
  34. {
  35. foreach (Ellipse tb in FindVisualChildren<Ellipse>(this))
  36. {
  37. if (tb.Tag != null)
  38. {
  39. if (tb.Tag.ToString() == "Ellipse") LeftTog = tb;
  40. }
  41. }
  42. }
  43. }
  44. public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
  45. {
  46. if (depObj != null)
  47. {
  48. for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
  49. {
  50. DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
  51. if (child != null && child is T)
  52. {
  53. yield return (T)child;
  54. }
  55. foreach (T childOfChild in FindVisualChildren<T>(child))
  56. {
  57. yield return childOfChild;
  58. }
  59. }
  60. }
  61. }
  62. private void TheEllipse_Loaded(object sender, RoutedEventArgs e)
  63. {
  64. if (this.ActualWidth <= 20)
  65. {
  66. Width = 80;
  67. Height = 80;
  68. }
  69. BKStrokeDashArray.CollectionChanged += BKStrokeDashArray_CollectionChanged;
  70. }
  71. private void BKStrokeDashArray_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  72. {
  73. Refresh();
  74. }
  75. public Brush BJColor
  76. {
  77. get { return (Brush)GetValue(BJColorProperty); }
  78. set { SetValue(BJColorProperty, value); }
  79. }
  80. public static readonly DependencyProperty BJColorProperty =
  81. DependencyProperty.Register("BJColor", typeof(Brush), typeof(TheEllipse), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
  82. public double BKThickness
  83. {
  84. get { return (double)GetValue(BKThicknessProperty); }
  85. set { SetValue(BKThicknessProperty, value); }
  86. }
  87. public static readonly DependencyProperty BKThicknessProperty =
  88. DependencyProperty.Register("BKThickness", typeof(double), typeof(TheEllipse), new PropertyMetadata(1.0));
  89. public ObservableCollection<double> BKStrokeDashArray
  90. {
  91. get { return (ObservableCollection<double>)GetValue(BKStrokeDashArrayProperty); }
  92. set { SetValue(BKStrokeDashArrayProperty, value); }
  93. }
  94. public static readonly DependencyProperty BKStrokeDashArrayProperty =
  95. DependencyProperty.Register("BKStrokeDashArray", typeof(ObservableCollection<double>), typeof(TheEllipse), new PropertyMetadata(new ObservableCollection<double>(),new PropertyChangedCallback(OnPropertyChanged)));
  96. public DoubleCollection DoubleArray
  97. {
  98. get { return (DoubleCollection)GetValue(DoubleArrayProperty); }
  99. set { SetValue(DoubleArrayProperty, value); }
  100. }
  101. public static readonly DependencyProperty DoubleArrayProperty =
  102. DependencyProperty.Register("DoubleArray", typeof(DoubleCollection), typeof(TheEllipse), new PropertyMetadata(new DoubleCollection()));
  103. private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  104. {
  105. (d as TheEllipse)?.Refresh();
  106. }
  107. private void Refresh()
  108. {
  109. DoubleArray = new DoubleCollection(BKStrokeDashArray);
  110. }
  111. public event EventHandler PropertyChange; //声明一个事件
  112. public string ControlType => "控件";
  113. private bool isExecuteState;
  114. public bool IsExecuteState
  115. {
  116. get { return isExecuteState; }
  117. set
  118. {
  119. isExecuteState = value;
  120. if (IsExecuteState)
  121. {
  122. Register();
  123. }
  124. }
  125. }
  126. // <summary>
  127. /// 运行事件
  128. /// </summary>
  129. public void Register()
  130. {
  131. }
  132. }
  133. }