ThrottleValveControl.xaml.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /// Interaction logic for ThrottleValveControl.xaml
  18. /// </summary>
  19. public partial class ThrottleValveControl : UserControl
  20. {
  21. public ThrottleValveControl()
  22. {
  23. InitializeComponent();
  24. }
  25. /// <summary>
  26. /// define dependency property
  27. /// </summary>
  28. public static readonly DependencyProperty ActualValueProperty = DependencyProperty.Register(
  29. "ActualValue", typeof(double), typeof(ThrottleValveControl),
  30. new FrameworkPropertyMetadata(50.0, FrameworkPropertyMetadataOptions.AffectsRender));
  31. public static readonly DependencyProperty DisplayAngleProperty = DependencyProperty.Register(
  32. "DisplayAngle", typeof(int), typeof(ThrottleValveControl),
  33. new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  34. /// <summary>
  35. /// set, get current progress value
  36. /// </summary>
  37. public double ActualValue
  38. {
  39. get
  40. {
  41. return (double)this.GetValue(ActualValueProperty);
  42. }
  43. set
  44. {
  45. this.SetValue(ActualValueProperty, value);
  46. }
  47. }
  48. /// <summary>
  49. /// display angle
  50. /// </summary>
  51. public int DisplayAngle
  52. {
  53. get
  54. {
  55. return (int)GetValue(DisplayAngleProperty);
  56. }
  57. set
  58. {
  59. SetValue(DisplayAngleProperty, value);
  60. }
  61. }
  62. /// <summary>
  63. ///
  64. /// </summary>
  65. /// <param name="drawingContext"></param>
  66. protected override void OnRender(DrawingContext drawingContext)
  67. {
  68. base.OnRender(drawingContext);
  69. this.rotateTransform.Angle = DisplayAngle;
  70. }
  71. }
  72. }