RFSimpleControl.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Aitex.Core.Common.DeviceData;
  2. using System;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Media;
  6. using System.Windows.Media.Imaging;
  7. namespace MECF.Framework.UI.Client.Ctrlib.UnitControls
  8. {
  9. /// <summary>
  10. /// RFSimpleControl.xaml 的交互逻辑
  11. /// </summary>
  12. public partial class RFSimpleControl : UserControl
  13. {
  14. public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
  15. "DeviceData", typeof(AITRfData), typeof(RFSimpleControl),
  16. new FrameworkPropertyMetadata(new AITRfData(), FrameworkPropertyMetadataOptions.AffectsRender));
  17. public AITRfData DeviceData
  18. {
  19. get
  20. {
  21. return (AITRfData)this.GetValue(DeviceDataProperty);
  22. }
  23. set
  24. {
  25. this.SetValue(DeviceDataProperty, value);
  26. }
  27. }
  28. public RFSimpleControl()
  29. {
  30. InitializeComponent();
  31. }
  32. protected override void OnRender(DrawingContext drawingContext)
  33. {
  34. base.OnRender(drawingContext);
  35. if (DeviceData == null)
  36. return;
  37. if (DeviceData.IsRfOn)
  38. imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.UI.Client;component/Resources/Images/units/rfOn.png"));
  39. else
  40. imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.UI.Client;component/Resources/Images/units/rfOff.png"));
  41. }
  42. }
  43. }