Arrow.xaml.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 Arrow.xaml111
  18. /// </summary>
  19. public partial class Arrow : UserControl
  20. {
  21. public Arrow()
  22. {
  23. InitializeComponent();
  24. }
  25. public static readonly DependencyProperty GasOnOffProperty = DependencyProperty.Register(
  26. "GasOnOff", typeof(bool), typeof(Arrow),
  27. new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
  28. public static readonly DependencyProperty GasColorProperty = DependencyProperty.Register(
  29. "GasColor", typeof(Brush), typeof(Arrow),
  30. new FrameworkPropertyMetadata(Brushes.Black, FrameworkPropertyMetadataOptions.AffectsRender));
  31. public static readonly DependencyProperty DisplayAngleProperty = DependencyProperty.Register(
  32. "DisplayAngle", typeof(int), typeof(Arrow),
  33. new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
  34. /// <summary>
  35. /// display angle
  36. /// </summary>
  37. public int DisplayAngle
  38. {
  39. get
  40. {
  41. return (int)GetValue(DisplayAngleProperty);
  42. }
  43. set
  44. {
  45. SetValue(DisplayAngleProperty, value);
  46. }
  47. }
  48. /// <summary>
  49. /// pipe gas on/off state
  50. /// </summary>
  51. public bool GasOnOff
  52. {
  53. get
  54. {
  55. return (bool)this.GetValue(GasOnOffProperty);
  56. }
  57. set
  58. {
  59. this.SetValue(GasOnOffProperty, value);
  60. }
  61. }
  62. /// <summary>
  63. /// pipe gas on color
  64. /// </summary>
  65. public Brush GasColor
  66. {
  67. get
  68. {
  69. return (Brush)this.GetValue(GasColorProperty);
  70. }
  71. set
  72. {
  73. this.SetValue(GasColorProperty, value);
  74. }
  75. }
  76. /// <summary>
  77. /// override rendering method
  78. /// </summary>
  79. /// <param name="drawingContext"></param>
  80. protected override void OnRender(DrawingContext drawingContext)
  81. {
  82. base.OnRender(drawingContext);
  83. this.Opacity = GasOnOff ? 1 : 0.5;
  84. this.arrow1.Fill = GasColor;
  85. this.rotateTransform.Angle = DisplayAngle;
  86. }
  87. }
  88. }