Loading INAF.Apps.Uwp.SLabDataManager/App.xaml.cs +3 −0 Original line number Diff line number Diff line using INAF.Apps.Uwp.Charts; using INAF.Apps.Uwp.SLabDataManager.Charts; using INAF.Apps.Uwp.SLabDataManager.Charts.Containers; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Helpers.ConfigHelpers; using INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations; Loading Loading @@ -132,6 +133,7 @@ namespace INAF.Apps.Uwp.SLabDataManager /* transient */ .AddTransient<AuthenticationManager>() .AddTransient<ConfigReader>() .AddTransient<ContinuumSpectraContainer>() .AddTransient<RemoteOperationsHelper>() .AddTransient<RemoteOperationsManager>() .AddTransient<RemoteOperationsXmlReader>() Loading @@ -144,6 +146,7 @@ namespace INAF.Apps.Uwp.SLabDataManager /* view models */ .AddSingleton<ChartViewModel>() .AddSingleton<ContinuumAnalysisViewModel>() .AddSingleton<CustomPaletteHelper>() .AddTransient<LoginViewModel>() .AddTransient<LoginCheckViewModel>() .AddSingleton<MainViewModel>() Loading INAF.Apps.Uwp.SLabDataManager/Charts/Containers/ContinuumSpectraContainer.cs 0 → 100644 +83 −0 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Models.Spectrum; using INAF.Libraries.Uwp.Logging; using System; using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers { public class ContinuumSpectraContainer : SpectraContainerBase { public ContinuumSpectraContainer(IServiceProvider serviceProvider, Logger logger) : base(serviceProvider, logger) { init(); } public override async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) { if (Spectra.Any(x => x.Key.Equals(spectrum.Key))) { /* if a spectrum of same type is already present, then replace it... */ int index = Spectra.ToList().FindIndex(x => x.Key.Equals(spectrum.Key)); if (index >= 0) Spectra[index] = spectrum; } else /* ...otherwise, add it... */ addSpectrum(spectrum); if (Spectra.Count == 1) await setBoundariesAsync(); else await updateBoundariesAsync(); spectrum.PropertyChanged += Spectrum_PropertyChanged; } protected override void addSpectrum(SpectrumModel spectrum) { //spectrum.setColor(); Spectra.Add(spectrum); /* enable navigation to chart page */ raiseIsAnySpectrumLoaded(); } public SpectrumModel cloneSpectrum(string srcKey, string destKey) { if (!isAnySpectrumOfType(srcKey)) return null; SpectrumModel clonedSpectrum = (SpectrumModel)tryGetSpectrumOfType(srcKey).Clone(); clonedSpectrum.setKey(destKey); clonedSpectrum.updateTitle(); return clonedSpectrum; } public override void init() { base.init(); Spectra = new ObservableCollection<SpectrumModel>(); } public bool isAnySpectrumOfType(string key) { return Spectra.Any(x => x.Key.Equals(key)); } public async Task removeSpectrumOfTypeAsync(string key) { var requestedSpectrum = tryGetSpectrumOfType(key); Spectra.Remove(requestedSpectrum); await updateBoundariesAsync(); } public SpectrumModel tryGetSpectrumOfType(string key) { return Spectra.FirstOrDefault(x => x.Key.Equals(key)); } } } INAF.Apps.Uwp.SLabDataManager/Charts/Containers/ISpectraContainer.cs 0 → 100644 +25 −0 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Models.Spectrum; using System.Threading.Tasks; namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers { public interface ISpectraContainer { bool IsAlignedSpectrumSaved { get; set; } Task addOrUpdateSpectrumAsync(SpectrumModel spectrum); void init(); void raiseIsAnySpectrumLoaded(); void raiseIsUpdateLayoutRequired(); Task setBoundariesAsync(); void setYAxisTitle(string title); Task updateBoundariesAsync(); } } INAF.Apps.Uwp.SLabDataManager/Charts/SpectraContainer.cs→INAF.Apps.Uwp.SLabDataManager/Charts/Containers/SpectraContainer.cs +42 −18 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using INAF.Libraries.NetStandard.ScienceModels.Spectra; using INAF.Libraries.Uwp.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; Loading @@ -14,27 +11,19 @@ using static INAF.Libraries.NetStandard.ScienceModels.Enums.Enums; using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums; using SpectrumModel = INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel; namespace INAF.Apps.Uwp.SLabDataManager.Charts namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers { public class SpectraContainer : SpectraContainerBase { public SpectraContainer(IServiceProvider serviceProvider, Logger logger) : base(serviceProvider, logger) { } private void Spectrum_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { UpdateUIHelper.UpdateUIAsync(() => { IsAnySpectrumUpdated = true; }); init(); } public void raiseIsAnySpectrumLoaded() { IsAnySpectrumLoaded = true; isAnySpectrumLoaded = false;// trick to enable for the next added spectrum } public SelectedRefBand SelectedRefBand { get; protected set; } public SpectrumAlignmentConfigModel SpectrumAlignmentConfig { get; protected set; } public async Task removeSpectrumOfTypeAsync(SpectrumType type) { Loading @@ -44,7 +33,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts } #region spectra public async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) public override async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) { if (isAnySummaryOfType(spectrum.Type)) tryGetSummaryOfType(spectrum.Type).init(spectrum); Loading @@ -68,6 +57,17 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts spectrum.PropertyChanged += Spectrum_PropertyChanged; } public SpectrumModel cloneSpectrum(SpectrumType srcType, SpectrumType destType) { if (!isAnySpectrumOfType(srcType)) return null; SpectrumModel clonedSpectrum = (SpectrumModel)tryGetSpectrumOfType(srcType).Clone(); clonedSpectrum.setType(destType); clonedSpectrum.updateTitle(); return clonedSpectrum; } public bool isAnySpectrumOfType(SpectrumType spectrumType) { return Spectra.Any(x => x.Type == spectrumType); Loading @@ -86,7 +86,31 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts } #endregion private void addSpectrum(SpectrumModel spectrum) public void clear() { Spectra.Clear(); } public override void init() { base.init(); SpectrumAlignmentConfig = serviceProvider.GetRequiredService<SpectrumAlignmentConfigModel>(); SelectedRefBand = serviceProvider.GetRequiredService<SelectedRefBand>(); Spectra = new ObservableCollection<SpectrumModel>(); Summaries = new ObservableCollection<SpectrumSummaryModel>(); } public void switchXAxisMeasureUnit(WavelengthMeasureUnit wavelengthMeasureUnit) { Spectra.All(x => { x.switchToMeasureUnit(wavelengthMeasureUnit); return true; }); XAxisBoundaries.switchToMeasureUnit(wavelengthMeasureUnit); //setXAxisMajorStep(wavelengthMeasureUnit); } protected override void addSpectrum(SpectrumModel spectrum) { spectrum.setColor(); Spectra.Add(spectrum); Loading INAF.Apps.Uwp.SLabDataManager/Charts/SpectraContainerBase.cs→INAF.Apps.Uwp.SLabDataManager/Charts/Containers/SpectraContainerBase.cs +67 −56 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using INAF.Libraries.NetStandard.ScienceModels.Spectra; using INAF.Libraries.Uwp.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using static INAF.Libraries.NetStandard.ScienceModels.Enums.Enums; using SpectrumModel = INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using INAF.Apps.Uwp.SLabDataManager.Helpers; namespace INAF.Apps.Uwp.SLabDataManager.Charts namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers { public class SpectraContainerBase : ObservableObject public class SpectraContainerBase : ObservableObject, ISpectraContainer { protected readonly IServiceProvider serviceProvider; protected readonly Logger logger; public SpectraContainerBase(IServiceProvider serviceProvider, Logger logger) { SpectrumAlignmentConfig = serviceProvider.GetRequiredService<SpectrumAlignmentConfigModel>(); SelectedRefBand = serviceProvider.GetRequiredService<SelectedRefBand>(); init(); this.serviceProvider = serviceProvider; this.logger = logger; } protected void Spectrum_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { UpdateUIHelper.UpdateUIAsync(() => { IsAnySpectrumUpdated = true; }); } #region properties public bool IsAlignedSpectrumSaved { get; set; } Loading @@ -42,11 +47,14 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts public bool IsAnySpectrumLoaded { get { return isAnySpectrumLoaded; } set { SetProperty(ref isAnySpectrumLoaded, value); isAnySpectrumLoaded = false; // reset value to make it working @ the next spectrum loading set { SetProperty(ref isAnySpectrumLoaded, value); } } protected bool isAnySpectrumRemoved; public bool IsAnySpectrumRemoved { get { return isAnySpectrumRemoved; } set { SetProperty(ref isAnySpectrumRemoved, value); } } protected bool isAnySpectrumUpdated; Loading Loading @@ -88,9 +96,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts protected set { SetProperty(ref spectra, value); } } public SelectedRefBand SelectedRefBand { get; private set; } public SpectrumAlignmentConfigModel SpectrumAlignmentConfig { get; protected set; } public string YAxisTitle { get; protected set; } protected ObservableCollection<SpectrumSummaryModel> summaries; public ObservableCollection<SpectrumSummaryModel> Summaries Loading @@ -113,8 +119,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts get { return yAxisBoundaries; } protected set { SetProperty(ref yAxisBoundaries, value); } } public string YAxisTitle { get; private set; } #endregion #region x axis major step protected double selectedXAxisMajorStep; Loading @@ -134,41 +139,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts } #endregion #endregion #endregion public void clear() { Spectra.Clear(); } protected void init() { Spectra = new ObservableCollection<SpectrumModel>(); Summaries = new ObservableCollection<SpectrumSummaryModel>(); IsAlignedSpectrumSaved = false; IsAnySpectrumLoaded = false; IsSpectrumAligned = false; IsChartUpdateLayoutRequired = false; XAxisMajorStepValues = new List<double>(2); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_0DOT1); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_100); } public void setYAxisTitle(string title) { YAxisTitle = title; } public void switchXAxisMeasureUnit(WavelengthMeasureUnit wavelengthMeasureUnit) { Spectra.All(x => { x.switchToMeasureUnit(wavelengthMeasureUnit); return true; }); XAxisBoundaries.switchToMeasureUnit(wavelengthMeasureUnit); //setXAxisMajorStep(wavelengthMeasureUnit); } #region boundaries protected async Task<(double xMin, double xMax, double yMin, double yMax)> getSpectrumAxesBoundariesAsync() { List<Task> tasks = new List<Task>(); Loading Loading @@ -218,13 +189,37 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts return (xMin, xMax, yMin, yMax); } public virtual void init() { IsAlignedSpectrumSaved = false; IsAnySpectrumLoaded = false; IsSpectrumAligned = false; IsChartUpdateLayoutRequired = false; XAxisMajorStepValues = new List<double>(2); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_0DOT1); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_100); } public void raiseIsAnySpectrumLoaded() { IsAnySpectrumLoaded = true; isAnySpectrumLoaded = false;// trick to enable for the next added spectrum } public void raiseIsAnySpectrumRemoved() { IsAnySpectrumRemoved = true; isAnySpectrumRemoved = false;// trick to enable for the next added spectrum } public void raiseIsUpdateLayoutRequired() { IsChartUpdateLayoutRequired = true; isChartUpdateLayoutRequired = false; } protected async Task setBoundariesAsync() public async Task setBoundariesAsync() { (double xMin, double xMax, double yMin, double yMax) result = await getSpectrumAxesBoundariesAsync(); Loading @@ -232,6 +227,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts YAxisBoundaries = new AxisBoundariesModel("y", result.yMin, result.yMax); } public void setYAxisTitle(string title) { YAxisTitle = title; } public async Task updateBoundariesAsync() { (double xMin, double xMax, double yMin, double yMax) result = await getSpectrumAxesBoundariesAsync(); Loading @@ -239,6 +239,17 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts XAxisBoundaries.updateAxisBoundaries(result.xMin, result.xMax); YAxisBoundaries.updateAxisBoundaries(result.yMin, result.yMax); } #region virtual methods public virtual Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) { throw new NotImplementedException(); } protected virtual void addSpectrum(SpectrumModel spectrum) { throw new NotImplementedException(); } #endregion } } Loading
INAF.Apps.Uwp.SLabDataManager/App.xaml.cs +3 −0 Original line number Diff line number Diff line using INAF.Apps.Uwp.Charts; using INAF.Apps.Uwp.SLabDataManager.Charts; using INAF.Apps.Uwp.SLabDataManager.Charts.Containers; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Helpers.ConfigHelpers; using INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations; Loading Loading @@ -132,6 +133,7 @@ namespace INAF.Apps.Uwp.SLabDataManager /* transient */ .AddTransient<AuthenticationManager>() .AddTransient<ConfigReader>() .AddTransient<ContinuumSpectraContainer>() .AddTransient<RemoteOperationsHelper>() .AddTransient<RemoteOperationsManager>() .AddTransient<RemoteOperationsXmlReader>() Loading @@ -144,6 +146,7 @@ namespace INAF.Apps.Uwp.SLabDataManager /* view models */ .AddSingleton<ChartViewModel>() .AddSingleton<ContinuumAnalysisViewModel>() .AddSingleton<CustomPaletteHelper>() .AddTransient<LoginViewModel>() .AddTransient<LoginCheckViewModel>() .AddSingleton<MainViewModel>() Loading
INAF.Apps.Uwp.SLabDataManager/Charts/Containers/ContinuumSpectraContainer.cs 0 → 100644 +83 −0 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Models.Spectrum; using INAF.Libraries.Uwp.Logging; using System; using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers { public class ContinuumSpectraContainer : SpectraContainerBase { public ContinuumSpectraContainer(IServiceProvider serviceProvider, Logger logger) : base(serviceProvider, logger) { init(); } public override async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) { if (Spectra.Any(x => x.Key.Equals(spectrum.Key))) { /* if a spectrum of same type is already present, then replace it... */ int index = Spectra.ToList().FindIndex(x => x.Key.Equals(spectrum.Key)); if (index >= 0) Spectra[index] = spectrum; } else /* ...otherwise, add it... */ addSpectrum(spectrum); if (Spectra.Count == 1) await setBoundariesAsync(); else await updateBoundariesAsync(); spectrum.PropertyChanged += Spectrum_PropertyChanged; } protected override void addSpectrum(SpectrumModel spectrum) { //spectrum.setColor(); Spectra.Add(spectrum); /* enable navigation to chart page */ raiseIsAnySpectrumLoaded(); } public SpectrumModel cloneSpectrum(string srcKey, string destKey) { if (!isAnySpectrumOfType(srcKey)) return null; SpectrumModel clonedSpectrum = (SpectrumModel)tryGetSpectrumOfType(srcKey).Clone(); clonedSpectrum.setKey(destKey); clonedSpectrum.updateTitle(); return clonedSpectrum; } public override void init() { base.init(); Spectra = new ObservableCollection<SpectrumModel>(); } public bool isAnySpectrumOfType(string key) { return Spectra.Any(x => x.Key.Equals(key)); } public async Task removeSpectrumOfTypeAsync(string key) { var requestedSpectrum = tryGetSpectrumOfType(key); Spectra.Remove(requestedSpectrum); await updateBoundariesAsync(); } public SpectrumModel tryGetSpectrumOfType(string key) { return Spectra.FirstOrDefault(x => x.Key.Equals(key)); } } }
INAF.Apps.Uwp.SLabDataManager/Charts/Containers/ISpectraContainer.cs 0 → 100644 +25 −0 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Models.Spectrum; using System.Threading.Tasks; namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers { public interface ISpectraContainer { bool IsAlignedSpectrumSaved { get; set; } Task addOrUpdateSpectrumAsync(SpectrumModel spectrum); void init(); void raiseIsAnySpectrumLoaded(); void raiseIsUpdateLayoutRequired(); Task setBoundariesAsync(); void setYAxisTitle(string title); Task updateBoundariesAsync(); } }
INAF.Apps.Uwp.SLabDataManager/Charts/SpectraContainer.cs→INAF.Apps.Uwp.SLabDataManager/Charts/Containers/SpectraContainer.cs +42 −18 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using INAF.Libraries.NetStandard.ScienceModels.Spectra; using INAF.Libraries.Uwp.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; Loading @@ -14,27 +11,19 @@ using static INAF.Libraries.NetStandard.ScienceModels.Enums.Enums; using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums; using SpectrumModel = INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel; namespace INAF.Apps.Uwp.SLabDataManager.Charts namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers { public class SpectraContainer : SpectraContainerBase { public SpectraContainer(IServiceProvider serviceProvider, Logger logger) : base(serviceProvider, logger) { } private void Spectrum_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { UpdateUIHelper.UpdateUIAsync(() => { IsAnySpectrumUpdated = true; }); init(); } public void raiseIsAnySpectrumLoaded() { IsAnySpectrumLoaded = true; isAnySpectrumLoaded = false;// trick to enable for the next added spectrum } public SelectedRefBand SelectedRefBand { get; protected set; } public SpectrumAlignmentConfigModel SpectrumAlignmentConfig { get; protected set; } public async Task removeSpectrumOfTypeAsync(SpectrumType type) { Loading @@ -44,7 +33,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts } #region spectra public async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) public override async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) { if (isAnySummaryOfType(spectrum.Type)) tryGetSummaryOfType(spectrum.Type).init(spectrum); Loading @@ -68,6 +57,17 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts spectrum.PropertyChanged += Spectrum_PropertyChanged; } public SpectrumModel cloneSpectrum(SpectrumType srcType, SpectrumType destType) { if (!isAnySpectrumOfType(srcType)) return null; SpectrumModel clonedSpectrum = (SpectrumModel)tryGetSpectrumOfType(srcType).Clone(); clonedSpectrum.setType(destType); clonedSpectrum.updateTitle(); return clonedSpectrum; } public bool isAnySpectrumOfType(SpectrumType spectrumType) { return Spectra.Any(x => x.Type == spectrumType); Loading @@ -86,7 +86,31 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts } #endregion private void addSpectrum(SpectrumModel spectrum) public void clear() { Spectra.Clear(); } public override void init() { base.init(); SpectrumAlignmentConfig = serviceProvider.GetRequiredService<SpectrumAlignmentConfigModel>(); SelectedRefBand = serviceProvider.GetRequiredService<SelectedRefBand>(); Spectra = new ObservableCollection<SpectrumModel>(); Summaries = new ObservableCollection<SpectrumSummaryModel>(); } public void switchXAxisMeasureUnit(WavelengthMeasureUnit wavelengthMeasureUnit) { Spectra.All(x => { x.switchToMeasureUnit(wavelengthMeasureUnit); return true; }); XAxisBoundaries.switchToMeasureUnit(wavelengthMeasureUnit); //setXAxisMajorStep(wavelengthMeasureUnit); } protected override void addSpectrum(SpectrumModel spectrum) { spectrum.setColor(); Spectra.Add(spectrum); Loading
INAF.Apps.Uwp.SLabDataManager/Charts/SpectraContainerBase.cs→INAF.Apps.Uwp.SLabDataManager/Charts/Containers/SpectraContainerBase.cs +67 −56 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using INAF.Libraries.NetStandard.ScienceModels.Spectra; using INAF.Libraries.Uwp.Logging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using static INAF.Libraries.NetStandard.ScienceModels.Enums.Enums; using SpectrumModel = INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using INAF.Apps.Uwp.SLabDataManager.Helpers; namespace INAF.Apps.Uwp.SLabDataManager.Charts namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers { public class SpectraContainerBase : ObservableObject public class SpectraContainerBase : ObservableObject, ISpectraContainer { protected readonly IServiceProvider serviceProvider; protected readonly Logger logger; public SpectraContainerBase(IServiceProvider serviceProvider, Logger logger) { SpectrumAlignmentConfig = serviceProvider.GetRequiredService<SpectrumAlignmentConfigModel>(); SelectedRefBand = serviceProvider.GetRequiredService<SelectedRefBand>(); init(); this.serviceProvider = serviceProvider; this.logger = logger; } protected void Spectrum_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { UpdateUIHelper.UpdateUIAsync(() => { IsAnySpectrumUpdated = true; }); } #region properties public bool IsAlignedSpectrumSaved { get; set; } Loading @@ -42,11 +47,14 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts public bool IsAnySpectrumLoaded { get { return isAnySpectrumLoaded; } set { SetProperty(ref isAnySpectrumLoaded, value); isAnySpectrumLoaded = false; // reset value to make it working @ the next spectrum loading set { SetProperty(ref isAnySpectrumLoaded, value); } } protected bool isAnySpectrumRemoved; public bool IsAnySpectrumRemoved { get { return isAnySpectrumRemoved; } set { SetProperty(ref isAnySpectrumRemoved, value); } } protected bool isAnySpectrumUpdated; Loading Loading @@ -88,9 +96,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts protected set { SetProperty(ref spectra, value); } } public SelectedRefBand SelectedRefBand { get; private set; } public SpectrumAlignmentConfigModel SpectrumAlignmentConfig { get; protected set; } public string YAxisTitle { get; protected set; } protected ObservableCollection<SpectrumSummaryModel> summaries; public ObservableCollection<SpectrumSummaryModel> Summaries Loading @@ -113,8 +119,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts get { return yAxisBoundaries; } protected set { SetProperty(ref yAxisBoundaries, value); } } public string YAxisTitle { get; private set; } #endregion #region x axis major step protected double selectedXAxisMajorStep; Loading @@ -134,41 +139,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts } #endregion #endregion #endregion public void clear() { Spectra.Clear(); } protected void init() { Spectra = new ObservableCollection<SpectrumModel>(); Summaries = new ObservableCollection<SpectrumSummaryModel>(); IsAlignedSpectrumSaved = false; IsAnySpectrumLoaded = false; IsSpectrumAligned = false; IsChartUpdateLayoutRequired = false; XAxisMajorStepValues = new List<double>(2); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_0DOT1); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_100); } public void setYAxisTitle(string title) { YAxisTitle = title; } public void switchXAxisMeasureUnit(WavelengthMeasureUnit wavelengthMeasureUnit) { Spectra.All(x => { x.switchToMeasureUnit(wavelengthMeasureUnit); return true; }); XAxisBoundaries.switchToMeasureUnit(wavelengthMeasureUnit); //setXAxisMajorStep(wavelengthMeasureUnit); } #region boundaries protected async Task<(double xMin, double xMax, double yMin, double yMax)> getSpectrumAxesBoundariesAsync() { List<Task> tasks = new List<Task>(); Loading Loading @@ -218,13 +189,37 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts return (xMin, xMax, yMin, yMax); } public virtual void init() { IsAlignedSpectrumSaved = false; IsAnySpectrumLoaded = false; IsSpectrumAligned = false; IsChartUpdateLayoutRequired = false; XAxisMajorStepValues = new List<double>(2); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_0DOT1); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_100); } public void raiseIsAnySpectrumLoaded() { IsAnySpectrumLoaded = true; isAnySpectrumLoaded = false;// trick to enable for the next added spectrum } public void raiseIsAnySpectrumRemoved() { IsAnySpectrumRemoved = true; isAnySpectrumRemoved = false;// trick to enable for the next added spectrum } public void raiseIsUpdateLayoutRequired() { IsChartUpdateLayoutRequired = true; isChartUpdateLayoutRequired = false; } protected async Task setBoundariesAsync() public async Task setBoundariesAsync() { (double xMin, double xMax, double yMin, double yMax) result = await getSpectrumAxesBoundariesAsync(); Loading @@ -232,6 +227,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts YAxisBoundaries = new AxisBoundariesModel("y", result.yMin, result.yMax); } public void setYAxisTitle(string title) { YAxisTitle = title; } public async Task updateBoundariesAsync() { (double xMin, double xMax, double yMin, double yMax) result = await getSpectrumAxesBoundariesAsync(); Loading @@ -239,6 +239,17 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts XAxisBoundaries.updateAxisBoundaries(result.xMin, result.xMax); YAxisBoundaries.updateAxisBoundaries(result.yMin, result.yMax); } #region virtual methods public virtual Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) { throw new NotImplementedException(); } protected virtual void addSpectrum(SpectrumModel spectrum) { throw new NotImplementedException(); } #endregion } }