DetectorEnableModel.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. namespace OINA.Extender.WPF.Testharness
  2. {
  3. using System.ComponentModel;
  4. using OINA.Extender.Data.Ed;
  5. /// <summary>
  6. /// Provides an object for WPF to bind to, where the user can enable / disable which detectors are used in a spectrum acquisition
  7. /// </summary>
  8. /// <seealso cref="System.ComponentModel.INotifyPropertyChanged" />
  9. public sealed class DetectorEnableModel : INotifyPropertyChanged
  10. {
  11. private readonly EdHardwareId edHardwareId;
  12. private bool isDetectorEnabled;
  13. public DetectorEnableModel(EdHardwareId edHardwareId, bool enabled)
  14. {
  15. this.edHardwareId = edHardwareId;
  16. this.isDetectorEnabled = enabled;
  17. }
  18. public event PropertyChangedEventHandler PropertyChanged;
  19. public bool IsDetectorEnabled
  20. {
  21. get
  22. {
  23. return this.isDetectorEnabled;
  24. }
  25. set
  26. {
  27. if (this.isDetectorEnabled != value)
  28. {
  29. this.isDetectorEnabled = value;
  30. this.RaisePropertyChangedEvent(nameof(this.IsDetectorEnabled));
  31. }
  32. }
  33. }
  34. public string DisplayName
  35. {
  36. get
  37. {
  38. return this.edHardwareId.DisplayName;
  39. }
  40. }
  41. public EdHardwareId EdHardwareId
  42. {
  43. get
  44. {
  45. return this.edHardwareId;
  46. }
  47. }
  48. /// <summary>
  49. /// Raises the property changed event.
  50. /// </summary>
  51. /// <param name="propertyName">Name of the property.</param>
  52. private void RaisePropertyChangedEvent(string propertyName)
  53. {
  54. this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  55. }
  56. }
  57. }