终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

720 lines
28 KiB

  1. using BPASmartClient.Compiler;
  2. using BPASmartClient.DATABUS;
  3. using BPASmartClient.MessageCommunication;
  4. using BPASmartClient.MessageCommunication.MsgControl;
  5. using BPASmartClient.MessageName;
  6. using BPASmartClient.MessageName.EnumHelp;
  7. using BPASmartClient.MessageName.发送消息Model;
  8. using BPASmartClient.MessageName.接收消息Model;
  9. using BPASmartClient.MessageName.接收消息Model.物料仓;
  10. using Newtonsoft.Json;
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Generic;
  14. using System.Collections.ObjectModel;
  15. using System.ComponentModel;
  16. using System.Drawing.Design;
  17. using System.Linq;
  18. using System.Reflection;
  19. using System.Text;
  20. using System.Threading.Tasks;
  21. using System.Windows;
  22. using System.Windows.Controls;
  23. using System.Windows.Data;
  24. using System.Windows.Documents;
  25. using System.Windows.Input;
  26. using System.Windows.Media;
  27. using System.Windows.Media.Animation;
  28. using System.Windows.Media.Imaging;
  29. using System.Windows.Navigation;
  30. using System.Windows.Shapes;
  31. using System.Windows.Threading;
  32. namespace BPASmartClient.SCADAControl.CustomerControls
  33. {
  34. /// <summary>
  35. /// Silos.xaml 的交互逻辑
  36. /// 物料仓
  37. /// </summary>
  38. public partial class Silos :UserControl, IExecutable, IDisposable
  39. {
  40. #region 临时变量
  41. TextBlock textBlockCLKZ = null;
  42. TextBlock textBlockValue = null;
  43. TextBlock textBlockText = null;
  44. TextBlock textBlockTitle = null;
  45. Ellipse ellipseControl = null;
  46. Storyboard storyboard = new Storyboard();
  47. object typeName;
  48. public List<string> typeNameList = new List<string>();
  49. public Enum @enum = null;
  50. #endregion
  51. public Silos()
  52. {
  53. InitializeComponent();
  54. this.DataContext = this;
  55. Width = 180;
  56. Height = 270;
  57. this.SizeChanged += Silos_SizeChanged; ;
  58. this.Loaded += Silos_Loaded;
  59. }
  60. private void Silos_Loaded(object sender,RoutedEventArgs e)
  61. {
  62. EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged;
  63. EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged;
  64. }
  65. private void EventSendNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  66. {
  67. if (EventSendNameList.Count > 0)
  68. {
  69. try
  70. {
  71. EventSendNameListStr = JsonConvert.SerializeObject(EventSendNameList);
  72. }
  73. catch (Exception ex)
  74. {
  75. }
  76. }
  77. }
  78. private void EventNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  79. {
  80. if (EventReceiveNameList.Count > 0)
  81. {
  82. try
  83. {
  84. EventReceiveNameListStr = JsonConvert.SerializeObject(EventReceiveNameList);
  85. }
  86. catch (Exception ex)
  87. {
  88. }
  89. }
  90. }
  91. public string ControlType => "物料仓";
  92. private bool isExecuteState;
  93. public bool IsExecuteState
  94. {
  95. get { return isExecuteState; }
  96. set
  97. {
  98. isExecuteState = value;
  99. if (IsExecuteState)
  100. {
  101. IsEnabled = true;
  102. Register();
  103. Style = null;
  104. }
  105. }
  106. }
  107. #region 动画
  108. /// <summary>
  109. /// 加载内部变量
  110. /// </summary>
  111. private void Silos_SizeChanged(object sender,SizeChangedEventArgs e)
  112. {
  113. //查找
  114. if (ellipseControl == null)
  115. {
  116. foreach (Ellipse tb in FindVisualChildren<Ellipse>(this))
  117. {
  118. // do something with tb here
  119. if (tb.Tag != null)
  120. {
  121. if (tb.Tag.ToString() == "出料圆")
  122. {
  123. ellipseControl = tb;
  124. storyboard.RepeatBehavior = RepeatBehavior.Forever;
  125. DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
  126. Storyboard.SetTarget(animation,ellipseControl);
  127. Storyboard.SetTargetProperty(animation,new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"));
  128. animation.KeyFrames.Add(new EasingDoubleKeyFrame(0,KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0))));
  129. animation.KeyFrames.Add(new EasingDoubleKeyFrame(180,KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1))));
  130. animation.KeyFrames.Add(new EasingDoubleKeyFrame(360,KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2))));
  131. storyboard.Children.Add(animation);
  132. }
  133. }
  134. }
  135. foreach (TextBlock tb in FindVisualChildren<TextBlock>(this))
  136. {
  137. // do something with tb here
  138. if (tb.Tag != null)
  139. {
  140. if (tb.Tag.ToString() == "出料控制")
  141. {
  142. textBlockCLKZ = tb;
  143. }
  144. else if (tb.Tag.ToString() == "Value")
  145. {
  146. textBlockValue = tb;
  147. }
  148. else if (tb.Tag.ToString() == "Text")
  149. {
  150. textBlockText = tb;
  151. }
  152. else if (tb.Tag.ToString() == "Title")
  153. {
  154. textBlockTitle = tb;
  155. }
  156. }
  157. }
  158. foreach (StackPanel tb in FindVisualChildren<StackPanel>(this))
  159. {
  160. // do something with tb here
  161. if (tb.Tag != null)
  162. {
  163. if (tb.Tag.ToString() == "ControlEvent")
  164. {
  165. foreach (var item in tb.Children)
  166. {
  167. if (item is Image)
  168. {
  169. (item as Image).MouseLeftButtonDown += Image_MouseLeftButtonDown;
  170. if ((item as Image).Tag != null)
  171. typeNameList.Add((item as Image).Tag?.ToString());
  172. }
  173. else if (item is Button)
  174. {
  175. (item as Button).Click += Button_Click;
  176. if ((item as Button).Tag != null)
  177. typeNameList.Add((item as Button).Tag?.ToString());
  178. }
  179. else if (item is TextBox)
  180. {
  181. (item as TextBox).TextChanged += TextBox_TextChanged;
  182. if ((item as TextBox).Tag != null)
  183. typeNameList.Add((item as TextBox).Tag?.ToString());
  184. }
  185. else if (item is CheckBox)
  186. {
  187. (item as CheckBox).Checked += CheckBox_Checked;
  188. (item as CheckBox).Unchecked += CheckBox_Unchecked;
  189. if ((item as CheckBox).Tag != null)
  190. typeNameList.Add((item as CheckBox).Tag?.ToString());
  191. }
  192. }
  193. @enum = EnumExtensions.CreateEnum(typeNameList,$"{this.Name}ControlEunm");
  194. }
  195. }
  196. }
  197. }
  198. }
  199. public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
  200. {
  201. if (depObj != null)
  202. {
  203. for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
  204. {
  205. DependencyObject child = VisualTreeHelper.GetChild(depObj,i);
  206. if (child != null && child is T)
  207. {
  208. yield return (T)child;
  209. }
  210. foreach (T childOfChild in FindVisualChildren<T>(child))
  211. {
  212. yield return childOfChild;
  213. }
  214. }
  215. }
  216. }
  217. #endregion
  218. #region 属性
  219. [Category("值设定")]
  220. public string Value
  221. {
  222. get { return (string)GetValue(ValueProperty); }
  223. set { SetValue(ValueProperty,value); }
  224. }
  225. public static readonly DependencyProperty ValueProperty =
  226. DependencyProperty.Register("Value",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));
  227. private static void onTargetChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.TargetRefresh();
  228. [Category("值设定")]
  229. public string Text
  230. {
  231. get { return (string)GetValue(TextProperty); }
  232. set { SetValue(TextProperty,value); }
  233. }
  234. public static readonly DependencyProperty TextProperty =
  235. DependencyProperty.Register("Text",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));
  236. [Category("值设定")]
  237. public string Title
  238. {
  239. get { return (string)GetValue(TitleProperty); }
  240. set { SetValue(TitleProperty,value); }
  241. }
  242. public static readonly DependencyProperty TitleProperty =
  243. DependencyProperty.Register("Title",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged)));
  244. [Category("值设定")]
  245. public int Direction
  246. {
  247. get { return (int)GetValue(DirectionProperty); }
  248. set { SetValue(DirectionProperty,value); }
  249. }
  250. public static readonly DependencyProperty DirectionProperty =
  251. DependencyProperty.Register("Direction",typeof(int),typeof(Silos),
  252. new PropertyMetadata(0,new PropertyChangedCallback(OnPropertyChanged)));
  253. private static void OnPropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)
  254. {
  255. (d as Silos)?.Refresh();
  256. }
  257. [Category("名称[自动生成]")]
  258. public string EventReceiveNameListStr
  259. {
  260. get { return (string)GetValue(EventReceiveNameListStrProperty); }
  261. set { SetValue(EventReceiveNameListStrProperty,value); }
  262. }
  263. public static readonly DependencyProperty EventReceiveNameListStrProperty =
  264. DependencyProperty.Register("EventReceiveNameListStr",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty,new PropertyChangedCallback(onEventReceiveNameListStrChanged)));
  265. private static void onEventReceiveNameListStrChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.ReceiveNameRefresh();
  266. [Category("消息接收名称集合")]
  267. public ObservableCollection<EventReceiveMessage> EventReceiveNameList
  268. {
  269. get { return (ObservableCollection<EventReceiveMessage>)GetValue(EventReceiveNameListProperty); }
  270. set { SetValue(EventReceiveNameListProperty,value); }
  271. }
  272. public static readonly DependencyProperty EventReceiveNameListProperty =
  273. DependencyProperty.Register("EventReceiveNameList",typeof(ObservableCollection<EventReceiveMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(),new PropertyChangedCallback(onEventNameListChanged)));
  274. [Category("名称[自动生成]")]
  275. private string EventSendNameListStr
  276. {
  277. get { return (string)GetValue(EventSendNameListStrProperty); }
  278. set { SetValue(EventSendNameListStrProperty,value); }
  279. }
  280. private static readonly DependencyProperty EventSendNameListStrProperty =
  281. DependencyProperty.Register("EventSendNameListStr",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
  282. [Category("消息发送名称集合")]
  283. private ObservableCollection<EventSendMessage> EventSendNameList
  284. {
  285. get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); }
  286. set { SetValue(EventSendNameListProperty,value); }
  287. }
  288. private static readonly DependencyProperty EventSendNameListProperty =
  289. DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged)));
  290. private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh();
  291. #endregion
  292. #region 数据绑定模块
  293. public event EventHandler PropertyChange; //声明一个事件
  294. //[Category("数据绑定-数据来源")]
  295. //public DataTypeEnum DataSouceType
  296. //{
  297. // get { return (DataTypeEnum)GetValue(DataSouceTypeProperty); }
  298. // set { SetValue(DataSouceTypeProperty,value); }
  299. //}
  300. //public static readonly DependencyProperty DataSouceTypeProperty =
  301. // DependencyProperty.Register("DataSouceType",typeof(DataTypeEnum),typeof(Silos),new PropertyMetadata(DataTypeEnum.静态数据));
  302. [Category("数据绑定-数据来源")]
  303. public int TimeCount
  304. {
  305. get { return (int)GetValue(TimeCountProperty); }
  306. set { SetValue(TimeCountProperty,value); }
  307. }
  308. public static readonly DependencyProperty TimeCountProperty =
  309. DependencyProperty.Register("TimeCount",typeof(int),typeof(Silos),new PropertyMetadata(5));
  310. //[Category("数据绑定-数据来源")]
  311. //public string DataSouceInformation
  312. //{
  313. // get { return (string)GetValue(DataSouceInformationProperty); }
  314. // set { SetValue(DataSouceInformationProperty,value); }
  315. //}
  316. //public static readonly DependencyProperty DataSouceInformationProperty =
  317. // DependencyProperty.Register("DataSouceInformation",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
  318. //[Category("数据绑定-数据来源")]
  319. //public string DeviceName
  320. //{
  321. // get { return (string)GetValue(DeviceNameProperty); }
  322. // set { SetValue(DeviceNameProperty,value); }
  323. //}
  324. //public static readonly DependencyProperty DeviceNameProperty =
  325. // DependencyProperty.Register("DeviceName",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
  326. //[Category("数据绑定-数据来源")]
  327. //public string DeviceValuleName
  328. //{
  329. // get { return (string)GetValue(DeviceValuleNameProperty); }
  330. // set { SetValue(DeviceValuleNameProperty,value); }
  331. //}
  332. //public static readonly DependencyProperty DeviceValuleNameProperty =
  333. // DependencyProperty.Register("DeviceValuleName",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
  334. [Category("数据绑定")]
  335. public string FDataSouce
  336. {
  337. get { return (string)GetValue(FDataSouceProperty); }
  338. set { SetValue(FDataSouceProperty,value); }
  339. }
  340. public static readonly DependencyProperty FDataSouceProperty =
  341. DependencyProperty.Register("FDataSouce",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty,new PropertyChangedCallback(onFDataSouceChanged)));
  342. private static void onFDataSouceChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataSouceRefresh();
  343. public void DataSouceRefresh()
  344. {
  345. try
  346. {
  347. if (!string.IsNullOrEmpty(FDataSouce))
  348. {
  349. GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code,new object[] { FDataSouce });
  350. if (PropertyChange != null)
  351. {
  352. PropertyChange(this,null);
  353. }
  354. }
  355. }
  356. catch (Exception ex)
  357. {
  358. }
  359. }
  360. public static string _code = "public string main(string message) \n{ \n //请在此填写你的代码\n\n return message; \n}\n";
  361. [Category("数据绑定")]
  362. public string Code
  363. {
  364. get { return (string)GetValue(CodeProperty); }
  365. set { SetValue(CodeProperty,value); }
  366. }
  367. public static readonly DependencyProperty CodeProperty =
  368. DependencyProperty.Register("Code",typeof(string),typeof(Silos),new PropertyMetadata(_code));
  369. [Category("数据绑定")]
  370. public string GenerateData
  371. {
  372. get { return (string)GetValue(GenerateDataProperty); }
  373. set { SetValue(GenerateDataProperty,value); }
  374. }
  375. public static readonly DependencyProperty GenerateDataProperty =
  376. DependencyProperty.Register("GenerateData",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
  377. #endregion
  378. #region 发送事件名称集合
  379. [Category("事件处理")]
  380. public MessageNameEnum 出料单击事件
  381. {
  382. get { return (MessageNameEnum)GetValue(出料单击事件Property); }
  383. set { SetValue(出料单击事件Property,value); }
  384. }
  385. public static readonly DependencyProperty 出料单击事件Property =
  386. DependencyProperty.Register("出料单击事件",typeof(MessageNameEnum),typeof(Silos),new PropertyMetadata(MessageNameEnum.Null));
  387. [Category("事件处理")]
  388. public MessageNameEnum 停止出料单击事件
  389. {
  390. get { return (MessageNameEnum)GetValue(停止出料单击事件Property); }
  391. set { SetValue(停止出料单击事件Property,value); }
  392. }
  393. public static readonly DependencyProperty 停止出料单击事件Property =
  394. DependencyProperty.Register("停止出料单击事件",typeof(MessageNameEnum),typeof(Silos),new PropertyMetadata(MessageNameEnum.Null));
  395. #endregion
  396. #region 函数
  397. /// <summary>
  398. /// 目标属性刷新
  399. /// </summary>
  400. public void TargetRefresh()
  401. {
  402. if (textBlockValue != null && textBlockText != null && textBlockTitle != null)
  403. {
  404. textBlockValue.Text = Value;
  405. textBlockText.Text = Text;
  406. textBlockTitle.Text = Title;
  407. }
  408. }
  409. /// <summary>
  410. /// 值变化刷新
  411. /// </summary>
  412. public void Refresh()
  413. {
  414. if (ellipseControl != null)
  415. {
  416. if (Direction == 1)
  417. {
  418. ellipseControl.Visibility = Visibility.Visible;
  419. textBlockCLKZ.Visibility = Visibility.Visible;
  420. storyboard.Begin();
  421. }
  422. else if (Direction == 2)
  423. {
  424. ellipseControl.Visibility = Visibility.Collapsed;
  425. textBlockCLKZ.Visibility = Visibility.Collapsed;
  426. storyboard.Stop();
  427. }
  428. else
  429. {
  430. ellipseControl.Visibility = Visibility.Collapsed;
  431. textBlockCLKZ.Visibility = Visibility.Collapsed;
  432. storyboard.Stop();
  433. }
  434. }
  435. }
  436. /// <summary>
  437. /// 运行名称变化事件
  438. /// </summary>
  439. public void RunNameRefresh()
  440. {
  441. }
  442. /// <summary>
  443. /// 数据名称变化事件
  444. /// </summary>
  445. public void DataNameRefresh()
  446. {
  447. }
  448. /// <summary>
  449. /// 接收数据改变
  450. /// </summary>
  451. public void ReceiveNameRefresh()
  452. {
  453. if (!string.IsNullOrEmpty(EventReceiveNameListStr))
  454. {
  455. try
  456. {
  457. EventReceiveNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventReceiveNameListStr);
  458. }
  459. catch (Exception ex)
  460. {
  461. }
  462. }
  463. }
  464. #endregion
  465. #region 运行事件
  466. DispatcherTimer timer = new DispatcherTimer();
  467. Dictionary<string, string> propertyBing = new Dictionary<string,string>();
  468. List<string> MessageNameL = null;
  469. public void Register()
  470. {
  471. if (!string.IsNullOrEmpty(EventReceiveNameListStr))
  472. {
  473. try
  474. {
  475. EventReceiveNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventReceiveNameListStr);
  476. }
  477. catch (Exception ex)
  478. {
  479. }
  480. }
  481. if (!string.IsNullOrEmpty(EventSendNameListStr))
  482. {
  483. try
  484. {
  485. EventSendNameList = JsonConvert.DeserializeObject<ObservableCollection<EventSendMessage>>(EventSendNameListStr);
  486. }
  487. catch (Exception ex)
  488. {
  489. }
  490. }
  491. List<string> MessageNameNew = EventReceiveNameList?.Select(o => o.MeaageName.ToString())?.Distinct()?.ToList();
  492. if (MessageNameL == null || !MessageNameNew.SequenceEqual(MessageNameL))
  493. {
  494. MessageNameL?.ForEach(o => Class_InnerMessageBus.GetInstance().RemoveMessage(o,"SliosEventHandler"));
  495. MessageNameNew?.ForEach(x => Class_InnerMessageBus.GetInstance().ListenMessage(this,x,"SliosEventHandler"));
  496. MessageNameL = MessageNameNew;
  497. }
  498. PropertyInfo[] propertyInfos = this.GetType().GetProperties();
  499. foreach (PropertyInfo propertyInfo in propertyInfos)
  500. {
  501. var propName = propertyInfo?.GetValue(this,null);
  502. if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
  503. {
  504. propertyBing[propertyInfo.Name] = propName.ToString();
  505. }
  506. }
  507. timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
  508. timer.Tick += Timer_Tick; ;
  509. timer.Start();
  510. }
  511. private void Timer_Tick(object? sender,EventArgs e)
  512. {
  513. try
  514. {
  515. foreach (var item in propertyBing)
  516. {
  517. //{Binding 测试设备.VAR_A_2}
  518. string[] str= item.Value.Replace("{Binding ","").Replace("}","").Split(".");
  519. if (str.Length > 1)
  520. {
  521. if (Class_DataBus.GetInstance().Dic_DeviceData.ContainsKey(str[0]))
  522. {
  523. Dictionary<string,object> b= Class_DataBus.GetInstance().Dic_DeviceData[str[0]];
  524. if (b!=null && b.ContainsKey(str[1]))
  525. {
  526. object _value = b[str[1]];
  527. this.GetType().GetProperty(item.Key).SetValue(this,_value);
  528. }
  529. }
  530. }
  531. }
  532. }
  533. catch (Exception ex)
  534. {
  535. }
  536. }
  537. /// <summary>
  538. /// 统一事件消息处理中心
  539. /// </summary>
  540. /// <param name="sender"></param>
  541. /// <param name="e"></param>
  542. public void SliosEventHandler(object sender,InnerMessageEventArgs e)
  543. {
  544. try
  545. {
  546. if (IsExecuteState = true)//正在运行
  547. {
  548. if (e.obj_MessageObj is RunEnumModel)//接收到运行消息
  549. {
  550. RunEnumModel mode = (RunEnumModel)e.obj_MessageObj;
  551. var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
  552. //必对消息号:
  553. if (msg != null)
  554. {
  555. Direction = mode.Run == RunEnum.Run ? 1 : 2;
  556. }
  557. }
  558. else if (e.obj_MessageObj is SilosMessageModel)//接收到数据模型
  559. {
  560. SilosMessageModel mode = (SilosMessageModel)e.obj_MessageObj;
  561. var msg = EventReceiveNameList?.ToList().Find(par => par.MeaageName.ToString() == e.str_MessageStr && par.MeaageID == mode.MessageID);
  562. //必对消息号:
  563. if (msg != null)
  564. {
  565. Title = mode.Title;
  566. Value = mode.Value;
  567. Text = mode.Text;
  568. }
  569. }
  570. }
  571. }
  572. catch (Exception ex)
  573. {
  574. }
  575. }
  576. #endregion
  577. #region 发送消息事件
  578. public void Dispose()
  579. {
  580. timer.Stop();
  581. }
  582. /// <summary>
  583. /// 按钮按下
  584. /// </summary>
  585. /// <param name="sender"></param>
  586. /// <param name="e"></param>
  587. private void Image_MouseLeftButtonDown(object sender,MouseButtonEventArgs e)
  588. {
  589. try
  590. {
  591. Image image = sender as Image;
  592. if (image.Tag != null)
  593. {
  594. if (image.Tag.ToString() == "出料" && 出料单击事件 != MessageNameEnum.Null)
  595. {
  596. EventSendMessage eventSend = new EventSendMessage();
  597. eventSend.ControlName = this.Name;
  598. eventSend.ControlTitle = this.Title;
  599. eventSend.ControlSource = image.Tag.ToString();
  600. eventSend.EventType = ControlEventType.MouseLeftButtonDown;
  601. eventSend.MeaageName = 出料单击事件;
  602. Class_InnerMessageBus.GetInstance().PostMessage(this,出料单击事件.ToString(),eventSend);
  603. }
  604. else if (image.Tag.ToString() == "停止出料" && 停止出料单击事件 != MessageNameEnum.Null)
  605. {
  606. EventSendMessage eventSend = new EventSendMessage();
  607. eventSend.ControlName = this.Name;
  608. eventSend.ControlTitle = this.Title;
  609. eventSend.ControlSource = image.Tag.ToString();
  610. eventSend.EventType = ControlEventType.MouseLeftButtonDown;
  611. eventSend.MeaageName = 停止出料单击事件;
  612. Class_InnerMessageBus.GetInstance().PostMessage(this,停止出料单击事件.ToString(),eventSend);
  613. }
  614. }
  615. }
  616. catch (Exception ex)
  617. {
  618. }
  619. }
  620. /// <summary>
  621. /// 按钮类型
  622. /// </summary>
  623. /// <param name="sender"></param>
  624. /// <param name="e"></param>
  625. private void Button_Click(object sender,RoutedEventArgs e)
  626. {
  627. }
  628. /// <summary>
  629. /// 值改变
  630. /// </summary>
  631. /// <param name="sender"></param>
  632. /// <param name="e"></param>
  633. private void TextBox_TextChanged(object sender,TextChangedEventArgs e)
  634. {
  635. }
  636. /// <summary>
  637. /// 选中
  638. /// </summary>
  639. /// <param name="sender"></param>
  640. /// <param name="e"></param>
  641. private void CheckBox_Checked(object sender,RoutedEventArgs e)
  642. {
  643. }
  644. /// <summary>
  645. /// 取消选中
  646. /// </summary>
  647. /// <param name="sender"></param>
  648. /// <param name="e"></param>
  649. private void CheckBox_Unchecked(object sender,RoutedEventArgs e)
  650. {
  651. }
  652. #endregion
  653. }
  654. }