using Aitex.Sorter.Common; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace Aitex.Sorter.UI.Controls { /// /// Door.xaml 的交互逻辑 /// public partial class Door : UserControl { public Door() { InitializeComponent(); } public FoupDoorState State { get { return (FoupDoorState)GetValue(StateProperty); } set { SetValue(StateProperty, value); } } // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc... public static readonly DependencyProperty StateProperty = DependencyProperty.Register("State", typeof(FoupDoorState), typeof(Door), new FrameworkPropertyMetadata(FoupDoorState.Unknown, FrameworkPropertyMetadataOptions.AffectsRender)); protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); switch (State) { case FoupDoorState.Open: border.BorderThickness = new Thickness(0); image.Visibility = Visibility.Hidden; break; case FoupDoorState.Close: image.Visibility = Visibility.Visible; border.BorderThickness = new Thickness(0); break; case FoupDoorState.Unknown: image.Visibility = Visibility.Visible; border.BorderThickness = new Thickness(2); break; default: break; } } } }