TransPorterControl.xaml.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using CyberX8_Core;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. using System.Windows.Threading;
  19. namespace CyberX8_Themes.UserControls
  20. {
  21. /// <summary>
  22. /// TransPorterControl.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class TransPorterControl : UserControl
  25. {
  26. #region 常量
  27. private const int HEIGHT = 93;
  28. private const int WAFER_HOLDER_TOP= 60;
  29. #endregion
  30. public TransPorterControl()
  31. {
  32. InitializeComponent();
  33. }
  34. public static readonly DependencyProperty TransPorterNameProperty = DependencyProperty.Register(
  35. "TransPorterName", typeof(string), typeof(TransPorterControl), new FrameworkPropertyMetadata("Loader TransPorter", FrameworkPropertyMetadataOptions.AffectsRender));
  36. public string TransPorterName
  37. {
  38. get { return this.GetValue(TransPorterNameProperty).ToString(); }
  39. set { this.SetValue(TransPorterNameProperty, value); }
  40. }
  41. public static readonly DependencyProperty WaferHolderVisibleProperty = DependencyProperty.Register(
  42. "WaferHolderVisible", typeof(bool), typeof(TransPorterControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  43. public bool WaferHolderVisible
  44. {
  45. get { return (bool)this.GetValue(WaferHolderVisibleProperty); }
  46. set { this.SetValue(WaferHolderVisibleProperty, value); }
  47. }
  48. public static readonly DependencyProperty VerticalPositionProperty = DependencyProperty.Register("VerticalPosition", typeof(double),
  49. typeof(TransPorterControl), new PropertyMetadata((double)93,new PropertyChangedCallback(VerticalPositionPropertyChanged)));
  50. public double VerticalPosition
  51. {
  52. get { return (double)this.GetValue(VerticalPositionProperty); }
  53. set
  54. {
  55. this.SetValue(VerticalPositionProperty, value);
  56. }
  57. }
  58. public static readonly DependencyProperty LiftHolderPositionProperty = DependencyProperty.Register("LiftHolderPosition", typeof(double), typeof(TransPorterControl), new PropertyMetadata((double)93));
  59. public double LiftHolderPosition
  60. {
  61. get { return (double)this.GetValue(LiftHolderPositionProperty); }
  62. set
  63. {
  64. this.SetValue(LiftHolderPositionProperty, value);
  65. }
  66. }
  67. public static readonly DependencyProperty WaferHolderPositionProperty = DependencyProperty.Register("WaferHolderPosition", typeof(double), typeof(TransPorterControl), new PropertyMetadata((double)93));
  68. public double WaferHolderPosition
  69. {
  70. get { return (double)this.GetValue(WaferHolderPositionProperty); }
  71. set
  72. {
  73. this.SetValue(WaferHolderPositionProperty, value);
  74. }
  75. }
  76. public static readonly DependencyProperty IsLoaderTransporterProperty = DependencyProperty.Register(
  77. "IsLoaderTransporter", typeof(bool), typeof(TransPorterControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  78. public bool IsLoaderTransporter
  79. {
  80. get { return (bool)this.GetValue(IsLoaderTransporterProperty); }
  81. set { this.SetValue(IsLoaderTransporterProperty, value); }
  82. }
  83. public static readonly DependencyProperty IsProcessTransporterProperty = DependencyProperty.Register(
  84. "IsProcessTransporter", typeof(bool), typeof(TransPorterControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  85. public bool IsProcessTransporter
  86. {
  87. get { return (bool)this.GetValue(IsProcessTransporterProperty); }
  88. set { this.SetValue(IsProcessTransporterProperty, value); }
  89. }
  90. public static readonly DependencyProperty IsWHEnableProperty = DependencyProperty.Register(
  91. "IsWHEnable", typeof(bool), typeof(TransPorterControl),
  92. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
  93. /// <summary>
  94. /// 模块名称
  95. /// </summary>
  96. public bool IsWHEnable
  97. {
  98. get
  99. {
  100. return (bool)this.GetValue(IsWHEnableProperty);
  101. }
  102. set
  103. {
  104. this.SetValue(IsWHEnableProperty, value);
  105. }
  106. }
  107. /// <summary>
  108. /// 垂直水平发生变化
  109. /// </summary>
  110. /// <param name="d"></param>
  111. /// <param name="e"></param>
  112. private static void VerticalPositionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  113. {
  114. if(e.NewValue!=null)
  115. {
  116. double newValue = (double)e.NewValue;
  117. d.SetValue(LiftHolderPositionProperty, newValue - HEIGHT);
  118. d.SetValue(WaferHolderPositionProperty, newValue + WAFER_HOLDER_TOP);
  119. }
  120. }
  121. private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  122. {
  123. string name = "";
  124. if("Loader Transporter".Equals(TransPorterName))
  125. {
  126. name = "Transporter2Teach";
  127. }
  128. if ("Process Transporter".Equals(TransPorterName))
  129. {
  130. name = "Transporter1Teach";
  131. }
  132. GlobalEvents.OnSwitchFixedTabItem("HardWare", "Transpoters", $"{name}");
  133. }
  134. }
  135. }