VceControl.xaml.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. using OpenSEMI.ClientBase;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Animation;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. using Venus_Core;
  18. using OpenSEMI.Ctrlib.Controls;
  19. using System.Diagnostics;
  20. namespace Venus_Themes.UserControls
  21. {
  22. /// <summary>
  23. /// VceControl.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class VceControl : UserControl
  26. {
  27. public VceControl()
  28. {
  29. InitializeComponent();
  30. }
  31. //Wafer信息
  32. public double TransformData
  33. {
  34. get { return (double)GetValue(TransformDataProperty); }
  35. set { SetValue(TransformDataProperty, value); }
  36. }
  37. public static readonly DependencyProperty TransformDataProperty =
  38. DependencyProperty.Register("TransformData", typeof(double), typeof(VceControl), new UIPropertyMetadata(null));
  39. public List<WaferInfo> UnitData2
  40. {
  41. get { return (List<WaferInfo>)GetValue(UnitData2Property); }
  42. set { SetValue(UnitData2Property, value); }
  43. }
  44. public static readonly DependencyProperty UnitData2Property =
  45. DependencyProperty.Register("UnitData2", typeof(List<WaferInfo>), typeof(VceControl), new PropertyMetadata(null,FoupWafer));
  46. public static void FoupWafer(DependencyObject d, DependencyPropertyChangedEventArgs e)
  47. {
  48. if (d is VceControl vceControl)
  49. {
  50. List<WaferInfo> UnitData = ((List<WaferInfo>)e.NewValue);
  51. foreach (WaferInfo item in UnitData)
  52. {
  53. if (item.WaferStatus == 1)
  54. {
  55. vceControl.vceFoupAndWafer.Children.Add(VceWaferNames[item.SlotID]);
  56. }
  57. else
  58. {
  59. vceControl.vceFoupAndWafer.Children.Remove(VceWaferNames[item.SlotID]);
  60. }
  61. }
  62. }
  63. }
  64. public bool ShowTitle1
  65. {
  66. get { return (bool)GetValue(ShowTitle1Property); }
  67. set { SetValue(ShowTitle1Property, value); }
  68. }
  69. public static readonly DependencyProperty ShowTitle1Property =
  70. DependencyProperty.Register("ShowTitle1", typeof(bool), typeof(VceControl), new UIPropertyMetadata(true));
  71. private void Slot_SlotMouseButtonDown(object sender, MouseButtonEventArgs e)
  72. {
  73. VenusGlobalEvents.OnSlotRightClickChanged(sender as Slot);
  74. }
  75. private void Slot_WaferTransferStarted(object sender, DragDropEventArgs e)
  76. {
  77. try
  78. {
  79. VenusGlobalEvents.OnSlotWaferTransfer(e);
  80. }
  81. catch (Exception ex)
  82. {
  83. Trace.WriteLine(ex);
  84. }
  85. }
  86. //画Foup
  87. private void foup_Loaded(object sender, RoutedEventArgs e)
  88. {
  89. DrawFoup();
  90. }
  91. //支撑底柱高度
  92. public static readonly DependencyProperty PositionZProperty = DependencyProperty.Register(
  93. "PositionZ", typeof(double), typeof(VceControl));
  94. public double PositionZ
  95. {
  96. get { return (double)GetValue(PositionZProperty); }
  97. set
  98. {
  99. SetValue(PositionZProperty, value);
  100. }
  101. }
  102. //是否开门
  103. public static readonly DependencyProperty VceDoorIsOpenProperty = DependencyProperty.Register(
  104. "VceDoorIsOpen", typeof(bool), typeof(VceControl));
  105. public bool VceDoorIsOpen
  106. {
  107. get { return (bool)this.GetValue(VceDoorIsOpenProperty); }
  108. set { SetValue(VceDoorIsOpenProperty, value); }
  109. }
  110. //槽口位置
  111. public int CurrentSlot
  112. {
  113. get { return (int)GetValue(CurrentSlotProperty); }
  114. set { SetValue(CurrentSlotProperty, value); }
  115. }
  116. public static readonly DependencyProperty CurrentSlotProperty =
  117. DependencyProperty.Register("CurrentSlot", typeof(int), typeof(VceControl), new PropertyMetadata(SelectWafer));
  118. //通过监听Slot值的变化改变wafer样式与Foup移动
  119. private static Image[] VceWaferNames = new Image[25];
  120. public static void SelectWafer(DependencyObject d, DependencyPropertyChangedEventArgs e)
  121. {
  122. if (d is VceControl vceControl)
  123. {
  124. if (Convert.ToInt32(e.NewValue) >= 0 && Convert.ToInt32(e.OldValue) >= 0)
  125. {
  126. VceWaferNames[(int)e.NewValue].Source = new BitmapImage(new Uri(@"F:\\Venus\\Venus\\Venus\\Venus_Themes\\Themes\\Images\\parts\\vce\\WaferSelected.png", UriKind.RelativeOrAbsolute));
  127. VceWaferNames[(int)e.OldValue].Source = new BitmapImage(new Uri(@"F:\\Venus\\Venus\\Venus\\Venus_Themes\\Themes\\Images\\parts\\vce\\Wafer.png", UriKind.RelativeOrAbsolute));
  128. DoubleAnimation floatY = new DoubleAnimation(
  129. 430 - 7 * (25 - (int)e.NewValue),
  130. TimeSpan.FromSeconds(3)
  131. );
  132. vceControl.Foup.BeginAnimation(Canvas.TopProperty, floatY);
  133. }
  134. else if (Convert.ToInt32(e.NewValue) >= 0 && Convert.ToInt32(e.OldValue) < 0)
  135. {
  136. VceWaferNames[(int)e.NewValue].Source = new BitmapImage(new Uri(@"F:\\Venus\\Venus\\Venus\\Venus_Themes\\Themes\\Images\\parts\\vce\\WaferSelected.png", UriKind.RelativeOrAbsolute));
  137. DoubleAnimation floatY = new DoubleAnimation(
  138. 430 - 7 * (25 - (int)e.NewValue),
  139. TimeSpan.FromSeconds(3)
  140. );
  141. vceControl.Foup.BeginAnimation(Canvas.TopProperty, floatY);
  142. }
  143. else if (Convert.ToInt32(e.NewValue) < 0 && Convert.ToInt32(e.OldValue) > 0)
  144. {
  145. VceWaferNames[(int)e.OldValue].Source = new BitmapImage(new Uri(@"F:\\Venus\\Venus\\Venus\\Venus_Themes\\Themes\\Images\\parts\\vce\\Wafer.png", UriKind.RelativeOrAbsolute));
  146. DoubleAnimation floatY = new DoubleAnimation(
  147. 430,
  148. TimeSpan.FromSeconds(3)
  149. );
  150. vceControl.Foup.BeginAnimation(Canvas.TopProperty, floatY);
  151. }
  152. }
  153. }
  154. private Image CreateImage(string ImagePath, int ImageHeight)
  155. {
  156. Image VceImage = new Image();
  157. VceImage.Height = ImageHeight;
  158. BitmapImage myBitmapImage = new BitmapImage();
  159. myBitmapImage.BeginInit();
  160. myBitmapImage.UriSource = new Uri(ImagePath);
  161. myBitmapImage.DecodePixelHeight = ImageHeight;
  162. myBitmapImage.EndInit();
  163. //set image source
  164. VceImage.Source = myBitmapImage;
  165. return VceImage;
  166. }
  167. private void DrawFoup()
  168. {
  169. double CanvasTop1 = -7;
  170. double CanvasTop2 = 0;
  171. double CanvasTop3 = -2;
  172. int ZIndex = 98;
  173. foreach (WaferInfo item in UnitData2)
  174. {
  175. Console.WriteLine(item);
  176. //text
  177. TextBlock SlotIndex = new TextBlock()
  178. {
  179. Background = new SolidColorBrush(Colors.Black),
  180. FontSize = 10,
  181. Width = 10,
  182. Foreground = new SolidColorBrush(Colors.White),
  183. TextWrapping = TextWrapping.Wrap,
  184. HorizontalAlignment = HorizontalAlignment.Center,
  185. TextAlignment = TextAlignment.Center,
  186. Padding = new Thickness(5),
  187. LineHeight = 5
  188. };
  189. SlotIndex.Text = item.SlotIndex + "";
  190. Canvas.SetLeft(SlotIndex, -50);
  191. Canvas.SetTop(SlotIndex, CanvasTop3);
  192. CanvasTop3 = CanvasTop3 + 5;
  193. Canvas.SetZIndex(SlotIndex, 98);//显示层级
  194. //Fuop
  195. string ImagePath1 = "F:\\Venus\\Venus\\Venus\\Venus_Themes\\Themes\\Images\\parts\\vce\\Foup1.png";
  196. Image VceControl = CreateImage(ImagePath1, 49);
  197. Canvas canvas1 = new Canvas();
  198. CanvasTop1 = CanvasTop1 + 7;
  199. canvas1.Children.Add(VceControl);
  200. Canvas.SetZIndex(canvas1, ZIndex--);//显示层级
  201. Canvas.SetLeft(canvas1, -25);
  202. Canvas.SetTop(canvas1, CanvasTop1);
  203. canvas1.Opacity = 0.7;
  204. vceFoupAndWafer.Children.Add(canvas1);
  205. //Boder
  206. Border border = new Border()
  207. {
  208. Width = 7.5,
  209. Height = 7.5,
  210. BorderThickness = new Thickness(1),
  211. BorderBrush = new SolidColorBrush(Colors.Blue),
  212. Background = new SolidColorBrush(Colors.White),
  213. HorizontalAlignment = HorizontalAlignment.Center,
  214. VerticalAlignment = VerticalAlignment.Center
  215. };
  216. Canvas.SetZIndex(border, ZIndex--);//显示层级
  217. Canvas.SetLeft(border, -25);
  218. Canvas.SetTop(border, CanvasTop3);
  219. CanvasTop3 = CanvasTop3 + 7.5;
  220. //Wafer
  221. string ImagePath2 = "F:\\Venus\\Venus\\Venus\\Venus_Themes\\Themes\\Images\\parts\\vce\\Wafer.png";
  222. VceWaferNames[item.SlotID] = (CreateImage(ImagePath2, 40));
  223. Canvas.SetTop(VceWaferNames[item.SlotID], CanvasTop2);
  224. CanvasTop2 = CanvasTop1+5;
  225. Canvas.SetZIndex(VceWaferNames[item.SlotID], ZIndex + 2);//显示层级
  226. Canvas.SetLeft(VceWaferNames[item.SlotID], -7);
  227. if (item.WaferStatus > 0 )
  228. {
  229. vceFoupAndWafer.Children.Add(VceWaferNames[item.SlotID]);
  230. }
  231. else
  232. {
  233. vceFoupAndWafer.Children.Remove(VceWaferNames[item.SlotID]);
  234. }
  235. }
  236. //FoupCover
  237. string ImagePath3 = "F:\\Venus\\Venus\\Venus\\Venus_Themes\\Themes\\Images\\parts\\vce\\Foup2.png";
  238. System.Windows.Controls.Image FoupCover = CreateImage(ImagePath3, 49);
  239. Canvas canvas2 = new Canvas();
  240. canvas2.Children.Add(FoupCover);
  241. Canvas.SetZIndex(canvas2, 99);//显示层级
  242. Canvas.SetLeft(canvas2, -25);
  243. Canvas.SetTop(canvas2, -17);
  244. canvas2.Opacity = .5;
  245. vceFoupAndWafer.Children.Add(canvas2);
  246. }
  247. }
  248. }