@@ -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<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject | |||
@@ -0,0 +1,239 @@ | |||
<UserControl x:Class="BPASmartClient.SCADAControl.CustomerControls.TheCylinder" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls" | |||
mc:Ignorable="d" > | |||
<Grid> | |||
<Viewbox Width="auto" Height="auto"> | |||
<Canvas | |||
Width="389" | |||
Height="100"> | |||
<Path | |||
Data="M2 30 L2 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M6 30 L6 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M10 30 L10 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M14 30 L14 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M18 30 L18 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M22 30 L22 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M26 30 L26 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M30 30 L30 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M34 30 L34 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M38 30 L38 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M42 30 L42 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M46 30 L46 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M50 30 L50 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M54 30 L54 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M58 30 L58 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M62 30 L62 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M64 30 L64 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M68 30 L68 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M72 30 L72 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M76 30 L76 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M80 30 L80 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M84 30 L84 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M88 30 L88 70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M92 30 L92 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M102 30 L102 70" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="16" /> | |||
<Path | |||
Data="M50 20 L50 80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="20" /> | |||
<Path | |||
Data="M42,25 L58,25 60,30 60,45 58,50 60,55 60,70 58,75 42,75 40,70 40,55 42,50 40,45 40,30 42,25" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="1" /> | |||
<Path | |||
Data="M42 50 L58 50" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="1" /> | |||
<Path Data="M110 0 L110,100 160,100 175,80 300 ,80 315,100 365,100 365,0 315,0 300,20 175,20 160,0 110,0"> | |||
<Path.Fill> | |||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||
<GradientStop Color="#FF1EDEDA" /> | |||
<GradientStop Offset="1" Color="#FF1EDEDA" /> | |||
<GradientStop Offset="0.5" Color="#FFDDEAE9" /> | |||
</LinearGradientBrush> | |||
</Path.Fill> | |||
</Path> | |||
<Path | |||
Data="M110 30 L160,30 A2,5 0 1 1 160,70 L110,70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M160 0 L160,30" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M160 70 L160,100" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M175 20 L175,80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M179 20 L179,80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M183 20 L183,80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M187 20 L187,80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M365 30 L315,30 A2,5 0 1 0 315,70 L365,70" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M315 0 L315,30" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M315 70 L315,100" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M300 20 L300,80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M296 20 L296,80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M292 20 L292,80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M288 20 L288,80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="2" /> | |||
<Path | |||
Data="M367 20 L367 80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M371 20 L371 80" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M375 20 L375 80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M379 20 L379 80" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M383 20 L383 80" | |||
Stroke="#FFB1B1B9" | |||
StrokeThickness="4" /> | |||
<Path | |||
Data="M387 20 L387 80" | |||
Stroke="#FF6d6666" | |||
StrokeThickness="4" /> | |||
<Ellipse Tag="LeftTog" Width="30" Height="30" Fill="Red" Margin="120,35,0,0" RenderTransformOrigin="0.5,0.5"> | |||
<Ellipse.OpacityMask> | |||
<RadialGradientBrush> | |||
<GradientStop Offset="0" Color="Transparent" /> | |||
<GradientStop Offset="1" Color="Black" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
</Ellipse> | |||
<Ellipse Tag="RightTog" Width="30" Height="30" Fill="Red" Margin="325,35,0,0" RenderTransformOrigin="0.5,0.5"> | |||
<Ellipse.OpacityMask> | |||
<RadialGradientBrush> | |||
<GradientStop Offset="0" Color="Transparent" /> | |||
<GradientStop Offset="1" Color="Black" /> | |||
</RadialGradientBrush> | |||
</Ellipse.OpacityMask> | |||
</Ellipse> | |||
</Canvas> | |||
</Viewbox> | |||
</Grid> | |||
</UserControl> |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// TheCylinder.xaml 的交互逻辑 | |||
/// 气缸 | |||
/// </summary> | |||
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 事件 | |||
/// <summary> | |||
/// 字节改变 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
/// <exception cref="NotImplementedException"></exception> | |||
private void TheCylinder_SizeChanged(object sender, SizeChangedEventArgs e) | |||
{ | |||
if (LeftTog == null) | |||
{ | |||
foreach (Ellipse tb in FindVisualChildren<Ellipse>(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<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; | |||
} | |||
} | |||
} | |||
} | |||
#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); | |||
} | |||
} | |||
/// <summary> | |||
/// 数据模板 | |||
/// </summary> | |||
private Dictionary<string, object> DataModel | |||
{ | |||
get { return (Dictionary<string, object>)GetValue(DataModelProperty); } | |||
set { SetValue(DataModelProperty, value); } | |||
} | |||
private static readonly DependencyProperty DataModelProperty = | |||
DependencyProperty.Register("DataModel", typeof(Dictionary<string, object>), typeof(TheCylinder), new PropertyMetadata(new Dictionary<string, object>())); | |||
#endregion | |||
/// <summary> | |||
/// 运行事件 | |||
/// </summary> | |||
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); | |||
})); | |||
} | |||
} | |||
} |
@@ -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<Dictionary<string, object>>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData)); | |||
@@ -263,8 +263,12 @@ | |||
<mypro:PropertyDefinition DisplayName="左边距" Category="基本属性" DisplayOrder="9" Name="(Canvas.Left)"/> | |||
<mypro:PropertyDefinition DisplayName="上边距" Category="基本属性" DisplayOrder="9" Name="(Canvas.Top)"/> | |||
<mypro:PropertyDefinition DisplayName="启动测试" Category="基本属性" DisplayOrder="9" Name="TestData"/> | |||
<mypro:PropertyDefinition DisplayName="气缸左执行" Category="基本属性" DisplayOrder="10" Name="LeftTogIsChecked"/> | |||
<mypro:PropertyDefinition DisplayName="气缸右执行" Category="基本属性" DisplayOrder="10" Name="RightTogIsChecked"/> | |||
<mypro:PropertyDefinition DisplayName="数据来源类型" Category="数据绑定模块" DisplayOrder="0" Name="DataSouceType"/> | |||
<mypro:PropertyDefinition DisplayName="数据来源类型" Category="数据绑定模块" DisplayOrder="0" Name="DataSouceType"/> | |||
<mypro:PropertyDefinition DisplayName="设备名称" Category="数据绑定模块" DisplayOrder="0" Name="DeviceName"/> | |||
<mypro:PropertyDefinition DisplayName="接口类型" Category="数据绑定模块" DisplayOrder="1" Name="InterfaceMode"/> | |||
@@ -391,8 +395,7 @@ | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="Text,Title,Value,BindingIsChecked,Header,KgValue,WLText,WLTitle,DataSouceInformation,Direction" > | |||
<mypro:EditorTemplateDefinition TargetProperties="Text,Title,Value,BindingIsChecked,Header,KgValue,WLText,WLTitle,DataSouceInformation,Direction,LeftTogIsChecked,RightTogIsChecked" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
@@ -355,7 +355,12 @@ | |||
<Setter TargetName="icon" Property="Kind" Value="PeriodicTable" /> | |||
<Setter TargetName="txt" Property="Text" Value="选项卡控件" /> | |||
</DataTrigger> | |||
<DataTrigger Binding="{Binding Name}" Value="TheCylinder"> | |||
<Setter TargetName="icon" Property="Kind" Value="AlphaGCircleOutline" /> | |||
<Setter TargetName="txt" Property="Text" Value="气缸控件" /> | |||
</DataTrigger> | |||
</DataTemplate.Triggers> | |||
</DataTemplate> | |||