Door.xaml.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Aitex.Sorter.Common;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Media;
  5. namespace Aitex.Sorter.UI.Controls
  6. {
  7. /// <summary>
  8. /// Door.xaml 的交互逻辑
  9. /// </summary>
  10. public partial class Door : UserControl
  11. {
  12. public Door()
  13. {
  14. InitializeComponent();
  15. }
  16. public FoupDoorState State
  17. {
  18. get { return (FoupDoorState)GetValue(StateProperty); }
  19. set { SetValue(StateProperty, value); }
  20. }
  21. // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc...
  22. public static readonly DependencyProperty StateProperty =
  23. DependencyProperty.Register("State", typeof(FoupDoorState), typeof(Door), new FrameworkPropertyMetadata(FoupDoorState.Unknown, FrameworkPropertyMetadataOptions.AffectsRender));
  24. protected override void OnRender(DrawingContext drawingContext)
  25. {
  26. base.OnRender(drawingContext);
  27. switch (State)
  28. {
  29. case FoupDoorState.Open:
  30. border.BorderThickness = new Thickness(0);
  31. image.Visibility = Visibility.Hidden;
  32. break;
  33. case FoupDoorState.Close:
  34. image.Visibility = Visibility.Visible;
  35. border.BorderThickness = new Thickness(0);
  36. break;
  37. case FoupDoorState.Unknown:
  38. image.Visibility = Visibility.Visible;
  39. border.BorderThickness = new Thickness(2);
  40. break;
  41. default:
  42. break;
  43. }
  44. }
  45. }
  46. }