AITPressureMeter.xaml.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. /// AITPressureMeter.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class AITPressureMeter : UserControl
  21. {
  22. public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
  23. "DeviceData", typeof(AITPressureMeterData), typeof(AITPressureMeter),
  24. new FrameworkPropertyMetadata(new AITPressureMeterData(), FrameworkPropertyMetadataOptions.AffectsRender));
  25. public AITPressureMeterData DeviceData
  26. {
  27. get
  28. {
  29. return (AITPressureMeterData)this.GetValue(DeviceDataProperty);
  30. }
  31. set
  32. {
  33. this.SetValue(DeviceDataProperty, value);
  34. }
  35. }
  36. public static readonly DependencyProperty FontSizeSettingProperty = DependencyProperty.Register(
  37. "FontSizeSetting", typeof(int), typeof(AITPressureMeter),
  38. new FrameworkPropertyMetadata(13, FrameworkPropertyMetadataOptions.AffectsRender));
  39. public int FontSizeSetting
  40. {
  41. get
  42. {
  43. return (int)this.GetValue(FontSizeSettingProperty);
  44. }
  45. set
  46. {
  47. this.SetValue(FontSizeSettingProperty, value);
  48. }
  49. }
  50. public static readonly DependencyProperty ForegroundSettingProperty = DependencyProperty.Register(
  51. "ForegroundSetting", typeof(string), typeof(AITPressureMeter),
  52. new FrameworkPropertyMetadata("Yellow", FrameworkPropertyMetadataOptions.AffectsRender));
  53. public string ForegroundSetting
  54. {
  55. get
  56. {
  57. return (string)this.GetValue(ForegroundSettingProperty);
  58. }
  59. set
  60. {
  61. this.SetValue(ForegroundSettingProperty, value);
  62. }
  63. }
  64. public AITPressureMeter()
  65. {
  66. InitializeComponent();
  67. }
  68. private void Grid_MouseEnter(object sender, MouseEventArgs e)
  69. {
  70. if (DeviceData != null)
  71. {
  72. string tooltipValue =
  73. string.Format("{0}:{1}\r\nID:{2}\r\n{3} {4}",
  74. DeviceData.Type,
  75. DeviceData.DisplayName,
  76. DeviceData.DeviceSchematicId,
  77. !string.IsNullOrEmpty(DeviceData.FormatString) ? DeviceData.FeedBack.ToString(DeviceData.FormatString) : DeviceData.FeedBack.ToString("F1"),
  78. DeviceData.Unit);
  79. ToolTip = tooltipValue;
  80. }
  81. }
  82. }
  83. }