Door.xaml.cs 1.3 KB

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