CheckerboardResult.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace TeamAAS_VP.Models
  9. {
  10. /// <summary>
  11. /// 棋盘格分析结果
  12. /// </summary>
  13. public class CheckerboardResult : INotifyPropertyChanged
  14. {
  15. private bool _detected;
  16. private double _blackMean;
  17. private double _whiteMean;
  18. private double _contrast;
  19. private int _optimalBrightness;
  20. public bool Detected
  21. {
  22. get => _detected;
  23. set => SetField(ref _detected, value);
  24. }
  25. public double BlackMean
  26. {
  27. get => _blackMean;
  28. set => SetField(ref _blackMean, value);
  29. }
  30. public double WhiteMean
  31. {
  32. get => _whiteMean;
  33. set => SetField(ref _whiteMean, value);
  34. }
  35. public double Contrast
  36. {
  37. get => _contrast;
  38. set => SetField(ref _contrast, value);
  39. }
  40. public int OptimalBrightness
  41. {
  42. get => _optimalBrightness;
  43. set => SetField(ref _optimalBrightness, value);
  44. }
  45. public event PropertyChangedEventHandler PropertyChanged;
  46. protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
  47. {
  48. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  49. }
  50. protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
  51. {
  52. if (EqualityComparer<T>.Default.Equals(field, value)) return false;
  53. field = value;
  54. OnPropertyChanged(propertyName);
  55. return true;
  56. }
  57. }
  58. }