Bath.xaml.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using System.ComponentModel;
  15. using Aitex.Core.Util;
  16. using Aitex.Core.UI.ControlDataContext;
  17. namespace Aitex.Core.UI.Control
  18. {
  19. /// <summary>
  20. /// Interaction logic for Bath.xaml
  21. /// </summary>
  22. public partial class Bath : UserControl
  23. {
  24. public Bath()
  25. {
  26. InitializeComponent();
  27. }
  28. //BathDataItem MoLineData { get { return (this.DataContext as MOSourceDataItem).BathData; } }
  29. public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
  30. "DeviceData", typeof(BathDataItem), typeof(Bath),
  31. new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  32. public BathDataItem DeviceData
  33. {
  34. get
  35. {
  36. return (BathDataItem)this.GetValue(DeviceDataProperty);
  37. }
  38. set
  39. {
  40. this.SetValue(DeviceDataProperty, value);
  41. }
  42. }
  43. protected override void OnRender(DrawingContext drawingContext)
  44. {
  45. if (DeviceData == null) return;
  46. lblBathTemperature.Content = DeviceData.TemperatureReading + "℃";
  47. if (DeviceData.IsCommErr || DeviceData.IsLevelWarning || DeviceData.IsOutofTempRange || DeviceData.IsCutoffAlarm)
  48. {
  49. if (cavBath.Background != Brushes.Red)
  50. cavBath.Background = Brushes.Red;
  51. }
  52. else
  53. {
  54. if (cavBath.Background != Brushes.SkyBlue)
  55. cavBath.Background = Brushes.SkyBlue;
  56. }
  57. }
  58. private void OnMouseEnter(object sender, MouseEventArgs e)
  59. {
  60. if (DeviceData == null) return;
  61. string tooltipStr = string.Format("{0}\n\n通信状态:{1}\n水位状态:{2}\n温度监测:{3}\n水槽温度:{4} ℃\n水槽切断:{5}",
  62. DeviceData.BathName,
  63. DeviceData.IsCommErr ? "异常" : "正常",
  64. DeviceData.IsLevelWarning ? "异常" : "正常",
  65. DeviceData.IsOutofTempRange ? "异常" : "正常",
  66. DeviceData.TemperatureReading.ToString("F1"),
  67. DeviceData.IsCutoffAlarm ? "异常" : "正常");
  68. this.ToolTip = tooltipStr;
  69. }
  70. }
  71. }