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