LoadPort.xaml.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using System;
  2. using System.Globalization;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Data;
  6. using System.Windows.Input;
  7. using System.Windows.Media;
  8. using Aitex.Sorter.Common;
  9. using MECF.Framework.Common.Equipment;
  10. namespace Aitex.Sorter.UI.Controls
  11. {
  12. /// <summary>
  13. /// LoadPort.xaml 的交互逻辑
  14. /// </summary>
  15. public partial class LoadPort : UserControl
  16. {
  17. public string Label
  18. {
  19. get { return (string)GetValue(LabelProperty); }
  20. set { SetValue(LabelProperty, value); }
  21. }
  22. // Using a DependencyProperty as the backing store for Label. This enables animation, styling, binding, etc...
  23. public static readonly DependencyProperty LabelProperty =
  24. DependencyProperty.Register("Label", typeof(string), typeof(LoadPort), new PropertyMetadata(null));
  25. public ICommand Command
  26. {
  27. get { return (ICommand)GetValue(CommandProperty); }
  28. set { SetValue(CommandProperty, value); }
  29. }
  30. // Using a DependencyProperty as the backing store for Command. This enables animation, styling, binding, etc...
  31. public static readonly DependencyProperty CommandProperty =
  32. DependencyProperty.Register("Command", typeof(ICommand), typeof(LoadPort), new PropertyMetadata(null));
  33. public LoadportCassetteState CassetteState
  34. {
  35. get { return (LoadportCassetteState)GetValue(CassetteStateProperty); }
  36. set { SetValue(CassetteStateProperty, value); }
  37. }
  38. // Using a DependencyProperty as the backing store for Present. This enables animation, styling, binding, etc...
  39. public static readonly DependencyProperty CassetteStateProperty =
  40. DependencyProperty.Register("CassetteState", typeof(LoadportCassetteState), typeof(LoadPort), new FrameworkPropertyMetadata(LoadportCassetteState.Unknown));
  41. public FoupDoorState DoorState
  42. {
  43. get { return (FoupDoorState)GetValue(DoorStateProperty); }
  44. set { SetValue(DoorStateProperty, value); }
  45. }
  46. // Using a DependencyProperty as the backing store for Open. This enables animation, styling, binding, etc...
  47. public static readonly DependencyProperty DoorStateProperty =
  48. DependencyProperty.Register("DoorState", typeof(FoupDoorState), typeof(LoadPort), new FrameworkPropertyMetadata(FoupDoorState.Unknown, FrameworkPropertyMetadataOptions.AffectsRender));
  49. public bool IsDockState
  50. {
  51. get { return (bool)GetValue(IsDockStateProperty); }
  52. set { SetValue(IsDockStateProperty, value); }
  53. }
  54. // Using a DependencyProperty as the backing store for IsDockState. This enables animation, styling, binding, etc...
  55. public static readonly DependencyProperty IsDockStateProperty =
  56. DependencyProperty.Register("IsDockState", typeof(bool), typeof(LoadPort), new FrameworkPropertyMetadata(false, 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. if (IsDockState)
  95. {
  96. cassette.VerticalAlignment = VerticalAlignment.Top;
  97. }
  98. else
  99. {
  100. cassette.VerticalAlignment = VerticalAlignment.Bottom;
  101. }
  102. }
  103. }
  104. public class LoadportCassetteStateConverter : IValueConverter
  105. {
  106. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  107. {
  108. var state = (LoadportCassetteState)value;
  109. return state == LoadportCassetteState.Normal ? Visibility.Visible : Visibility.Hidden;
  110. }
  111. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  112. {
  113. throw new NotImplementedException();
  114. }
  115. }
  116. public class FoupDoorStateConverter : IValueConverter
  117. {
  118. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  119. {
  120. var state = (FoupDoorState)value;
  121. return state == FoupDoorState.Open ? Visibility.Visible : Visibility.Hidden;
  122. }
  123. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  124. {
  125. throw new NotImplementedException();
  126. }
  127. }
  128. }