FoupTopView3.xaml.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using System.ComponentModel;
  2. using System.Runtime.CompilerServices;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Media;
  6. using MECF.Framework.Common.CommonData;
  7. using MECF.Framework.Common.OperationCenter;
  8. using MECF.Framework.UI.Client.Annotations;
  9. namespace MECF.Framework.UI.Client.Ctrlib.UnitControls
  10. {
  11. /// <summary>
  12. /// Door.xaml 的交互逻辑
  13. /// </summary>
  14. public partial class FoupTopView3 : UserControl, INotifyPropertyChanged
  15. {
  16. public double CanvasYPosition { get; set; }
  17. public bool _isFoupLoaded;
  18. public bool IsFoupLoaded
  19. {
  20. get { return (bool)GetValue(IsFoupLoadedProperty); }
  21. set
  22. {
  23. SetValue(IsFoupLoadedProperty, value);
  24. CanvasYPosition = value ? -20 : 0;
  25. OnPropertyChanged(nameof(CanvasYPosition));
  26. }
  27. }
  28. public static readonly DependencyProperty IsFoupLoadedProperty =
  29. DependencyProperty.Register("IsFoupLoaded", typeof(bool), typeof(FoupTopView3),
  30. new PropertyMetadata(false, PropertyChangedCallback));
  31. public string ModuleName
  32. {
  33. get { return (string)GetValue(ModuleNameProperty); }
  34. set { SetValue(ModuleNameProperty, value); }
  35. }
  36. public static readonly DependencyProperty ModuleNameProperty =
  37. DependencyProperty.Register("ModuleName", typeof(string), typeof(FoupTopView3),
  38. new PropertyMetadata("LP1", PropertyChangedCallback));
  39. public Visibility MenuVisibility
  40. {
  41. get { return (Visibility)this.GetValue(MenuVisibilityProperty); }
  42. set { this.SetValue(MenuVisibilityProperty, value); }
  43. }
  44. public static readonly DependencyProperty MenuVisibilityProperty =
  45. DependencyProperty.Register("MenuVisibility", typeof(Visibility), typeof(FoupTopView3),
  46. new FrameworkPropertyMetadata(Visibility.Visible, FrameworkPropertyMetadataOptions.AffectsRender));
  47. public LPMenuEnable DeviceData
  48. {
  49. get
  50. {
  51. return (LPMenuEnable)this.GetValue(DeviceDataProperty);
  52. }
  53. set
  54. {
  55. this.SetValue(DeviceDataProperty, value);
  56. }
  57. }
  58. public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
  59. "DeviceData", typeof(LPMenuEnable), typeof(FoupTopView3),
  60. new FrameworkPropertyMetadata(new LPMenuEnable(), FrameworkPropertyMetadataOptions.AffectsRender));
  61. public FoupTopView3()
  62. {
  63. InitializeComponent();
  64. }
  65. public event PropertyChangedEventHandler PropertyChanged;
  66. [NotifyPropertyChangedInvocator]
  67. protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
  68. {
  69. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  70. }
  71. static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  72. {
  73. var self = (FoupTopView3)d;
  74. switch (e.Property.Name)
  75. {
  76. case "IsFoupLoaded":
  77. self.CanvasYPosition = (bool)e.NewValue ? -30 : 0;
  78. self.OnPropertyChanged(nameof(CanvasYPosition));
  79. break;
  80. default:
  81. self.OnPropertyChanged(nameof(e.Property.Name));
  82. break;
  83. }
  84. }
  85. protected override void OnRender(DrawingContext drawingContext)
  86. {
  87. base.OnRender(drawingContext);
  88. canvas.ContextMenu.Visibility = MenuVisibility;
  89. if (DeviceData == null)
  90. return;
  91. if (MenuVisibility == Visibility.Visible && canvas.ContextMenu.Items != null && canvas.ContextMenu.Items.Count == 13)
  92. {
  93. ((MenuItem)canvas.ContextMenu.Items[1]).IsEnabled = DeviceData.IsResetEnable;
  94. ((MenuItem)canvas.ContextMenu.Items[2]).IsEnabled = DeviceData.IsAbortEnable;
  95. ((MenuItem)canvas.ContextMenu.Items[3]).IsEnabled = DeviceData.IsLoadEnable;
  96. ((MenuItem)canvas.ContextMenu.Items[4]).IsEnabled = DeviceData.IsUnloadEnable;
  97. ((MenuItem)canvas.ContextMenu.Items[5]).IsEnabled = DeviceData.IsReadCarrierIDEnable;
  98. ((MenuItem)canvas.ContextMenu.Items[6]).IsEnabled = DeviceData.IsClampEnable;
  99. ((MenuItem)canvas.ContextMenu.Items[7]).IsEnabled = DeviceData.IsUnclampEnable;
  100. ((MenuItem)canvas.ContextMenu.Items[8]).IsEnabled = DeviceData.IsDockEnable;
  101. ((MenuItem)canvas.ContextMenu.Items[9]).IsEnabled = DeviceData.IsUndockEnable;
  102. ((MenuItem)canvas.ContextMenu.Items[10]).IsEnabled = DeviceData.IsOpenEnable;
  103. ((MenuItem)canvas.ContextMenu.Items[11]).IsEnabled = DeviceData.IsCloseEnable;
  104. ((MenuItem)canvas.ContextMenu.Items[12]).IsEnabled = DeviceData.IsMapEnable;
  105. }
  106. }
  107. private void Home(object sender, RoutedEventArgs e)
  108. {
  109. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Home");
  110. }
  111. private void Reset(object sender, RoutedEventArgs e)
  112. {
  113. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Reset");
  114. }
  115. private void Abort(object sender, RoutedEventArgs e)
  116. {
  117. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Abort");
  118. }
  119. private void ReadCarrierID(object sender, RoutedEventArgs e)
  120. {
  121. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ReadCarrierId");
  122. }
  123. private void Load(object sender, RoutedEventArgs e)
  124. {
  125. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Load");
  126. }
  127. private void Unload(object sender, RoutedEventArgs e)
  128. {
  129. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Unload");
  130. }
  131. private void Clamp(object sender, RoutedEventArgs e)
  132. {
  133. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Clamp");
  134. }
  135. private void Unclamp(object sender, RoutedEventArgs e)
  136. {
  137. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Unclamp");
  138. }
  139. private void Dock(object sender, RoutedEventArgs e)
  140. {
  141. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Dock");
  142. }
  143. private void Undock(object sender, RoutedEventArgs e)
  144. {
  145. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Undock");
  146. }
  147. private void OpenDoor(object sender, RoutedEventArgs e)
  148. {
  149. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.OpenDoor");
  150. }
  151. private void CloseDoor(object sender, RoutedEventArgs e)
  152. {
  153. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.CloseDoor");
  154. }
  155. private void Map(object sender, RoutedEventArgs e)
  156. {
  157. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.Map");
  158. }
  159. }
  160. }