LoadPort.xaml.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using Aitex.Sorter.Common;
  2. using MECF.Framework.Common.Equipment;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.Linq;
  7. using System.Text;
  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. namespace VirgoUI.Controls.Parts
  19. {
  20. /// <summary>
  21. /// LoadPort.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class LoadPort : UserControl
  24. {
  25. public string Label
  26. {
  27. get { return (string)GetValue(LabelProperty); }
  28. set { SetValue(LabelProperty, value); }
  29. }
  30. // Using a DependencyProperty as the backing store for Label. This enables animation, styling, binding, etc...
  31. public static readonly DependencyProperty LabelProperty =
  32. DependencyProperty.Register("Label", typeof(string), typeof(LoadPort), new PropertyMetadata(null));
  33. public ICommand Command
  34. {
  35. get { return (ICommand)GetValue(CommandProperty); }
  36. set { SetValue(CommandProperty, value); }
  37. }
  38. // Using a DependencyProperty as the backing store for Command. This enables animation, styling, binding, etc...
  39. public static readonly DependencyProperty CommandProperty =
  40. DependencyProperty.Register("Command", typeof(ICommand), typeof(LoadPort), new PropertyMetadata(null));
  41. public LoadportCassetteState CassetteState
  42. {
  43. get { return (LoadportCassetteState)GetValue(CassetteStateProperty); }
  44. set { SetValue(CassetteStateProperty, value); }
  45. }
  46. // Using a DependencyProperty as the backing store for Present. This enables animation, styling, binding, etc...
  47. public static readonly DependencyProperty CassetteStateProperty =
  48. DependencyProperty.Register("CassetteState", typeof(LoadportCassetteState), typeof(LoadPort), new FrameworkPropertyMetadata(LoadportCassetteState.Unknown));
  49. public FoupDoorState DoorState
  50. {
  51. get { return (FoupDoorState)GetValue(DoorStateProperty); }
  52. set { SetValue(DoorStateProperty, value); }
  53. }
  54. // Using a DependencyProperty as the backing store for Open. This enables animation, styling, binding, etc...
  55. public static readonly DependencyProperty DoorStateProperty =
  56. DependencyProperty.Register("DoorState", typeof(FoupDoorState), typeof(LoadPort), new FrameworkPropertyMetadata(FoupDoorState.Unknown, FrameworkPropertyMetadataOptions.AffectsRender));
  57. public ModuleName Station
  58. {
  59. get { return (ModuleName)GetValue(StationProperty); }
  60. set { SetValue(StationProperty, value); }
  61. }
  62. // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc...
  63. public static readonly DependencyProperty StationProperty =
  64. DependencyProperty.Register("Station", typeof(ModuleName), typeof(LoadPort), new PropertyMetadata(ModuleName.System));
  65. public int RotateAngel
  66. {
  67. get { return (int)GetValue(RotateAngelProperty); }
  68. set { SetValue(RotateAngelProperty, value); }
  69. }
  70. // Using a DependencyProperty as the backing store for RotateAngel. This enables animation, styling, binding, etc...
  71. public static readonly DependencyProperty RotateAngelProperty =
  72. DependencyProperty.Register("RotateAngel", typeof(int), typeof(LoadPort), new PropertyMetadata(0));
  73. public LoadPort()
  74. {
  75. InitializeComponent();
  76. root.DataContext = this;
  77. }
  78. private void MenuItem_Click(object sender, RoutedEventArgs e)
  79. {
  80. var cmd = ((MenuItem)sender).Tag;
  81. Command.Execute(new[] { Station.ToString(), cmd });
  82. }
  83. protected override void OnRender(DrawingContext drawingContext)
  84. {
  85. base.OnRender(drawingContext);
  86. if (DoorState == FoupDoorState.Open)
  87. {
  88. cassette.VerticalAlignment = VerticalAlignment.Top;
  89. }
  90. else if (DoorState == FoupDoorState.Close)
  91. {
  92. cassette.VerticalAlignment = VerticalAlignment.Bottom;
  93. }
  94. }
  95. }
  96. public class LoadportCassetteStateConverter : IValueConverter
  97. {
  98. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  99. {
  100. var state = (LoadportCassetteState)value;
  101. return state == LoadportCassetteState.Normal ? Visibility.Visible : Visibility.Hidden;
  102. }
  103. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  104. {
  105. throw new NotImplementedException();
  106. }
  107. }
  108. public class FoupDoorStateConverter : IValueConverter
  109. {
  110. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  111. {
  112. var state = (FoupDoorState)value;
  113. return state == FoupDoorState.Open ? Visibility.Visible : Visibility.Hidden;
  114. }
  115. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  116. {
  117. throw new NotImplementedException();
  118. }
  119. }
  120. }