HandValve.xaml.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 HandValve.xaml
  19. /// </summary>
  20. public partial class HandValve : UserControl
  21. {
  22. public HandValve()
  23. {
  24. InitializeComponent();
  25. }
  26. public static readonly DependencyProperty HandValveDirectionProperty = DependencyProperty.Register(
  27. "HandValveDirection", typeof(ValveDirection), typeof(HandValve),
  28. new FrameworkPropertyMetadata(ValveDirection.ToBottom, FrameworkPropertyMetadataOptions.AffectsRender));
  29. /// <summary>
  30. /// direction of the valve
  31. /// </summary>
  32. public ValveDirection HandValveDirection
  33. {
  34. get
  35. {
  36. return (ValveDirection)GetValue(HandValveDirectionProperty);
  37. }
  38. set
  39. {
  40. SetValue(HandValveDirectionProperty, value);
  41. }
  42. }
  43. protected override void OnRender(DrawingContext drawingContext)
  44. {
  45. try
  46. {
  47. base.OnRender(drawingContext);
  48. switch (HandValveDirection)
  49. {
  50. case ValveDirection.ToBottom:
  51. rotateTransform.Angle = 90;
  52. break;
  53. case ValveDirection.ToTop:
  54. rotateTransform.Angle = -90;
  55. break;
  56. case ValveDirection.ToLeft:
  57. rotateTransform.Angle = 180;
  58. break;
  59. case ValveDirection.ToRight:
  60. rotateTransform.Angle = 0;
  61. break;
  62. default:
  63. break;
  64. }
  65. }
  66. catch (Exception ex)
  67. {
  68. LOG.WriteExeption(ex);
  69. throw ex;
  70. }
  71. }
  72. }
  73. }