diff --git a/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs index f17fc578..7db7221d 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs @@ -45,8 +45,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls TextBlock textBlockTitle = null; Ellipse ellipseControl = null; Storyboard storyboard = new Storyboard(); - - object typeName; #endregion public Silos() @@ -141,28 +139,13 @@ namespace BPASmartClient.SCADAControl.CustomerControls { (item as Image).MouseLeftButtonDown += Image_MouseLeftButtonDown; ; } - //else if (item is Button) - //{ - // (item as Button).Click += Button_Click; - //} - //else if (item is TextBox) - //{ - // (item as TextBox).TextChanged += TextBox_TextChanged; - //} - //else if (item is CheckBox) - //{ - // (item as CheckBox).Checked += CheckBox_Checked; - // (item as CheckBox).Unchecked += CheckBox_Unchecked; - //} } } } } - TargetRefresh(); } - } public static IEnumerable FindVisualChildren(DependencyObject depObj) where T : DependencyObject diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheCylinder.xaml b/BPASmartClient.SCADAControl/CustomerControls/TheCylinder.xaml new file mode 100644 index 00000000..125a50e0 --- /dev/null +++ b/BPASmartClient.SCADAControl/CustomerControls/TheCylinder.xaml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheCylinder.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheCylinder.xaml.cs new file mode 100644 index 00000000..6d127154 --- /dev/null +++ b/BPASmartClient.SCADAControl/CustomerControls/TheCylinder.xaml.cs @@ -0,0 +1,167 @@ +using BPASmartClient.Compiler; +using BPASmartClient.DATABUS; +using System; +using System.Collections.Generic; +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.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.SCADAControl.CustomerControls +{ + /// + /// TheCylinder.xaml 的交互逻辑 + /// 气缸 + /// + public partial class TheCylinder : UserControl, IExecutable + { + #region 临时变量 + Ellipse LeftTog = null; + Ellipse RightTog = null; + Storyboard storyboard = new Storyboard(); + #endregion + public TheCylinder() + { + InitializeComponent(); + Width = 389; + Height = 100; + this.SizeChanged += TheCylinder_SizeChanged; + } + + #region 事件 + /// + /// 字节改变 + /// + /// + /// + /// + private void TheCylinder_SizeChanged(object sender, SizeChangedEventArgs e) + { + if (LeftTog == null) + { + foreach (Ellipse tb in FindVisualChildren(this)) + { + if (tb.Tag != null) + { + if (tb.Tag.ToString() == "LeftTog") LeftTog = tb; + else if (tb.Tag.ToString() == "RightTog") RightTog = tb; + } + } + //storyboard.RepeatBehavior = RepeatBehavior.Forever; + //DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames(); + //Storyboard.SetTarget(animation, ellipseControl); + //Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)")); + //animation.KeyFrames.Add(new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)))); + //animation.KeyFrames.Add(new EasingDoubleKeyFrame(180, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)))); + //animation.KeyFrames.Add(new EasingDoubleKeyFrame(360, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2)))); + //storyboard.Children.Add(animation); + } + + } + public static IEnumerable FindVisualChildren(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(child)) + { + yield return childOfChild; + } + } + } + } + #endregion + + + + + #region 属性 + public string ControlType => "控件"; + private bool isExecuteState; + public bool IsExecuteState + { + get { return isExecuteState; } + set + { + isExecuteState = value; + if (IsExecuteState) + { + IsEnabled = true; + Focusable = true; + Register(); + } + } + } + public event EventHandler PropertyChange; //声明一个事件 + public bool LeftTogIsChecked + { + get { return (bool)GetValue(LeftTogIsCheckedProperty); } + set { SetValue(LeftTogIsCheckedProperty, value); } + } + public static readonly DependencyProperty LeftTogIsCheckedProperty = + DependencyProperty.Register("LeftTogIsChecked", typeof(bool), typeof(TheCylinder), + new PropertyMetadata(false, new PropertyChangedCallback(OnPropertyChanged))); + public bool RightTogIsChecked + { + get { return (bool)GetValue(RightTogIsCheckedProperty); } + set { SetValue(RightTogIsCheckedProperty, value); } + } + public static readonly DependencyProperty RightTogIsCheckedProperty = + DependencyProperty.Register("RightTogIsChecked", typeof(bool), typeof(TheCylinder), + new PropertyMetadata(false, new PropertyChangedCallback(OnPropertyChanged))); + private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + (d as TheCylinder)?.Refresh(); + } + private void Refresh() + { + if (LeftTog != null) + { + LeftTog.Fill= LeftTogIsChecked?new SolidColorBrush(Colors.Green): new SolidColorBrush(Colors.Red); + RightTog.Fill = RightTogIsChecked ? new SolidColorBrush(Colors.Green) : new SolidColorBrush(Colors.Red); + } + } + /// + /// 数据模板 + /// + private Dictionary DataModel + { + get { return (Dictionary)GetValue(DataModelProperty); } + set { SetValue(DataModelProperty, value); } + } + private static readonly DependencyProperty DataModelProperty = + DependencyProperty.Register("DataModel", typeof(Dictionary), typeof(TheCylinder), new PropertyMetadata(new Dictionary())); + #endregion + /// + /// 运行事件 + /// + public void Register() + { + Class_DataBus.GetInstance().BindingAction += BindingActionHeader; + } + public void BindingActionHeader(object sender, EventArgs e) + { + this.Dispatcher.Invoke((Action)(() => + { + DataModel = Class_DataBus.GetInstance().Dic_RedisDataBinding; + PropertyChange?.Invoke(this, EventArgs.Empty); + })); + } + } +} diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs index 58b3bcd3..36b073f0 100644 --- a/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs +++ b/BPASmartClient.SCADAControl/CustomerControls/TheRedis.xaml.cs @@ -146,6 +146,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls Random ran = new Random(); int n = ran.Next(0, 100); keyValuePairs1[i.ToString()] = "10." + n; + keyValuePairs1["Left"+i.ToString()] = new Random().Next(0,10)>5?true: false; + keyValuePairs1["Right"+i.ToString()] = new Random().Next(0, 10) > 5 ? true : false; } Class_DataBus.GetInstance().Dic_RedisData["Test"] = keyValuePairs1; Class_DataBus.GetInstance().Dic_RedisDataBinding = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData)); diff --git a/BPASmartClient.SCADAControl/DLL/BPASmartClient.Compiler.dll b/BPASmartClient.SCADAControl/DLL/BPASmartClient.Compiler.dll index bf41ab07..77d64357 100644 Binary files a/BPASmartClient.SCADAControl/DLL/BPASmartClient.Compiler.dll and b/BPASmartClient.SCADAControl/DLL/BPASmartClient.Compiler.dll differ diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml index 64d6fb4e..d9b3212a 100644 --- a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml +++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml @@ -263,8 +263,12 @@ + + + + @@ -391,8 +395,7 @@ - - + diff --git a/BeDesignerSCADA/Themes/Styles.xaml b/BeDesignerSCADA/Themes/Styles.xaml index d49a5a67..99e08960 100644 --- a/BeDesignerSCADA/Themes/Styles.xaml +++ b/BeDesignerSCADA/Themes/Styles.xaml @@ -355,7 +355,12 @@ - + + + + + +