|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using BPASmartClient.Compiler;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
-
- namespace BPASmartClient.SCADAControl.CustomerControls
- {
- /// <summary>
- /// TheEllipse.xaml 的交互逻辑
- /// </summary>
- public partial class TheEllipse : UserControl, IExecutable
- {
- Ellipse LeftTog = null;
- public TheEllipse()
- {
- InitializeComponent();
- this.Loaded += TheEllipse_Loaded; ; ;
- this.SizeChanged += TheEllipse_SizeChanged; ; ;
- }
-
- private void TheEllipse_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- if (LeftTog == null)
- {
- foreach (Ellipse tb in FindVisualChildren<Ellipse>(this))
- {
- if (tb.Tag != null)
- {
- if (tb.Tag.ToString() == "Ellipse") LeftTog = tb;
- }
- }
- }
- }
-
- public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
- {
- if (depObj != null)
- {
- for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
- {
- DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
- if (child != null && child is T)
- {
- yield return (T)child;
- }
-
- foreach (T childOfChild in FindVisualChildren<T>(child))
- {
- yield return childOfChild;
- }
- }
- }
- }
-
- private void TheEllipse_Loaded(object sender, RoutedEventArgs e)
- {
- if (this.ActualWidth <= 20)
- {
- Width = 80;
- Height = 80;
- }
- BKStrokeDashArray.CollectionChanged += BKStrokeDashArray_CollectionChanged;
- }
-
- private void BKStrokeDashArray_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
- {
- Refresh();
- }
-
-
- public Brush BJColor
- {
- get { return (Brush)GetValue(BJColorProperty); }
- set { SetValue(BJColorProperty, value); }
- }
- public static readonly DependencyProperty BJColorProperty =
- DependencyProperty.Register("BJColor", typeof(Brush), typeof(TheEllipse), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
- public double BKThickness
- {
- get { return (double)GetValue(BKThicknessProperty); }
- set { SetValue(BKThicknessProperty, value); }
- }
- public static readonly DependencyProperty BKThicknessProperty =
- DependencyProperty.Register("BKThickness", typeof(double), typeof(TheEllipse), new PropertyMetadata(1.0));
- public ObservableCollection<double> BKStrokeDashArray
- {
- get { return (ObservableCollection<double>)GetValue(BKStrokeDashArrayProperty); }
- set { SetValue(BKStrokeDashArrayProperty, value); }
- }
- public static readonly DependencyProperty BKStrokeDashArrayProperty =
- DependencyProperty.Register("BKStrokeDashArray", typeof(ObservableCollection<double>), typeof(TheEllipse), new PropertyMetadata(new ObservableCollection<double>(),new PropertyChangedCallback(OnPropertyChanged)));
- public DoubleCollection DoubleArray
- {
- get { return (DoubleCollection)GetValue(DoubleArrayProperty); }
- set { SetValue(DoubleArrayProperty, value); }
- }
- public static readonly DependencyProperty DoubleArrayProperty =
- DependencyProperty.Register("DoubleArray", typeof(DoubleCollection), typeof(TheEllipse), new PropertyMetadata(new DoubleCollection()));
-
-
- private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- (d as TheEllipse)?.Refresh();
- }
- private void Refresh()
- {
- DoubleArray = new DoubleCollection(BKStrokeDashArray);
- }
- public event EventHandler PropertyChange; //声明一个事件
- public string ControlType => "控件";
- private bool isExecuteState;
- public bool IsExecuteState
- {
- get { return isExecuteState; }
- set
- {
- isExecuteState = value;
- if (IsExecuteState)
- {
- Register();
- }
- }
- }
- // <summary>
- /// 运行事件
- /// </summary>
- public void Register()
- {
-
- }
- }
- }
|