PcControl.xaml.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. namespace Aitex.Core.UI.Control
  15. {
  16. /// <summary>
  17. /// PcControl.xaml 的交互逻辑
  18. /// </summary>
  19. public partial class PcControl : UserControl
  20. {
  21. public PcControl()
  22. {
  23. InitializeComponent();
  24. }
  25. /// <summary>
  26. /// define dependency property
  27. /// </summary>
  28. public static readonly DependencyProperty ActualValueProperty = DependencyProperty.Register(
  29. "DeviceData", typeof(object), typeof(PcControl),
  30. new FrameworkPropertyMetadata(50.0, FrameworkPropertyMetadataOptions.AffectsRender));
  31. public static readonly DependencyProperty SetPointProperty = DependencyProperty.Register(
  32. "SetPoint", typeof(double), typeof(PcControl),
  33. new FrameworkPropertyMetadata(60.0, FrameworkPropertyMetadataOptions.AffectsRender));
  34. public static readonly DependencyProperty DisplayAngleProperty = DependencyProperty.Register(
  35. "DisplayAngle", typeof(int), typeof(PcControl),
  36. new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  37. /// <summary>
  38. /// set, get current progress value
  39. /// </summary>
  40. public double SetPoint
  41. {
  42. get
  43. {
  44. return (double)this.GetValue(SetPointProperty);
  45. }
  46. set
  47. {
  48. this.SetValue(SetPointProperty, value);
  49. }
  50. }
  51. /// <summary>
  52. /// set, get current progress value AnalogDeviceData
  53. /// </summary>
  54. public object ActualValue
  55. {
  56. get
  57. {
  58. return this.GetValue(ActualValueProperty);
  59. }
  60. set
  61. {
  62. this
  63. .SetValue(ActualValueProperty, value);
  64. }
  65. } /// <summary>
  66. /// display angle
  67. /// </summary>
  68. public int DisplayAngle
  69. {
  70. get
  71. {
  72. return (int)GetValue(DisplayAngleProperty);
  73. }
  74. set
  75. {
  76. SetValue(DisplayAngleProperty, value);
  77. }
  78. }
  79. /// <summary>
  80. /// override rendering behavior
  81. /// </summary>
  82. /// <param name="drawingContext"></param>
  83. protected override void OnRender(DrawingContext drawingContext)
  84. {
  85. base.OnRender(drawingContext);
  86. this.rotateTransform.Angle = DisplayAngle;
  87. try
  88. {
  89. labelValue.Content=ActualValue;
  90. }
  91. catch (Exception ex)
  92. {
  93. //LOG.Write(ex);
  94. throw ex;
  95. }
  96. }
  97. private void Canvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  98. {
  99. }
  100. }
  101. }