VceControl.xaml.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. if (UnitData2 != null)
  91. {
  92. DrawFoup();
  93. }
  94. }
  95. //支撑底柱高度
  96. public static readonly DependencyProperty PositionZProperty = DependencyProperty.Register(
  97. "PositionZ", typeof(double), typeof(VceControl));
  98. public double PositionZ
  99. {
  100. get { return (double)GetValue(PositionZProperty); }
  101. set
  102. {
  103. SetValue(PositionZProperty, value);
  104. }
  105. }
  106. //是否开门
  107. public static readonly DependencyProperty VceDoorIsOpenProperty = DependencyProperty.Register(
  108. "VceDoorIsOpen", typeof(bool), typeof(VceControl));
  109. public bool VceDoorIsOpen
  110. {
  111. get { return (bool)this.GetValue(VceDoorIsOpenProperty); }
  112. set { SetValue(VceDoorIsOpenProperty, value); }
  113. }
  114. //槽口位置
  115. public int CurrentSlot
  116. {
  117. get { return (int)GetValue(CurrentSlotProperty); }
  118. set { SetValue(CurrentSlotProperty, value); }
  119. }
  120. public static readonly DependencyProperty CurrentSlotProperty =
  121. DependencyProperty.Register("CurrentSlot", typeof(int), typeof(VceControl), new PropertyMetadata(SelectWafer));
  122. //通过监听Slot值的变化改变wafer样式与Foup移动
  123. private static Image[] VceWaferNames = new Image[25];
  124. public static void SelectWafer(DependencyObject d, DependencyPropertyChangedEventArgs e)
  125. {
  126. if (d is VceControl vceControl)
  127. {
  128. //if (Convert.ToInt32(e.NewValue) >= 0 && Convert.ToInt32(e.OldValue) >= 0)
  129. //{
  130. // VceWaferNames[(int)e.NewValue].Source = new BitmapImage(new Uri(@"pack://application:,,,/Venus_Themes;component/Themes/Images/parts/vce/WaferSelected.png", UriKind.RelativeOrAbsolute));
  131. // VceWaferNames[(int)e.OldValue].Source = new BitmapImage(new Uri(@"pack://application:,,,/Venus_Themes;component/Themes/Images/parts/vce/Wafer.png", UriKind.RelativeOrAbsolute));
  132. // DoubleAnimation floatY = new DoubleAnimation(
  133. // 430 - 7 * (25 - (int)e.NewValue),
  134. // TimeSpan.FromSeconds(3)
  135. // );
  136. // vceControl.Foup.BeginAnimation(Canvas.TopProperty, floatY);
  137. //}
  138. //else if (Convert.ToInt32(e.NewValue) >= 0 && Convert.ToInt32(e.OldValue) < 0)
  139. //{
  140. // VceWaferNames[(int)e.NewValue].Source = new BitmapImage(new Uri(@"pack://application:,,,/Venus_Themes;component/Themes/Images/parts/vce/WaferSelected.png", UriKind.RelativeOrAbsolute));
  141. // DoubleAnimation floatY = new DoubleAnimation(
  142. // 430 - 7 * (25 - (int)e.NewValue),
  143. // TimeSpan.FromSeconds(3)
  144. // );
  145. // vceControl.Foup.BeginAnimation(Canvas.TopProperty, floatY);
  146. //}
  147. //else if (Convert.ToInt32(e.NewValue) < 0 && Convert.ToInt32(e.OldValue) > 0)
  148. //{
  149. // VceWaferNames[(int)e.OldValue].Source = new BitmapImage(new Uri(@"pack://application:,,,/Venus_Themes;component/Themes/Images/parts/vce/Wafer.png", UriKind.RelativeOrAbsolute));
  150. // DoubleAnimation floatY = new DoubleAnimation(
  151. // 430,
  152. // TimeSpan.FromSeconds(3)
  153. // );
  154. // vceControl.Foup.BeginAnimation(Canvas.TopProperty, floatY);
  155. //}
  156. }
  157. }
  158. private Image CreateImage(string ImagePath, int ImageHeight)
  159. {
  160. Image VceImage = new Image();
  161. VceImage.Height = ImageHeight;
  162. //BitmapImage myBitmapImage = new BitmapImage();
  163. //myBitmapImage.BeginInit();
  164. //myBitmapImage.BaseUri = new Uri(ImagePath);
  165. //myBitmapImage.DecodePixelHeight = ImageHeight;
  166. //myBitmapImage.EndInit();
  167. //set image source
  168. VceImage.Source = new BitmapImage(new Uri(ImagePath)); ;
  169. return VceImage;
  170. }
  171. private void DrawFoup()
  172. {
  173. double CanvasTop1 = -7;
  174. double CanvasTop2 = 0;
  175. double CanvasTop3 = -2;
  176. int ZIndex = 98;
  177. foreach (WaferInfo item in UnitData2)
  178. {
  179. //Console.WriteLine(item);
  180. //text
  181. TextBlock SlotIndex = new TextBlock()
  182. {
  183. Background = new SolidColorBrush(Colors.Black),
  184. FontSize = 10,
  185. Width = 10,
  186. Foreground = new SolidColorBrush(Colors.White),
  187. TextWrapping = TextWrapping.Wrap,
  188. HorizontalAlignment = HorizontalAlignment.Center,
  189. TextAlignment = TextAlignment.Center,
  190. Padding = new Thickness(5),
  191. LineHeight = 5
  192. };
  193. SlotIndex.Text = item.SlotIndex + "";
  194. Canvas.SetLeft(SlotIndex, -50);
  195. Canvas.SetTop(SlotIndex, CanvasTop3);
  196. CanvasTop3 = CanvasTop3 + 5;
  197. Canvas.SetZIndex(SlotIndex, 98);//显示层级
  198. //Fuop pack://application:,,,/
  199. string ImagePath1 = "pack://application:,,,/Venus_Themes;component/Themes/Images/parts/vce/Foup1.png";
  200. Image VceControl = CreateImage(ImagePath1, 49);
  201. Canvas canvas1 = new Canvas();
  202. CanvasTop1 = CanvasTop1 + 7;
  203. canvas1.Children.Add(VceControl);
  204. Canvas.SetZIndex(canvas1, ZIndex--);//显示层级
  205. Canvas.SetLeft(canvas1, -25);
  206. Canvas.SetTop(canvas1, CanvasTop1);
  207. canvas1.Opacity = 0.7;
  208. vceFoupAndWafer.Children.Add(canvas1);
  209. //Boder
  210. Border border = new Border()
  211. {
  212. Width = 7.5,
  213. Height = 7.5,
  214. BorderThickness = new Thickness(1),
  215. BorderBrush = new SolidColorBrush(Colors.Blue),
  216. Background = new SolidColorBrush(Colors.White),
  217. HorizontalAlignment = HorizontalAlignment.Center,
  218. VerticalAlignment = VerticalAlignment.Center
  219. };
  220. Canvas.SetZIndex(border, ZIndex--);//显示层级
  221. Canvas.SetLeft(border, -25);
  222. Canvas.SetTop(border, CanvasTop3);
  223. CanvasTop3 = CanvasTop3 + 7.5;
  224. //Wafer
  225. string ImagePath2 = @"pack://application:,,,/Venus_Themes;component/Themes/Images/parts/vce/Wafer.png";
  226. VceWaferNames[item.SlotID] = (CreateImage(ImagePath2, 40));
  227. Canvas.SetTop(VceWaferNames[item.SlotID], CanvasTop2);
  228. CanvasTop2 = CanvasTop1+5;
  229. Canvas.SetZIndex(VceWaferNames[item.SlotID], ZIndex + 2);//显示层级
  230. Canvas.SetLeft(VceWaferNames[item.SlotID], -7);
  231. if (item.WaferStatus > 0 )
  232. {
  233. vceFoupAndWafer.Children.Add(VceWaferNames[item.SlotID]);
  234. }
  235. else
  236. {
  237. vceFoupAndWafer.Children.Remove(VceWaferNames[item.SlotID]);
  238. }
  239. }
  240. //FoupCover
  241. string ImagePath3 = @"pack://application:,,,/Venus_Themes;component/Themes/Images/parts/vce/Foup2.png";
  242. System.Windows.Controls.Image FoupCover = CreateImage(ImagePath3, 49);
  243. Canvas canvas2 = new Canvas();
  244. canvas2.Children.Add(FoupCover);
  245. Canvas.SetZIndex(canvas2, 99);//显示层级
  246. Canvas.SetLeft(canvas2, -25);
  247. Canvas.SetTop(canvas2, -17);
  248. canvas2.Opacity = .5;
  249. vceFoupAndWafer.Children.Add(canvas2);
  250. }
  251. private string getimageURI(string directoryPath)
  252. {
  253. var startupPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
  254. string dir = System.IO.Path.GetDirectoryName(startupPath);
  255. var ret = System.IO.Path.Combine(dir, directoryPath);
  256. if (!ret.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
  257. ret = ret + System.IO.Path.DirectorySeparatorChar;
  258. if (!Directory.Exists(ret))
  259. Directory.CreateDirectory(ret);
  260. return ret;
  261. }
  262. }
  263. }