AITFlowMeter.xaml.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 Aitex.Core.Common.DeviceData;
  15. namespace Aitex.Core.UI.DeviceControl
  16. {
  17. /// <summary>
  18. /// AITFlowMeter.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class AITFlowMeter : UserControl
  21. {
  22. public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
  23. "DeviceData", typeof(AITWaterFlowMeterData), typeof(AITFlowMeter),
  24. new FrameworkPropertyMetadata(new AITWaterFlowMeterData(), FrameworkPropertyMetadataOptions.AffectsRender));
  25. public AITWaterFlowMeterData DeviceData
  26. {
  27. get
  28. {
  29. return (AITWaterFlowMeterData)this.GetValue(DeviceDataProperty);
  30. }
  31. set
  32. {
  33. this.SetValue(DeviceDataProperty, value);
  34. }
  35. }
  36. public static readonly DependencyProperty StringFormatProperty = DependencyProperty.Register(
  37. "StringFormat", typeof(string), typeof(AITFlowMeter),
  38. new FrameworkPropertyMetadata("F1", FrameworkPropertyMetadataOptions.AffectsRender));
  39. public string StringFormat
  40. {
  41. get
  42. {
  43. return (string)this.GetValue(StringFormatProperty);
  44. }
  45. set
  46. {
  47. this.SetValue(StringFormatProperty, value);
  48. }
  49. }
  50. public AITFlowMeter()
  51. {
  52. InitializeComponent();
  53. }
  54. private void Grid_MouseEnter(object sender, MouseEventArgs e)
  55. {
  56. if (DeviceData != null)
  57. {
  58. string tooltipValue =
  59. string.Format(Application.Current.Resources["GlobalLableFlowMeterToolTip"].ToString(),
  60. DeviceData.Type,
  61. DeviceData.DisplayName,
  62. DeviceData.DeviceSchematicId,
  63. DeviceData.FeedBack.ToString(StringFormat),
  64. DeviceData.Unit);
  65. ToolTip = tooltipValue;
  66. }
  67. }
  68. }
  69. }