PC.xaml.cs 3.2 KB

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