namespace OINA.Extender.WPF.Testharness { using System; using System.ComponentModel; using OINA.Extender.Acquisition.Ed; using OINA.Extender.Data.Ed; /// /// Item to encapsulate an acquisition /// public class AcquisitionItem : INotifyPropertyChanged { /// /// Gets the ed spectrum. /// /// /// The ed spectrum. /// public IEdSpectrum EdSpectrum { get; private set; } /// /// Gets the label. /// /// /// The label. /// public string Label { get { return this.EdSpectrum.Label; } } /// /// Gets the aquisition mode. /// /// /// The aquisition mode. /// public EdAcquireMode AcquisitionMode { get; private set; } /// /// Gets the aquisition time. /// /// /// The aquisition time. /// public double AcquisitionTime { get; private set; } /// /// Gets the current progress. /// /// /// The current progress. /// public double CurrentProgress { get { if (this.AcquisitionMode == EdAcquireMode.LiveTime) { return this.EdSpectrum.LiveTimeSeconds * 1000.0; } else { return this.EdSpectrum.RealTimeSeconds * 1000.0; } } } /// /// Initializes a new instance of the class. /// /// The ed spectrum. /// The mode. /// The aquisition time. public AcquisitionItem(IEdSpectrum edSpectrum, EdAcquireMode mode, double acquisitionTime) { this.EdSpectrum = edSpectrum; this.AcquisitionMode = mode; this.AcquisitionTime = acquisitionTime; this.EdSpectrum.DataChanged += this.OnEdSpectrumDataChanged; } /// /// Called when [ed spectrum data changed]. /// /// The sender. /// The instance containing the event data. public void OnEdSpectrumDataChanged(object sender, EventArgs e) { this.RaisePropertyChangedEvent(@"CurrentProgress"); } /// /// Occurs when a property value changes. /// public event PropertyChangedEventHandler PropertyChanged; /// /// Raises the property changed event. /// /// Name of the property. private void RaisePropertyChangedEvent(string propertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } }