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