using Aitex.Sorter.Common; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using MECF.Framework.Common.Equipment; namespace Aitex.Sorter.UI.Controls { /// /// Slot.xaml 的交互逻辑 /// public partial class Slot : UserControl { public Slot() { InitializeComponent(); } public SlotTransferInfo TransferInfo { get { return (SlotTransferInfo)GetValue(TransferInfoProperty); } set { SetValue(TransferInfoProperty, value); } } // Using a DependencyProperty as the backing store for TransferInfo. This enables animation, styling, binding, etc... public static readonly DependencyProperty TransferInfoProperty = DependencyProperty.Register("TransferInfo", typeof(SlotTransferInfo), typeof(Slot), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender)); protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); var blue = (SolidColorBrush)Application.Current.TryFindResource("blueSlot"); var green = (LinearGradientBrush)Application.Current.TryFindResource("greenSlot"); var lightBlue = (LinearGradientBrush)Application.Current.TryFindResource("lightBlueSlot"); if (TransferInfo != null) { if (TransferInfo.SourceStation == ModuleName.System) { if (TransferInfo.DestinationStation != ModuleName.System) { left.Fill = green; tipLeft.Content = string.Format("To {0} slot {1}", TransferInfo.DestinationStation, TransferInfo.DestinationSlot); } } if (TransferInfo.DestinationStation == ModuleName.System) { if (TransferInfo.SourceStation != ModuleName.System) { right.Fill = lightBlue; tipRight.Content = string.Format("From {0} slot {1}", TransferInfo.SourceStation, TransferInfo.SourceSlot); } } } else { tipLeft.Content = tipRight.Content = null; left.Fill = blue; right.Fill = blue; } } } }