Slot.xaml.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Aitex.Sorter.Common;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Media;
  5. using MECF.Framework.Common.Equipment;
  6. namespace Aitex.Sorter.UI.Controls
  7. {
  8. /// <summary>
  9. /// Slot.xaml 的交互逻辑
  10. /// </summary>
  11. public partial class Slot : UserControl
  12. {
  13. public Slot()
  14. {
  15. InitializeComponent();
  16. }
  17. public SlotTransferInfo TransferInfo
  18. {
  19. get { return (SlotTransferInfo)GetValue(TransferInfoProperty); }
  20. set { SetValue(TransferInfoProperty, value); }
  21. }
  22. // Using a DependencyProperty as the backing store for TransferInfo. This enables animation, styling, binding, etc...
  23. public static readonly DependencyProperty TransferInfoProperty =
  24. DependencyProperty.Register("TransferInfo", typeof(SlotTransferInfo), typeof(Slot), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  25. protected override void OnRender(DrawingContext drawingContext)
  26. {
  27. base.OnRender(drawingContext);
  28. var blue = (SolidColorBrush)Application.Current.TryFindResource("blueSlot");
  29. var green = (LinearGradientBrush)Application.Current.TryFindResource("greenSlot");
  30. var lightBlue = (LinearGradientBrush)Application.Current.TryFindResource("lightBlueSlot");
  31. if (TransferInfo != null)
  32. {
  33. if (TransferInfo.SourceStation == ModuleName.System)
  34. {
  35. if (TransferInfo.DestinationStation != ModuleName.System)
  36. {
  37. left.Fill = green;
  38. tipLeft.Content = string.Format("To {0} slot {1}", TransferInfo.DestinationStation, TransferInfo.DestinationSlot);
  39. }
  40. }
  41. if (TransferInfo.DestinationStation == ModuleName.System)
  42. {
  43. if (TransferInfo.SourceStation != ModuleName.System)
  44. {
  45. right.Fill = lightBlue;
  46. tipRight.Content = string.Format("From {0} slot {1}", TransferInfo.SourceStation, TransferInfo.SourceSlot);
  47. }
  48. }
  49. }
  50. else
  51. {
  52. tipLeft.Content = tipRight.Content = null;
  53. left.Fill = blue;
  54. right.Fill = blue;
  55. }
  56. }
  57. }
  58. }