@@ -3,7 +3,7 @@ | |||
namespace BPASmartClient.MessageName | |||
{ | |||
/// <summary> | |||
/// 消息名称管理中心 | |||
/// 消息名称管理中心---不在使用 | |||
/// 特性:Category,消息分组 | |||
/// Description,消息备注 | |||
/// Browsable,是否使用 | |||
@@ -13,39 +13,59 @@ namespace BPASmartClient.MessageName | |||
/// Class_InnerMessageBus.GetInstance().ListenMessage(this, MessageName.xxx, "xxnameHandler"); | |||
/// public void xxnameHandler(object sender, InnerMessageEventArgs e) { } | |||
/// </summary> | |||
public class MessageName | |||
{ | |||
#region XX消息 | |||
/// <summary> | |||
/// xxx消息 | |||
/// </summary> | |||
[Category("消息分组"),Description("消息备注"),Browsable(true)] | |||
public static string xxx = "xxx"; | |||
#endregion | |||
//public class MessageName | |||
//{ | |||
// #region XX消息 | |||
// /// <summary> | |||
// /// xxx消息 | |||
// /// </summary> | |||
// [Category("消息分组"),Description("消息备注"),Browsable(true)] | |||
// public static string xxx = "xxx"; | |||
// #endregion | |||
#region 滚动线消息事件管理中心 | |||
/// <summary> | |||
/// 滚动线控制滚动消息 | |||
/// </summary> | |||
[Category("滚动线"), Description("滚动线控制滚动"), Browsable(true)] | |||
public static string ConveyorBeltIsRun = "ConveyorBeltIsRun"; | |||
// #region 滚动线消息事件管理中心 | |||
// /// <summary> | |||
// /// 滚动线控制滚动消息 | |||
// /// </summary> | |||
// [Category("滚动线"), Description("滚动线控制滚动"), Browsable(true)] | |||
// public static string ConveyorBeltIsRun = "ConveyorBeltIsRun"; | |||
// /// <summary> | |||
// /// 滚动线控制左转 | |||
// /// </summary> | |||
// [Category("滚动线"), Description("滚动线控制左转"), Browsable(true)] | |||
// public static string ConveyorBeltLeft = "ConveyorBeltLeft"; | |||
// /// <summary> | |||
// /// 滚动线控制右转 | |||
// /// </summary> | |||
// [Category("滚动线"), Description("滚动线控制右转"), Browsable(true)] | |||
// public static string ConveyorBeltRight = "ConveyorBeltRight"; | |||
// /// <summary> | |||
// /// 滚动线控制停止 | |||
// /// </summary> | |||
// [Category("滚动线"), Description("滚动线控制停止"), Browsable(true)] | |||
// public static string ConveyorBeltStop = "ConveyorBeltStop"; | |||
// #endregion | |||
//} | |||
/// <summary> | |||
/// 消息名称管理中心-枚举 | |||
/// </summary> | |||
public enum MessageNameEnum | |||
{ | |||
/// <summary> | |||
/// 滚动线控制左转 | |||
/// 无 | |||
/// </summary> | |||
[Category("滚动线"), Description("滚动线控制左转"), Browsable(true)] | |||
public static string ConveyorBeltLeft = "ConveyorBeltLeft"; | |||
Null, | |||
/// <summary> | |||
/// 滚动线控制右转 | |||
/// 物料仓运行状态 | |||
/// </summary> | |||
[Category("滚动线"), Description("滚动线控制右转"), Browsable(true)] | |||
public static string ConveyorBeltRight = "ConveyorBeltRight"; | |||
SilosRunStatus, | |||
/// <summary> | |||
/// 滚动线控制停止 | |||
/// 滚动线运行状态 | |||
/// </summary> | |||
[Category("滚动线"), Description("滚动线控制停止"), Browsable(true)] | |||
public static string ConveyorBeltStop = "ConveyorBeltStop"; | |||
#endregion | |||
ConveyorBeltRunStatus, | |||
} | |||
} |
@@ -12,6 +12,7 @@ | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -1,5 +1,7 @@ | |||
using System; | |||
using BPASmartClient.MessageName; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.ComponentModel; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -60,6 +62,7 @@ namespace BPASmartClient.SCADAControl | |||
public void Register() | |||
{ | |||
} | |||
public void VisualStateManagerData() | |||
@@ -140,29 +143,6 @@ namespace BPASmartClient.SCADAControl | |||
geometry1.Figures.Add(pathFigure1); | |||
Path_mp.Data = geometry1; | |||
} | |||
/// <summary> | |||
/// 搜索指定名称的子元素 | |||
/// </summary> | |||
/// <typeparam name="T"></typeparam> | |||
/// <param name="obj"></param> | |||
/// <param name="name"></param> | |||
/// <returns></returns> | |||
public static T FindChild<T>(DependencyObject obj, string name) where T : FrameworkElement | |||
{ | |||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) | |||
{ | |||
DependencyObject child = VisualTreeHelper.GetChild(obj, i); | |||
if (child != null && child is T && (child as T).Name.Equals(name)) | |||
return (T)child; | |||
else | |||
{ | |||
T childOfChild = FindChild<T>(child, name); | |||
if (childOfChild != null) | |||
return childOfChild; | |||
} | |||
} | |||
return null; | |||
} | |||
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject | |||
{ | |||
@@ -272,6 +252,49 @@ namespace BPASmartClient.SCADAControl | |||
DependencyProperty.Register("Direction", typeof(int), typeof(NewConveyorBelt), | |||
new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged))); | |||
[Category("主题订阅")] | |||
public string ConveyorBeltLeft | |||
{ | |||
get { return (string)GetValue(ConveyorBeltLeftProperty); } | |||
set { SetValue(ConveyorBeltLeftProperty, value); } | |||
} | |||
public static readonly DependencyProperty ConveyorBeltLeftProperty = | |||
DependencyProperty.Register("ConveyorBeltLeft", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty)); | |||
[Category("主题订阅")] | |||
public string ConveyorBeltRight | |||
{ | |||
get { return (string)GetValue(ConveyorBeltRightProperty); } | |||
set { SetValue(ConveyorBeltRightProperty, value); } | |||
} | |||
public static readonly DependencyProperty ConveyorBeltRightProperty = | |||
DependencyProperty.Register("ConveyorBeltRight", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty)); | |||
[Category("主题订阅")] | |||
public string ConveyorBeltStop | |||
{ | |||
get { return (string)GetValue(ConveyorBeltStopProperty); } | |||
set { SetValue(ConveyorBeltStopProperty, value); } | |||
} | |||
public static readonly DependencyProperty ConveyorBeltStopProperty = | |||
DependencyProperty.Register("ConveyorBeltStop", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty)); | |||
//[Category("事件名称集合")] | |||
//public ObservableCollection<string> EventList | |||
//{ | |||
// get { return (ObservableCollection<string>)GetValue(EventListProperty); } | |||
// set { SetValue(EventListProperty, value); } | |||
//} | |||
//public static readonly DependencyProperty EventListProperty = | |||
// DependencyProperty.Register("EventList", typeof(ObservableCollection<string>), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection<string>())); | |||
[Category("消息名称")] | |||
public MessageNameEnum EventName | |||
{ | |||
get { return (MessageNameEnum)GetValue(EventNameProperty); } | |||
set { SetValue(EventNameProperty, value); } | |||
} | |||
public static readonly DependencyProperty EventNameProperty = | |||
DependencyProperty.Register("EventName", typeof(MessageNameEnum), typeof(NewConveyorBelt), new PropertyMetadata(MessageNameEnum.Null)); | |||
} | |||
} |
@@ -11,32 +11,73 @@ d:DesignHeight="270" d:DesignWidth="180" > | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Top" | |||
Margin="0 10 0 35" | |||
FontSize="20" | |||
Foreground="#FF1FD622" | |||
Tag="出料控制" | |||
Text="出料中..." Visibility="Collapsed" /> | |||
<Ellipse Grid.Row="0" Tag="出料圆" Margin="0,40,0,0" Visibility="Collapsed" StrokeThickness="60" Width="150" Height="70" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top"> | |||
<Ellipse.RenderTransform> | |||
<TransformGroup> | |||
<ScaleTransform/> | |||
<SkewTransform AngleY="0"/> | |||
<RotateTransform Angle="0"/> | |||
<TranslateTransform/> | |||
</TransformGroup> | |||
</Ellipse.RenderTransform> | |||
<Ellipse.Stroke> | |||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" Opacity="0.4"> | |||
<GradientStop Color="#CCA48E42"/> | |||
<GradientStop Color="#CC2D48DA" Offset="1"/> | |||
<GradientStop Color="#FF3FD256" Offset="0.305"/> | |||
<!--<GradientStop Color="#FFB12C87" Offset="0.67"/>--> | |||
</LinearGradientBrush> | |||
</Ellipse.Stroke> | |||
</Ellipse> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Bottom" | |||
Margin="0 0 0 35" | |||
FontSize="25" | |||
FontSize="45" | |||
Foreground="#FFCCD61F" | |||
Text="{Binding Title,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="0,25,0,0" | |||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center"> | |||
<TextBlock | |||
Margin="0,20,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Foreground="#FF00FFF9" | |||
Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
<TextBlock | |||
Margin="0,20,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FF00FFF9" | |||
Text="(g)" /> | |||
</StackPanel> | |||
<TextBlock | |||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center"> | |||
<TextBlock | |||
Margin="0,50,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="50" | |||
Foreground="#FFFFA400" | |||
Text="{Binding Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="0,70,0,0" | |||
HorizontalAlignment="Center" | |||
FontSize="20" | |||
Foreground="#FF0084FF" | |||
Text="{Binding Text,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
FontSize="25" | |||
Foreground="#FFFFA400" | |||
Text=" 号仓" /> | |||
</StackPanel> | |||
<Image | |||
Grid.RowSpan="2" | |||
Source="/BPASmartClient.SCADAControl;component/Images/光柱.png" | |||
Stretch="Fill" /> | |||
</Grid> | |||
</UserControl> |
@@ -1,4 +1,5 @@ | |||
using System; | |||
using BPASmartClient.MessageName; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.ComponentModel; | |||
using System.Linq; | |||
@@ -10,6 +11,7 @@ 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; | |||
@@ -22,6 +24,9 @@ namespace BPASmartClient.SCADAControl | |||
/// </summary> | |||
public partial class Silos : UserControl, IExecutable | |||
{ | |||
TextBlock textBlockCLKZ = null; | |||
Ellipse ellipseControl = null; | |||
Storyboard storyboard = new Storyboard(); | |||
public Silos() | |||
{ | |||
InitializeComponent(); | |||
@@ -30,9 +35,13 @@ namespace BPASmartClient.SCADAControl | |||
Height = 270; | |||
Value = 25.23; | |||
Title = "香料"; | |||
Text = "1 号仓"; | |||
Text = "1"; | |||
this.SizeChanged += Silos_SizeChanged; ; | |||
} | |||
public string ControlType => "物料仓"; | |||
private bool isExecuteState; | |||
@@ -51,6 +60,71 @@ namespace BPASmartClient.SCADAControl | |||
} | |||
} | |||
#region 动画 | |||
/// <summary> | |||
/// 字节改变 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void Silos_SizeChanged(object sender, SizeChangedEventArgs e) | |||
{ | |||
//查找 | |||
if (ellipseControl == null) | |||
{ | |||
foreach (Ellipse tb in FindVisualChildren<Ellipse>(this)) | |||
{ | |||
// do something with tb here | |||
if (tb.Tag != null) | |||
{ | |||
if (tb.Tag.ToString() == "出料圆") | |||
{ | |||
ellipseControl = tb; | |||
} | |||
} | |||
} | |||
foreach (TextBlock tb in FindVisualChildren<TextBlock>(this)) | |||
{ | |||
// do something with tb here | |||
if (tb.Tag != null) | |||
{ | |||
if (tb.Tag.ToString() == "出料控制") | |||
{ | |||
textBlockCLKZ = 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 属性 | |||
[Category("值设定")] | |||
public double Value | |||
@@ -80,17 +154,62 @@ namespace BPASmartClient.SCADAControl | |||
} | |||
public static readonly DependencyProperty TitleProperty = | |||
DependencyProperty.Register("Title", typeof(string), typeof(Silos), new PropertyMetadata(string.Empty)); | |||
[Category("消息名称")] | |||
public MessageNameEnum EventName | |||
{ | |||
get { return (MessageNameEnum)GetValue(EventNameProperty); } | |||
set { SetValue(EventNameProperty, value); } | |||
} | |||
public static readonly DependencyProperty EventNameProperty = | |||
DependencyProperty.Register("EventName", typeof(MessageNameEnum), typeof(Silos), new PropertyMetadata(MessageNameEnum.Null,onEventValueChanged)); | |||
private static void onEventValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as Silos)?.Refresh(); | |||
[Category("值设定")] | |||
public int Direction | |||
{ | |||
get { return (int)GetValue(DirectionProperty); } | |||
set { SetValue(DirectionProperty, value); } | |||
} | |||
public static readonly DependencyProperty DirectionProperty = | |||
DependencyProperty.Register("Direction", typeof(int), typeof(Silos), | |||
new PropertyMetadata(0, new PropertyChangedCallback(OnPropertyChanged))); | |||
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | |||
{ | |||
(d as Silos)?.Refresh(); | |||
} | |||
#endregion | |||
#region 函数 | |||
public void Refresh() | |||
{ | |||
if (ellipseControl != null) | |||
{ | |||
if (Direction == 1) | |||
{ | |||
ellipseControl.Visibility = Visibility.Visible; | |||
textBlockCLKZ.Visibility = Visibility.Visible; | |||
storyboard.Begin(); | |||
} | |||
else if (Direction == 2) | |||
{ | |||
ellipseControl.Visibility = Visibility.Collapsed; | |||
textBlockCLKZ.Visibility = Visibility.Collapsed; | |||
storyboard.Stop(); | |||
} | |||
else | |||
{ | |||
ellipseControl.Visibility = Visibility.Collapsed; | |||
textBlockCLKZ.Visibility = Visibility.Collapsed; | |||
storyboard.Stop(); | |||
} | |||
} | |||
} | |||
#endregion | |||
public void Register() | |||
{ | |||
} | |||
} | |||
} |