Commit 04935b4a authored by Francesco Carraro's avatar Francesco Carraro
Browse files

completed zoom panel; fixed segments-fits panel open/close; fixed handling of...

completed zoom panel; fixed segments-fits panel open/close; fixed handling of unit of measure change
parent 0c1702ab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ namespace INAF.Apps.Uwp.SLabDataManager

        private ActivationService CreateActivationService()
        {
#if DEBUG
#if DEBUG2
            return new ActivationService(this, typeof(Views.MainPage), new Lazy<UIElement>(CreateShell));
#else
            /* hide left navigation pane to avoid navigation to main page if user is not allowed */
+4 −2
Original line number Diff line number Diff line
using INAF.Apps.Uwp.SLabDataManager.Models.Spectrum;
using INAF.Apps.Uwp.Charts;
using INAF.Apps.Uwp.SLabDataManager.Models.Spectrum;
using INAF.Libraries.Uwp.Logging;
using System;
using System.Collections.ObjectModel;
@@ -10,7 +11,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
    public class ContinuumSpectraContainer : SpectraContainerBase
    {
        public ContinuumSpectraContainer(IServiceProvider serviceProvider,
                                         Logger logger) : base(serviceProvider, logger)
                                         SpectrumChartOptionsModel spectrumChartOptions,
                                         Logger logger) : base(serviceProvider, spectrumChartOptions, logger)
        {
            init();
        }
+22 −10
Original line number Diff line number Diff line
using INAF.Apps.Uwp.SLabDataManager.Models;
using INAF.Apps.Uwp.Charts;
using INAF.Apps.Uwp.SLabDataManager.Models;
using INAF.Libraries.Uwp.Logging;
using Microsoft.Extensions.DependencyInjection;
using System;
@@ -6,7 +7,6 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
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;

@@ -15,9 +15,28 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
    public class SpectraContainer : SpectraContainerBase
    {
        public SpectraContainer(IServiceProvider serviceProvider,
                                Logger logger) : base(serviceProvider, logger)
                                SpectrumChartOptionsModel spectrumChartOptions,
                                Logger logger) : base(serviceProvider, spectrumChartOptions, logger)
        {
            init();

            spectrumChartOptions.PropertyChanged += SpectrumChartOptions_PropertyChanged;
        }

        private async void SpectrumChartOptions_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals(nameof(spectrumChartOptions.SelectedWavelengthMeasureUnit)))
            {
                IsWorkInProgress = true;

                switchXAxisMeasureUnit(spectrumChartOptions.SelectedWavelengthMeasureUnit);

                await Task.Delay(TimeSpan.FromMilliseconds(300));
                SpectrumAlignmentConfig.switchToMeasureUnit(spectrumChartOptions.SelectedWavelengthMeasureUnit);
                SelectedRefBand.switchToMeasureUnit(spectrumChartOptions.SelectedWavelengthMeasureUnit);

                IsWorkInProgress = false;
            }
        }

        public SelectedRefBand SelectedRefBand { get; protected set; }
@@ -158,13 +177,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
            Summaries = new ObservableCollection<SpectrumSummaryModel>();
        }

        public void switchXAxisMeasureUnit(WavelengthMeasureUnit wavelengthMeasureUnit)
        {
            Spectra.All(x => { x.switchToMeasureUnit(wavelengthMeasureUnit); return true; });
            XAxisBoundaries.switchToMeasureUnit(wavelengthMeasureUnit);
            //setXAxisMajorStep(wavelengthMeasureUnit);
        }

        protected void addSpectrum(SpectrumModel spectrum)
        {
            Spectra.Add(spectrum);
+31 −6
Original line number Diff line number Diff line
using INAF.Apps.Uwp.SLabDataManager.Helpers;
using INAF.Apps.Uwp.Charts;
using INAF.Apps.Uwp.SLabDataManager.Helpers;
using INAF.Apps.Uwp.SLabDataManager.Models;
using INAF.Libraries.NetStandard.ScienceModels.Extensions;
using INAF.Libraries.NetStandard.ScienceModels.Spectra;
@@ -9,6 +10,7 @@ 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;

namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
@@ -16,12 +18,15 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
    public class SpectraContainerBase : ObservableObject, ISpectraContainer
    {
        protected readonly IServiceProvider serviceProvider;
        protected readonly SpectrumChartOptionsModel spectrumChartOptions;
        protected readonly Logger logger;

        public SpectraContainerBase(IServiceProvider serviceProvider,
                                    SpectrumChartOptionsModel spectrumChartOptions,
                                    Logger logger)
        {
            this.serviceProvider = serviceProvider;
            this.spectrumChartOptions = spectrumChartOptions;
            this.logger = logger;
        }

@@ -73,6 +78,13 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
            }
        }

        private bool isWorkInProgress;
        public bool IsWorkInProgress
        {
            get { return isWorkInProgress; }
            set { SetProperty(ref isWorkInProgress, value); }
        }

        public string YAxisTitle { get; protected set; }

        protected ObservableCollection<SpectrumSummaryModel> summaries;
@@ -151,6 +163,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
        }
        #endregion

        public virtual Task addOrUpdateSpectrumAsync(SpectrumModel spectrum)
        {
            throw new NotImplementedException();
        }

        public async Task<(double xMin, double xMax, double yMin, double yMax)> getSpectraAxesBoundariesAsync()
        {
            List<Task> tasks = new List<Task>();
@@ -234,6 +251,19 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
            YAxisTitle = title;
        }

        protected void switchXAxisMeasureUnit(WavelengthMeasureUnit wavelengthMeasureUnit)
        {
            try
            {
                Spectra.All(x => { x.switchToMeasureUnit(wavelengthMeasureUnit); return true; });
                XAxisBoundaries.switchToMeasureUnit(wavelengthMeasureUnit);
            }
            catch (Exception ex)
            {
                logger.Write<SpectraContainerBase>($"{nameof(switchXAxisMeasureUnit)} - ex: {ex.Message}", Serilog.Events.LogEventLevel.Error);
            }
        }

        public async Task updateBoundariesAsync()
        {
            (double xMin, double xMax, double yMin, double yMax) result = await getSpectraAxesBoundariesAsync();
@@ -247,10 +277,5 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
            XAxisBoundaries.updateAxisBoundaries(xMin, xMax);
            YAxisBoundaries.updateAxisBoundaries(yMin, yMax);
        }

        public virtual Task addOrUpdateSpectrumAsync(SpectrumModel spectrum)
        {
            throw new NotImplementedException();
        }
    }
}
+36 −15
Original line number Diff line number Diff line
using INAF.Apps.Uwp.SLabDataManager.Helpers;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using INAF.Apps.Uwp.Charts;
using INAF.Apps.Uwp.SLabDataManager.Helpers;
using INAF.Libraries.NetStandard.Extensions;
using INAF.Libraries.NetStandard.ScienceModels.Extensions;
using INAF.Libraries.NetStandard.ScienceModels.Spectra;
using INAF.Libraries.Uwp.Settings;
using static INAF.Libraries.NetStandard.ScienceModels.Enums.Enums;

namespace INAF.Apps.Uwp.SLabDataManager.Charts
{
    public sealed class SelectedRefBand : ObservableObject
    public sealed class SelectedRefBand : BaseValueModel
    {
        private readonly SettingsHelper settingsHelper;
        private readonly SpectrumChartOptionsModel spectrumChartOptions;

        public SelectedRefBand(SettingsHelper settingsHelper)
        public SelectedRefBand(SettingsHelper settingsHelper,
                               SpectrumChartOptionsModel spectrumChartOptions)
        {
            this.settingsHelper = settingsHelper;
            this.spectrumChartOptions = spectrumChartOptions;

            MeasureUnit = spectrumChartOptions.SelectedWavelengthMeasureUnit;

            if (!tryReadXMin())
                xMin = 0d;
@@ -19,6 +27,9 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            if (!tryReadXMax())
                xMax = 0d;

            /* switch xmin/xmax to selected wavelength measure unit, if required */
            switchToMeasureUnit(MeasureUnit);

            trySetBoundariesRelatedValues();
        }

@@ -29,7 +40,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
        public string SelectedSegmentText
        {
            get { return selectedSegmentText; }
            private set { SetProperty(ref selectedSegmentText, value); }
            private set
            {
                selectedSegmentText = value;
                RaisePropertyChanged(nameof(SelectedSegmentText));
            }
        }

        private double xMax;
@@ -38,13 +53,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            get { return xMax; }
            private set
            {
                if (SetProperty(ref xMax, value))
                {
                xMax = value;
                RaisePropertyChanged(nameof(XMax));
                saveXMax(value);
                trySetBoundariesRelatedValues();
            }
        }
        }

        private double xMin;
        public double XMin
@@ -52,13 +66,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            get { return xMin; }
            private set
            {
                if (SetProperty(ref xMin, value))
                {
                xMin = value;
                RaisePropertyChanged(nameof(XMin));
                saveXMin(value);
                trySetBoundariesRelatedValues();
            }
        }
        }
        #endregion

        #region save/read settings
@@ -109,6 +122,14 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            trySetBoundariesRelatedValues();
        }

        public void switchToMeasureUnit(WavelengthMeasureUnit newMeasureUnit)
        {
            XMax = XMax.ToWavelengthMeasureUnitValue(MeasureUnit, newMeasureUnit);
            XMin = XMin.ToWavelengthMeasureUnitValue(MeasureUnit, newMeasureUnit);

            MeasureUnit = newMeasureUnit;
        }

        private void trySetBoundariesRelatedValues()
        {
            if (XMin != 0 && XMax != 0)
Loading