BoatDiagram.xaml.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace MaintainModule.Controls;
  16. /// <summary>
  17. /// Interaction logic for BoatDiagram.xaml
  18. /// </summary>
  19. public partial class BoatDiagram : UserControl
  20. {
  21. public BoatDiagram()
  22. {
  23. InitializeComponent();
  24. }
  25. public int Position
  26. {
  27. get { return (int)GetValue(PositionProperty); }
  28. set { SetValue(PositionProperty, value); }
  29. }
  30. // Using a DependencyProperty as the backing store for Position. This enables animation, styling, binding, etc...
  31. public static readonly DependencyProperty PositionProperty =
  32. DependencyProperty.Register(nameof(Position), typeof(int), typeof(BoatDiagram), new PropertyMetadata(3, PropertyChangedCallback));
  33. static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  34. {
  35. if (d is not BoatDiagram boat)
  36. return;
  37. if (e.NewValue is not int pos)
  38. return;
  39. switch (pos)
  40. {
  41. case 1:
  42. boat.Core.SetValue(Canvas.TopProperty, 126d);
  43. break;
  44. case 2:
  45. boat.Core.SetValue(Canvas.TopProperty, 286d);
  46. break;
  47. case 3:
  48. boat.Core.SetValue(Canvas.TopProperty, 380d);
  49. break;
  50. default:
  51. break;
  52. }
  53. }
  54. }