RoiModel.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Prism.Mvvm;
  2. using System.Windows;
  3. using TeamAAS_VP.Resources.Languages;
  4. namespace TeamAAS_VP.Models
  5. {
  6. /// <summary>
  7. /// ROI模型
  8. /// </summary>
  9. public class RoiModel : BindableBase
  10. {
  11. private double _x;
  12. private double _y;
  13. private double _width;
  14. private double _height;
  15. private double _angle;
  16. /// <summary>
  17. /// X坐标
  18. /// </summary>
  19. public double X
  20. {
  21. get => _x;
  22. set => SetProperty(ref _x, value);
  23. }
  24. /// <summary>
  25. /// Y坐标
  26. /// </summary>
  27. public double Y
  28. {
  29. get => _y;
  30. set => SetProperty(ref _y, value);
  31. }
  32. /// <summary>
  33. /// 宽度
  34. /// </summary>
  35. public double Width
  36. {
  37. get => _width;
  38. set => SetProperty(ref _width, value);
  39. }
  40. /// <summary>
  41. /// 高度
  42. /// </summary>
  43. public double Height
  44. {
  45. get => _height;
  46. set => SetProperty(ref _height, value);
  47. }
  48. /// <summary>
  49. /// 旋转角度
  50. /// </summary>
  51. public double Angle
  52. {
  53. get => _angle;
  54. set => SetProperty(ref _angle, value);
  55. }
  56. public bool IsValid => Width > 0 && Height > 0;
  57. public Rect ToRect() => new Rect(X, Y, Width, Height);
  58. public override string ToString()
  59. {
  60. return IsValid
  61. ? $"X={X:F0}, Y={Y:F0}, W={Width:F0}, H={Height:F0}, Angle={Angle:F1}°"
  62. : Lang.未设置;
  63. }
  64. }
  65. }