VceControl.xaml.cs 11 KB

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