@@ -11,6 +11,7 @@ | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="System.Reflection" Version="4.3.0" /> | <PackageReference Include="System.Reflection" Version="4.3.0" /> | ||||
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" /> | <PackageReference Include="System.Reflection.Emit" Version="4.7.0" /> | ||||
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
</Project> | </Project> |
@@ -20,7 +20,7 @@ namespace BPASmartClient.MessageName.EnumHelp | |||||
/// 根据控件-》创建枚举类型 | /// 根据控件-》创建枚举类型 | ||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public static Type CreatEnumType(UIElementCollection list) | |||||
public static object CreatEnumType(UIElementCollection list) | |||||
{ | { | ||||
var currentDomain = AppDomain.CurrentDomain; | var currentDomain = AppDomain.CurrentDomain; | ||||
var assembly = Assembly.GetExecutingAssembly(); | var assembly = Assembly.GetExecutingAssembly(); | ||||
@@ -47,6 +47,75 @@ namespace BPASmartClient.MessageName.EnumHelp | |||||
} | } | ||||
/// <summary> | |||||
/// 动态创建枚举 | |||||
/// </summary> | |||||
/// <param name="enumDictionary">枚举元素列表</param> | |||||
/// <param name="enumName">枚举名</param> | |||||
/// <returns>Enum枚举</returns> | |||||
public static Enum CreateEnum(Dictionary<string,int> enumDictionary,string enumName = "DefalutEnum") | |||||
{ | |||||
if (enumDictionary == null || enumDictionary.Count <= 0) | |||||
return null; | |||||
AppDomain currentDomain = AppDomain.CurrentDomain; | |||||
AssemblyName aName = new AssemblyName("TempAssembly"); | |||||
AssemblyBuilder ab = AssemblyBuilder.DefineDynamicAssembly(aName,AssemblyBuilderAccess.Run); | |||||
ModuleBuilder mb = ab.DefineDynamicModule(aName.Name); | |||||
if (string.IsNullOrEmpty(enumName)) | |||||
{ | |||||
enumName = "DefalutEnum"; | |||||
} | |||||
EnumBuilder eb = mb.DefineEnum(enumName,TypeAttributes.Public,typeof(int)); | |||||
foreach (var item in enumDictionary) | |||||
{ | |||||
eb.DefineLiteral(item.Key,item.Value); | |||||
} | |||||
Type finished = eb.CreateType(); | |||||
Enum eEnum = Activator.CreateInstance(finished) as Enum; | |||||
//foreach (object item in Enum.GetValues(eEnum.GetType())) | |||||
//{ | |||||
// Debug.LogError(string.Format("{0}.{1} = {2}", finished, item, ((int)item))); | |||||
//} | |||||
return eEnum; | |||||
} | |||||
/// <summary> | |||||
/// 动态创建枚举 | |||||
/// </summary> | |||||
/// <param name="enumDictionary">枚举元素列表</param> | |||||
/// <param name="enumName">枚举名</param> | |||||
/// <returns>Enum枚举</returns> | |||||
public static Enum CreateEnum(List<string> enumList,string enumName = "DefalutEnum") | |||||
{ | |||||
if (enumList == null || enumList.Count <= 0) | |||||
return null; | |||||
AppDomain currentDomain = AppDomain.CurrentDomain; | |||||
AssemblyName aName = new AssemblyName("TempAssembly"); | |||||
AssemblyBuilder ab = AssemblyBuilder.DefineDynamicAssembly(aName,AssemblyBuilderAccess.Run); | |||||
ModuleBuilder mb = ab.DefineDynamicModule(aName.Name); | |||||
if (string.IsNullOrEmpty(enumName)) | |||||
{ | |||||
enumName = "DefalutEnum"; | |||||
} | |||||
EnumBuilder eb = mb.DefineEnum(enumName,TypeAttributes.Public,typeof(int)); | |||||
for (int i = 0; i < enumList.Count; i++) | |||||
{ | |||||
eb.DefineLiteral(enumList[i],i); | |||||
} | |||||
Type finished = eb.CreateType(); | |||||
Enum eEnum = Activator.CreateInstance(finished) as Enum; | |||||
//foreach (object item in Enum.GetValues(eEnum.GetType())) | |||||
//{ | |||||
// Debug.LogError(string.Format("{0}.{1} = {2}", finished, item, ((int)item))); | |||||
//} | |||||
return eEnum; | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 根据枚举int值获取枚举名称 | /// 根据枚举int值获取枚举名称 | ||||
/// </summary> | /// </summary> | ||||
@@ -58,6 +127,14 @@ namespace BPASmartClient.MessageName.EnumHelp | |||||
return Enum.GetName(typeof(T), status); | return Enum.GetName(typeof(T), status); | ||||
} | } | ||||
/// <summary> | |||||
/// 根据枚举名称获取枚举值 | |||||
/// </summary> | |||||
public static T ToEnumValue<T>(string name) | |||||
{ | |||||
return (T)Enum.Parse(typeof(T),name); | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 获取枚举变量值的 Description 属性 | /// 获取枚举变量值的 Description 属性 | ||||
@@ -101,5 +178,7 @@ namespace BPASmartClient.MessageName.EnumHelp | |||||
} | } | ||||
return obj.ToString(); | return obj.ToString(); | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -11,10 +11,6 @@ namespace BPASmartClient.MessageName.发送消息Model | |||||
/// </summary> | /// </summary> | ||||
public class EventSendMessage: MessageBase | public class EventSendMessage: MessageBase | ||||
{ | { | ||||
/// <summary> | |||||
/// 控件类型 | |||||
/// </summary> | |||||
public ControlEventType EventType { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 控件名称 | /// 控件名称 | ||||
/// </summary> | /// </summary> | ||||
@@ -26,11 +22,16 @@ namespace BPASmartClient.MessageName.发送消息Model | |||||
/// <summary> | /// <summary> | ||||
/// 控件触发源 | /// 控件触发源 | ||||
/// </summary> | /// </summary> | ||||
public string ControlSource { get; set; } | |||||
public object ControlSource { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 控件状态 | /// 控件状态 | ||||
/// </summary> | /// </summary> | ||||
public string ControlStatus { get; set; } | public string ControlStatus { get; set; } | ||||
/// <summary> | |||||
/// 控件类型 | |||||
/// </summary> | |||||
public ControlEventType EventType { get; set; } | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 控件类型 | /// 控件类型 | ||||
@@ -337,7 +337,9 @@ namespace BPASmartClient.SCADAControl | |||||
set { SetValue(EventReceiveNameListStrProperty, value); } | set { SetValue(EventReceiveNameListStrProperty, value); } | ||||
} | } | ||||
public static readonly DependencyProperty EventReceiveNameListStrProperty = | public static readonly DependencyProperty EventReceiveNameListStrProperty = | ||||
DependencyProperty.Register("EventReceiveNameListStr", typeof(string), typeof(NewConveyorBelt), new PropertyMetadata(string.Empty)); | |||||
DependencyProperty.Register("EventReceiveNameListStr",typeof(string),typeof(NewConveyorBelt),new PropertyMetadata(string.Empty,new PropertyChangedCallback(onEventReceiveNameListStrChanged))); | |||||
private static void onEventReceiveNameListStrChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.ReceiveNameRefresh(); | |||||
[Category("消息接收名称集合")] | [Category("消息接收名称集合")] | ||||
public ObservableCollection<EventReceiveMessage> EventReceiveNameList | public ObservableCollection<EventReceiveMessage> EventReceiveNameList | ||||
{ | { | ||||
@@ -348,20 +350,20 @@ namespace BPASmartClient.SCADAControl | |||||
DependencyProperty.Register("EventReceiveNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), onEventNameListChanged)); | DependencyProperty.Register("EventReceiveNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), onEventNameListChanged)); | ||||
private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh(); | private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh(); | ||||
[Category("名称[自动生成]")] | [Category("名称[自动生成]")] | ||||
public string EventSendNameListStr | |||||
private string EventSendNameListStr | |||||
{ | { | ||||
get { return (string)GetValue(EventSendNameListStrProperty); } | get { return (string)GetValue(EventSendNameListStrProperty); } | ||||
set { SetValue(EventSendNameListStrProperty,value); } | set { SetValue(EventSendNameListStrProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty EventSendNameListStrProperty = | |||||
private static readonly DependencyProperty EventSendNameListStrProperty = | |||||
DependencyProperty.Register("EventSendNameListStr",typeof(string),typeof(NewConveyorBelt),new PropertyMetadata(string.Empty)); | DependencyProperty.Register("EventSendNameListStr",typeof(string),typeof(NewConveyorBelt),new PropertyMetadata(string.Empty)); | ||||
[Category("消息发送名称集合")] | [Category("消息发送名称集合")] | ||||
public ObservableCollection<EventSendMessage> EventSendNameList | |||||
private ObservableCollection<EventSendMessage> EventSendNameList | |||||
{ | { | ||||
get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); } | get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); } | ||||
set { SetValue(EventSendNameListProperty,value); } | set { SetValue(EventSendNameListProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty EventSendNameListProperty = | |||||
private static readonly DependencyProperty EventSendNameListProperty = | |||||
DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(NewConveyorBelt),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(NewConveyorBelt),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | ||||
#endregion | #endregion | ||||
@@ -469,6 +471,24 @@ namespace BPASmartClient.SCADAControl | |||||
{ | { | ||||
} | } | ||||
/// <summary> | |||||
/// 接收数据改变 | |||||
/// </summary> | |||||
public void ReceiveNameRefresh() | |||||
{ | |||||
if (!string.IsNullOrEmpty(EventReceiveNameListStr)) | |||||
{ | |||||
try | |||||
{ | |||||
EventReceiveNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventReceiveNameListStr); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
} | |||||
#endregion | #endregion | ||||
} | } | ||||
@@ -71,12 +71,10 @@ | |||||
Grid.RowSpan="2" | Grid.RowSpan="2" | ||||
Source="/BPASmartClient.SCADAControl;component/Images/光柱.png" | Source="/BPASmartClient.SCADAControl;component/Images/光柱.png" | ||||
Stretch="Fill" /> | Stretch="Fill" /> | ||||
<StackPanel Tag="ControlEvent" HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="1" VerticalAlignment="Bottom" > | |||||
<Image Margin="10,10,0,0" Tag="出料" Source="/BPASmartClient.SCADAControl;component/Images/借出.png" Cursor="Hand" ToolTip="出料" Width="24" ></Image> | |||||
<Image Margin="10,10,0,0" Tag="停止出料" Source="/BPASmartClient.SCADAControl;component/Images/退出.png" Cursor="Hand" Width="24" ToolTip="停止出料"></Image> | |||||
<Button Margin="10,10,0,0" Tag="出料">出料</Button> | |||||
<TextBox Width="50" Tag="文本改变" TextChanged="TextBox_TextChanged" ></TextBox> | |||||
<CheckBox Checked="CheckBox_Checked" Tag="是否选中" Unchecked="CheckBox_Unchecked"></CheckBox> | |||||
<StackPanel Tag="ControlEvent" HorizontalAlignment="Right" Orientation="Vertical" Grid.Row="1" VerticalAlignment="Bottom" > | |||||
<Image Margin="20,10,0,0" Tag="出料" Source="/BPASmartClient.SCADAControl;component/Images/借出.png" Cursor="Hand" ToolTip="出料" Width="24" ></Image> | |||||
<Image Margin="20,10,0,10" Tag="停止出料" Source="/BPASmartClient.SCADAControl;component/Images/退出.png" Cursor="Hand" Width="24" ToolTip="停止出料"></Image> | |||||
</StackPanel> | </StackPanel> | ||||
</Grid> | </Grid> | ||||
</UserControl> | </UserControl> |
@@ -46,6 +46,8 @@ namespace BPASmartClient.SCADAControl | |||||
Storyboard storyboard = new Storyboard(); | Storyboard storyboard = new Storyboard(); | ||||
object typeName; | object typeName; | ||||
public List<string> typeNameList = new List<string>(); | |||||
public Enum @enum = null; | |||||
#endregion | #endregion | ||||
public Silos() | public Silos() | ||||
@@ -62,7 +64,6 @@ namespace BPASmartClient.SCADAControl | |||||
{ | { | ||||
EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged; | EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged; | ||||
EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged; | EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged; | ||||
//Loading(); | |||||
} | } | ||||
private void EventSendNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | private void EventSendNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | ||||
@@ -176,26 +177,38 @@ namespace BPASmartClient.SCADAControl | |||||
if (item is Image) | if (item is Image) | ||||
{ | { | ||||
(item as Image).MouseLeftButtonDown += Image_MouseLeftButtonDown; | (item as Image).MouseLeftButtonDown += Image_MouseLeftButtonDown; | ||||
if ((item as Image).Tag != null) | |||||
typeNameList.Add((item as Image).Tag?.ToString()); | |||||
} | } | ||||
else if (item is Button) | else if (item is Button) | ||||
{ | { | ||||
(item as Button).Click += Button_Click; | (item as Button).Click += Button_Click; | ||||
if ((item as Button).Tag != null) | |||||
typeNameList.Add((item as Button).Tag?.ToString()); | |||||
} | } | ||||
else if (item is TextBox) | else if (item is TextBox) | ||||
{ | { | ||||
(item as TextBox).TextChanged += TextBox_TextChanged; | (item as TextBox).TextChanged += TextBox_TextChanged; | ||||
if ((item as TextBox).Tag != null) | |||||
typeNameList.Add((item as TextBox).Tag?.ToString()); | |||||
} | } | ||||
else if (item is CheckBox) | else if (item is CheckBox) | ||||
{ | { | ||||
(item as CheckBox).Checked += CheckBox_Checked; | (item as CheckBox).Checked += CheckBox_Checked; | ||||
(item as CheckBox).Unchecked += CheckBox_Unchecked; | (item as CheckBox).Unchecked += CheckBox_Unchecked; | ||||
if ((item as CheckBox).Tag != null) | |||||
typeNameList.Add((item as CheckBox).Tag?.ToString()); | |||||
} | } | ||||
} | } | ||||
@enum = EnumExtensions.CreateEnum(typeNameList,$"{this.Name}ControlEunm"); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject | public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject | ||||
@@ -248,6 +261,20 @@ namespace BPASmartClient.SCADAControl | |||||
public static readonly DependencyProperty TitleProperty = | public static readonly DependencyProperty TitleProperty = | ||||
DependencyProperty.Register("Title",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); | DependencyProperty.Register("Title",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); | ||||
[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(); | |||||
} | |||||
[Category("名称[自动生成]")] | [Category("名称[自动生成]")] | ||||
public string EventReceiveNameListStr | public string EventReceiveNameListStr | ||||
{ | { | ||||
@@ -255,7 +282,9 @@ namespace BPASmartClient.SCADAControl | |||||
set { SetValue(EventReceiveNameListStrProperty,value); } | set { SetValue(EventReceiveNameListStrProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty EventReceiveNameListStrProperty = | public static readonly DependencyProperty EventReceiveNameListStrProperty = | ||||
DependencyProperty.Register("EventReceiveNameListStr",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty)); | |||||
DependencyProperty.Register("EventReceiveNameListStr",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty,new PropertyChangedCallback(onEventReceiveNameListStrChanged))); | |||||
private static void onEventReceiveNameListStrChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.ReceiveNameRefresh(); | |||||
[Category("消息接收名称集合")] | [Category("消息接收名称集合")] | ||||
public ObservableCollection<EventReceiveMessage> EventReceiveNameList | public ObservableCollection<EventReceiveMessage> EventReceiveNameList | ||||
{ | { | ||||
@@ -265,37 +294,41 @@ namespace BPASmartClient.SCADAControl | |||||
public static readonly DependencyProperty EventReceiveNameListProperty = | public static readonly DependencyProperty EventReceiveNameListProperty = | ||||
DependencyProperty.Register("EventReceiveNameList",typeof(ObservableCollection<EventReceiveMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | DependencyProperty.Register("EventReceiveNameList",typeof(ObservableCollection<EventReceiveMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | ||||
[Category("名称[自动生成]")] | [Category("名称[自动生成]")] | ||||
public string EventSendNameListStr | |||||
private string EventSendNameListStr | |||||
{ | { | ||||
get { return (string)GetValue(EventSendNameListStrProperty); } | get { return (string)GetValue(EventSendNameListStrProperty); } | ||||
set { SetValue(EventSendNameListStrProperty,value); } | set { SetValue(EventSendNameListStrProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty EventSendNameListStrProperty = | |||||
private static readonly DependencyProperty EventSendNameListStrProperty = | |||||
DependencyProperty.Register("EventSendNameListStr",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty)); | DependencyProperty.Register("EventSendNameListStr",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty)); | ||||
[Category("消息发送名称集合")] | [Category("消息发送名称集合")] | ||||
public ObservableCollection<EventSendMessage> EventSendNameList | |||||
private ObservableCollection<EventSendMessage> EventSendNameList | |||||
{ | { | ||||
get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); } | get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); } | ||||
set { SetValue(EventSendNameListProperty,value); } | set { SetValue(EventSendNameListProperty,value); } | ||||
} | } | ||||
public static readonly DependencyProperty EventSendNameListProperty = | |||||
private static readonly DependencyProperty EventSendNameListProperty = | |||||
DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | ||||
private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh(); | private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh(); | ||||
#endregion | |||||
[Category("值设定")] | |||||
public int Direction | |||||
#region 发送事件名称集合 | |||||
[Category("事件处理")] | |||||
public MessageNameEnum 出料单击事件 | |||||
{ | { | ||||
get { return (int)GetValue(DirectionProperty); } | |||||
set { SetValue(DirectionProperty,value); } | |||||
get { return (MessageNameEnum)GetValue(出料单击事件Property); } | |||||
set { SetValue(出料单击事件Property,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) | |||||
public static readonly DependencyProperty 出料单击事件Property = | |||||
DependencyProperty.Register("出料单击事件",typeof(MessageNameEnum),typeof(Silos),new PropertyMetadata(MessageNameEnum.Null)); | |||||
[Category("事件处理")] | |||||
public MessageNameEnum 停止出料单击事件 | |||||
{ | { | ||||
(d as Silos)?.Refresh(); | |||||
get { return (MessageNameEnum)GetValue(停止出料单击事件Property); } | |||||
set { SetValue(停止出料单击事件Property,value); } | |||||
} | } | ||||
public static readonly DependencyProperty 停止出料单击事件Property = | |||||
DependencyProperty.Register("停止出料单击事件",typeof(MessageNameEnum),typeof(Silos),new PropertyMetadata(MessageNameEnum.Null)); | |||||
#endregion | #endregion | ||||
#region 函数 | #region 函数 | ||||
@@ -356,6 +389,24 @@ namespace BPASmartClient.SCADAControl | |||||
{ | { | ||||
} | } | ||||
/// <summary> | |||||
/// 接收数据改变 | |||||
/// </summary> | |||||
public void ReceiveNameRefresh() | |||||
{ | |||||
if (!string.IsNullOrEmpty(EventReceiveNameListStr)) | |||||
{ | |||||
try | |||||
{ | |||||
EventReceiveNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventReceiveNameListStr); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | |||||
} | |||||
#endregion | #endregion | ||||
#region 运行事件 | #region 运行事件 | ||||
@@ -384,14 +435,15 @@ namespace BPASmartClient.SCADAControl | |||||
} | } | ||||
} | } | ||||
List<string> MessageNameNew = EventReceiveNameList?.Select(o => o.MeaageName.ToString())?.Distinct()?.ToList(); | List<string> MessageNameNew = EventReceiveNameList?.Select(o => o.MeaageName.ToString())?.Distinct()?.ToList(); | ||||
if (MessageNameL==null || !MessageNameNew.SequenceEqual(MessageNameL)) | |||||
if (MessageNameL == null || !MessageNameNew.SequenceEqual(MessageNameL)) | |||||
{ | { | ||||
MessageNameL?.ForEach(o => Class_InnerMessageBus.GetInstance().RemoveMessage(o,"SliosEventHandler")); | MessageNameL?.ForEach(o => Class_InnerMessageBus.GetInstance().RemoveMessage(o,"SliosEventHandler")); | ||||
MessageNameNew?.ForEach(x => Class_InnerMessageBus.GetInstance().ListenMessage(this,x,"SliosEventHandler")); | MessageNameNew?.ForEach(x => Class_InnerMessageBus.GetInstance().ListenMessage(this,x,"SliosEventHandler")); | ||||
MessageNameL = MessageNameNew; | MessageNameL = MessageNameNew; | ||||
} | } | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 统一事件消息处理中心 | /// 统一事件消息处理中心 | ||||
@@ -446,7 +498,29 @@ namespace BPASmartClient.SCADAControl | |||||
try | try | ||||
{ | { | ||||
Image image = sender as Image; | Image image = sender as Image; | ||||
if (image.Tag != null) | |||||
{ | |||||
if (image.Tag.ToString() == "出料" && 出料单击事件 != MessageNameEnum.Null) | |||||
{ | |||||
EventSendMessage eventSend = new EventSendMessage(); | |||||
eventSend.ControlName = this.Name; | |||||
eventSend.ControlTitle = this.Title; | |||||
eventSend.ControlSource = image.Tag.ToString(); | |||||
eventSend.EventType = ControlEventType.MouseLeftButtonDown; | |||||
eventSend.MeaageName = 出料单击事件; | |||||
Class_InnerMessageBus.GetInstance().PostMessage(this,出料单击事件.ToString(),eventSend); | |||||
} | |||||
else if (image.Tag.ToString() == "停止出料" && 停止出料单击事件 != MessageNameEnum.Null) | |||||
{ | |||||
EventSendMessage eventSend = new EventSendMessage(); | |||||
eventSend.ControlName = this.Name; | |||||
eventSend.ControlTitle = this.Title; | |||||
eventSend.ControlSource = image.Tag.ToString(); | |||||
eventSend.EventType = ControlEventType.MouseLeftButtonDown; | |||||
eventSend.MeaageName = 停止出料单击事件; | |||||
Class_InnerMessageBus.GetInstance().PostMessage(this,停止出料单击事件.ToString(),eventSend); | |||||
} | |||||
} | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
@@ -495,7 +569,5 @@ namespace BPASmartClient.SCADAControl | |||||
} | } | ||||
#endregion | #endregion | ||||
} | } | ||||
} | } |
@@ -16,11 +16,14 @@ | |||||
<Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
<RowDefinition Height="40"/> | <RowDefinition Height="40"/> | ||||
<RowDefinition/> | <RowDefinition/> | ||||
<RowDefinition Height="200"/> | |||||
</Grid.RowDefinitions> | </Grid.RowDefinitions> | ||||
<Button Click="Button_Click">加载文件</Button> | <Button Click="Button_Click">加载文件</Button> | ||||
<local:RunCanvas Grid.Row="1" x:Name="runCanvas"/> | <local:RunCanvas Grid.Row="1" x:Name="runCanvas"/> | ||||
<TextBox x:Name="LogShow" Grid.Row="2" TextWrapping="Wrap" Foreground="#FFF100C7" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" FontFamily="宋体" Background="#FF282B29" FontSize="10"></TextBox> | |||||
<Grid Grid.Column="1" Grid.RowSpan="2"> | <Grid Grid.Column="1" Grid.RowSpan="2"> | ||||
<Border BorderBrush="AntiqueWhite" BorderThickness="3"> | <Border BorderBrush="AntiqueWhite" BorderThickness="3"> | ||||
@@ -1,9 +1,12 @@ | |||||
using BPASmartClient.MessageCommunication; | using BPASmartClient.MessageCommunication; | ||||
using BPASmartClient.MessageCommunication.MsgControl; | |||||
using BPASmartClient.MessageName; | using BPASmartClient.MessageName; | ||||
using BPASmartClient.MessageName.EnumHelp; | using BPASmartClient.MessageName.EnumHelp; | ||||
using BPASmartClient.MessageName.发送消息Model; | |||||
using BPASmartClient.MessageName.接收消息Model; | using BPASmartClient.MessageName.接收消息Model; | ||||
using BPASmartClient.MessageName.接收消息Model.物料仓; | using BPASmartClient.MessageName.接收消息Model.物料仓; | ||||
using Microsoft.Win32; | using Microsoft.Win32; | ||||
using Newtonsoft.Json; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.IO; | using System.IO; | ||||
@@ -43,9 +46,32 @@ namespace SCADA.Test | |||||
xxnc.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList(); | xxnc.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList(); | ||||
mlname.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList(); | mlname.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList(); | ||||
xx.ItemsSource = System.Enum.GetNames(typeof(RunEnum))?.ToList(); | xx.ItemsSource = System.Enum.GetNames(typeof(RunEnum))?.ToList(); | ||||
Class_InnerMessageBus.GetInstance().ListenMessage(this,MessageNameEnum.SendMessageName.ToString(),"MainWindowHandler"); | |||||
} | |||||
public void MainWindowHandler(object sender,InnerMessageEventArgs e) | |||||
{ | |||||
try | |||||
{ | |||||
if (e.obj_MessageObj is EventSendMessage)//接收到运行消息 | |||||
{ | |||||
EventSendMessage mode = (EventSendMessage)e.obj_MessageObj; | |||||
LogShowText(JsonConvert.SerializeObject(mode)); | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
} | |||||
} | } | ||||
#region 加载数据 | #region 加载数据 | ||||
public void LogShowText(string str) | |||||
{ | |||||
LogShow.Text += str + "\n"; | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 加载数据 | /// 加载数据 | ||||
/// </summary> | /// </summary> | ||||
@@ -7,6 +7,10 @@ | |||||
<UseWPF>true</UseWPF> | <UseWPF>true</UseWPF> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | |||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" /> | <ProjectReference Include="..\BPASmartClient.Compiler\BPASmartClient.Compiler.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | <ProjectReference Include="..\BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj" /> | ||||