Commit c1d485f0 authored by Francesco Carraro's avatar Francesco Carraro
Browse files

fixed UI issues in chart for changing unit of measure by flyout

parent 8cd949d2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models
            SeparatorWavelength0.switchToMeasureUnit(newMeasureUnit);
            SeparatorWavelength1.switchToMeasureUnit(newMeasureUnit);
            SeparatorWavelength2.switchToMeasureUnit(newMeasureUnit);
            SeparatorWavelength3.switchToMeasureUnit(newMeasureUnit);
        }
    }
}
+30 −1
Original line number Diff line number Diff line
@@ -8,8 +8,10 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models
{
    public class WorkingItemsModel : ObservableObject
    {
        public WorkingItemsModel()
        public WorkingItemsModel(AlignmentConfigModel alignmentConfig)
        {
            AlignmentConfig = alignmentConfig;

            init();
        }

@@ -60,6 +62,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models
        }
        #endregion

        public AlignmentConfigModel AlignmentConfig { get; set; }

        private SpectrumChartOptionsModel spectrumChartOptions;
        public SpectrumChartOptionsModel SpectrumChartOptions
        {
@@ -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
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -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,
@@ -53,7 +53,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels
        }

        #region properties
        public WorkingItemsModel WorkingItemsModel { get; set; }
        public WorkingItemsModel WorkingItems { get; set; }
        #endregion
    }
}
+3 −7
Original line number Diff line number Diff line
@@ -21,9 +21,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels
                                                   settingsHelper,
                                                   storageItemsAccessHelper,
                                                   logger)
        {
            AlignmentConfig = alignmentConfig;
        }
        { }

        #region navigation events
        public void OnNavigatedTo(NavigationEventArgs e)
@@ -38,8 +36,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels
        #endregion

        #region properties
        public AlignmentConfigModel AlignmentConfig { get; set; }

        private bool isLoading;
        public bool IsLoading
        {
@@ -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;
        }
+13 −10
Original line number Diff line number Diff line
@@ -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();
@@ -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;
                }
                
@@ -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);
@@ -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 */
@@ -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