RoiModel.cs 1.5 KB

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