PanelUvSize.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.Windows;
  2. using System.Windows.Controls;
  3. namespace HandyControl.Data;
  4. internal struct PanelUvSize
  5. {
  6. private readonly Orientation _orientation;
  7. public Size ScreenSize => new(U, V);
  8. public double U { get; set; }
  9. public double V { get; set; }
  10. public double Width
  11. {
  12. get => _orientation == Orientation.Horizontal ? U : V;
  13. private set
  14. {
  15. if (_orientation == Orientation.Horizontal)
  16. {
  17. U = value;
  18. }
  19. else
  20. {
  21. V = value;
  22. }
  23. }
  24. }
  25. public double Height
  26. {
  27. get => _orientation == Orientation.Horizontal ? V : U;
  28. private set
  29. {
  30. if (_orientation == Orientation.Horizontal)
  31. {
  32. V = value;
  33. }
  34. else
  35. {
  36. U = value;
  37. }
  38. }
  39. }
  40. public PanelUvSize(Orientation orientation, double width, double height)
  41. {
  42. U = V = 0d;
  43. _orientation = orientation;
  44. Width = width;
  45. Height = height;
  46. }
  47. public PanelUvSize(Orientation orientation, Size size)
  48. {
  49. U = V = 0d;
  50. _orientation = orientation;
  51. Width = size.Width;
  52. Height = size.Height;
  53. }
  54. public PanelUvSize(Orientation orientation)
  55. {
  56. U = V = 0d;
  57. _orientation = orientation;
  58. }
  59. }