Loading INAF.Apps.Uwp.SLabDataManager/Models/AlignmentConfigModel.cs +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models SeparatorWavelength0.switchToMeasureUnit(newMeasureUnit); SeparatorWavelength1.switchToMeasureUnit(newMeasureUnit); SeparatorWavelength2.switchToMeasureUnit(newMeasureUnit); SeparatorWavelength3.switchToMeasureUnit(newMeasureUnit); } } } INAF.Apps.Uwp.SLabDataManager/Models/WorkingItemsModel.cs +30 −1 Original line number Diff line number Diff line Loading @@ -8,8 +8,10 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models { public class WorkingItemsModel : ObservableObject { public WorkingItemsModel() public WorkingItemsModel(AlignmentConfigModel alignmentConfig) { AlignmentConfig = alignmentConfig; init(); } Loading Loading @@ -60,6 +62,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models } #endregion public AlignmentConfigModel AlignmentConfig { get; set; } private SpectrumChartOptionsModel spectrumChartOptions; public SpectrumChartOptionsModel SpectrumChartOptions { Loading Loading @@ -87,6 +91,31 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models RefSpectrumFilepath = "RefSpectrumFileNotSelectedMessage".GetText(); RefSpectrumReadingStatus = Status.None; } public void reset() { RawSpectrum = null; RefSpectrum = null; RawSpectrumSummary.reset(); RefSpectrumSummary.reset(); if (SpectrumChartOptions != null) SpectrumChartOptions.PropertyChanged -= SpectrumChartOptions_PropertyChanged; } public void setSpectrumChartOptionsEventListener() { if (SpectrumChartOptions != null) SpectrumChartOptions.PropertyChanged += SpectrumChartOptions_PropertyChanged; } private void SpectrumChartOptions_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName.Equals(nameof(SpectrumChartOptions.SelectedWavelengthMeasureUnit))) { AlignmentConfig.switchToMeasureUnit(SpectrumChartOptions.SelectedWavelengthMeasureUnit); } } #endregion } } INAF.Apps.Uwp.SLabDataManager/ViewModels/BaseViewModel.cs +2 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels { this.serviceProvider = serviceProvider; WorkingItemsModel = (WorkingItemsModel)serviceProvider.GetService(typeof(WorkingItemsModel)); WorkingItems = (WorkingItemsModel)serviceProvider.GetService(typeof(WorkingItemsModel)); } public BaseViewModel(IServiceProvider serviceProvider, Loading Loading @@ -53,7 +53,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels } #region properties public WorkingItemsModel WorkingItemsModel { get; set; } public WorkingItemsModel WorkingItems { get; set; } #endregion } } INAF.Apps.Uwp.SLabDataManager/ViewModels/ChartViewModel.cs +3 −7 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels settingsHelper, storageItemsAccessHelper, logger) { AlignmentConfig = alignmentConfig; } { } #region navigation events public void OnNavigatedTo(NavigationEventArgs e) Loading @@ -38,8 +36,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels #endregion #region properties public AlignmentConfigModel AlignmentConfig { get; set; } private bool isLoading; public bool IsLoading { Loading @@ -60,8 +56,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels }); /* switch unit of measure for alignment options, if needed */ if (WorkingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit != Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Nanometers) AlignmentConfig.switchToMeasureUnit(WorkingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit); if (WorkingItems.SpectrumChartOptions.SelectedWavelengthMeasureUnit != Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Nanometers) WorkingItems.AlignmentConfig.switchToMeasureUnit(WorkingItems.SpectrumChartOptions.SelectedWavelengthMeasureUnit); IsLoading = false; } Loading INAF.Apps.Uwp.SLabDataManager/ViewModels/MainViewModel.cs +13 −10 Original line number Diff line number Diff line Loading @@ -49,19 +49,21 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels private async Task tryReadingSpectrumFileAsync(FileType fileType) { //SpectrumModel spectrum = null; //string filename = string.Empty; /* reset WorkingItems for avoiding errors when a spectrum is already opened and we're opening a new one */ WorkingItems.reset(); /* retrieve usefull items for reading new spectrum and read it */ SpectrumReader reader = serviceProvider.GetRequiredService<SpectrumReader>(); SpectrumModel spectrum = await reader.readAsync(fileType); /* if spectrum has been successfully opened, then do operations for showing chart */ if (spectrum != null) { switch (fileType) { case FileType.Raw: WorkingItemsModel.RawSpectrum = spectrum; WorkingItemsModel.RawSpectrumSummary.init(spectrum); WorkingItems.RawSpectrum = spectrum; WorkingItems.RawSpectrumSummary.init(spectrum); spectrumChartOptionsModel.Filename = spectrum.Filename; spectrumChartOptionsModel.YAxisTitle = "SpectrumYAxisTitle".GetText(); Loading @@ -75,11 +77,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels }); spectrumChartOptionsModel.setSpectrum(spectrum); WorkingItemsModel.SpectrumChartOptions = spectrumChartOptionsModel; WorkingItems.SpectrumChartOptions = spectrumChartOptionsModel; WorkingItems.setSpectrumChartOptionsEventListener(); break; case FileType.Ref: WorkingItemsModel.RefSpectrum = spectrum; WorkingItemsModel.RefSpectrumSummary.init(spectrum); WorkingItems.RefSpectrum = spectrum; WorkingItems.RefSpectrumSummary.init(spectrum); break; } Loading @@ -89,7 +92,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels private async Task selectFileAsync(FileType fileType, List<FileExt> fileExts) { /* reset spectrum summary when opening a new file */ WorkingItemsModel.RawSpectrumSummary.reset(); WorkingItems.RawSpectrumSummary.reset(); /* select file */ StorageFile file = await base.selectFileAsync(fileExts); Loading @@ -99,7 +102,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels switch (fileType) { case FileType.Raw: WorkingItemsModel.RawSpectrumFilepath = file.Path; WorkingItems.RawSpectrumFilepath = file.Path; /* remember access to file */ settingsHelper.save(Constants.Constants.RAW_SPECTRUM_FILE, file.Path); /* remember access to file */ Loading @@ -109,7 +112,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels await tryReadingSpectrumFileAsync(fileType); break; case FileType.Ref: WorkingItemsModel.RefSpectrumFilepath = file.Path; WorkingItems.RefSpectrumFilepath = file.Path; /* remember access to file */ settingsHelper.save(Constants.Constants.REF_SPECTRUM_FILE, file.Path); /* remember access to file */ Loading Loading
INAF.Apps.Uwp.SLabDataManager/Models/AlignmentConfigModel.cs +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models SeparatorWavelength0.switchToMeasureUnit(newMeasureUnit); SeparatorWavelength1.switchToMeasureUnit(newMeasureUnit); SeparatorWavelength2.switchToMeasureUnit(newMeasureUnit); SeparatorWavelength3.switchToMeasureUnit(newMeasureUnit); } } }
INAF.Apps.Uwp.SLabDataManager/Models/WorkingItemsModel.cs +30 −1 Original line number Diff line number Diff line Loading @@ -8,8 +8,10 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models { public class WorkingItemsModel : ObservableObject { public WorkingItemsModel() public WorkingItemsModel(AlignmentConfigModel alignmentConfig) { AlignmentConfig = alignmentConfig; init(); } Loading Loading @@ -60,6 +62,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models } #endregion public AlignmentConfigModel AlignmentConfig { get; set; } private SpectrumChartOptionsModel spectrumChartOptions; public SpectrumChartOptionsModel SpectrumChartOptions { Loading Loading @@ -87,6 +91,31 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models RefSpectrumFilepath = "RefSpectrumFileNotSelectedMessage".GetText(); RefSpectrumReadingStatus = Status.None; } public void reset() { RawSpectrum = null; RefSpectrum = null; RawSpectrumSummary.reset(); RefSpectrumSummary.reset(); if (SpectrumChartOptions != null) SpectrumChartOptions.PropertyChanged -= SpectrumChartOptions_PropertyChanged; } public void setSpectrumChartOptionsEventListener() { if (SpectrumChartOptions != null) SpectrumChartOptions.PropertyChanged += SpectrumChartOptions_PropertyChanged; } private void SpectrumChartOptions_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName.Equals(nameof(SpectrumChartOptions.SelectedWavelengthMeasureUnit))) { AlignmentConfig.switchToMeasureUnit(SpectrumChartOptions.SelectedWavelengthMeasureUnit); } } #endregion } }
INAF.Apps.Uwp.SLabDataManager/ViewModels/BaseViewModel.cs +2 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels { this.serviceProvider = serviceProvider; WorkingItemsModel = (WorkingItemsModel)serviceProvider.GetService(typeof(WorkingItemsModel)); WorkingItems = (WorkingItemsModel)serviceProvider.GetService(typeof(WorkingItemsModel)); } public BaseViewModel(IServiceProvider serviceProvider, Loading Loading @@ -53,7 +53,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels } #region properties public WorkingItemsModel WorkingItemsModel { get; set; } public WorkingItemsModel WorkingItems { get; set; } #endregion } }
INAF.Apps.Uwp.SLabDataManager/ViewModels/ChartViewModel.cs +3 −7 Original line number Diff line number Diff line Loading @@ -21,9 +21,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels settingsHelper, storageItemsAccessHelper, logger) { AlignmentConfig = alignmentConfig; } { } #region navigation events public void OnNavigatedTo(NavigationEventArgs e) Loading @@ -38,8 +36,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels #endregion #region properties public AlignmentConfigModel AlignmentConfig { get; set; } private bool isLoading; public bool IsLoading { Loading @@ -60,8 +56,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels }); /* switch unit of measure for alignment options, if needed */ if (WorkingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit != Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Nanometers) AlignmentConfig.switchToMeasureUnit(WorkingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit); if (WorkingItems.SpectrumChartOptions.SelectedWavelengthMeasureUnit != Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Nanometers) WorkingItems.AlignmentConfig.switchToMeasureUnit(WorkingItems.SpectrumChartOptions.SelectedWavelengthMeasureUnit); IsLoading = false; } Loading
INAF.Apps.Uwp.SLabDataManager/ViewModels/MainViewModel.cs +13 −10 Original line number Diff line number Diff line Loading @@ -49,19 +49,21 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels private async Task tryReadingSpectrumFileAsync(FileType fileType) { //SpectrumModel spectrum = null; //string filename = string.Empty; /* reset WorkingItems for avoiding errors when a spectrum is already opened and we're opening a new one */ WorkingItems.reset(); /* retrieve usefull items for reading new spectrum and read it */ SpectrumReader reader = serviceProvider.GetRequiredService<SpectrumReader>(); SpectrumModel spectrum = await reader.readAsync(fileType); /* if spectrum has been successfully opened, then do operations for showing chart */ if (spectrum != null) { switch (fileType) { case FileType.Raw: WorkingItemsModel.RawSpectrum = spectrum; WorkingItemsModel.RawSpectrumSummary.init(spectrum); WorkingItems.RawSpectrum = spectrum; WorkingItems.RawSpectrumSummary.init(spectrum); spectrumChartOptionsModel.Filename = spectrum.Filename; spectrumChartOptionsModel.YAxisTitle = "SpectrumYAxisTitle".GetText(); Loading @@ -75,11 +77,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels }); spectrumChartOptionsModel.setSpectrum(spectrum); WorkingItemsModel.SpectrumChartOptions = spectrumChartOptionsModel; WorkingItems.SpectrumChartOptions = spectrumChartOptionsModel; WorkingItems.setSpectrumChartOptionsEventListener(); break; case FileType.Ref: WorkingItemsModel.RefSpectrum = spectrum; WorkingItemsModel.RefSpectrumSummary.init(spectrum); WorkingItems.RefSpectrum = spectrum; WorkingItems.RefSpectrumSummary.init(spectrum); break; } Loading @@ -89,7 +92,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels private async Task selectFileAsync(FileType fileType, List<FileExt> fileExts) { /* reset spectrum summary when opening a new file */ WorkingItemsModel.RawSpectrumSummary.reset(); WorkingItems.RawSpectrumSummary.reset(); /* select file */ StorageFile file = await base.selectFileAsync(fileExts); Loading @@ -99,7 +102,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels switch (fileType) { case FileType.Raw: WorkingItemsModel.RawSpectrumFilepath = file.Path; WorkingItems.RawSpectrumFilepath = file.Path; /* remember access to file */ settingsHelper.save(Constants.Constants.RAW_SPECTRUM_FILE, file.Path); /* remember access to file */ Loading @@ -109,7 +112,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels await tryReadingSpectrumFileAsync(fileType); break; case FileType.Ref: WorkingItemsModel.RefSpectrumFilepath = file.Path; WorkingItems.RefSpectrumFilepath = file.Path; /* remember access to file */ settingsHelper.save(Constants.Constants.REF_SPECTRUM_FILE, file.Path); /* remember access to file */ Loading