Commit 4f9d6761 authored by Francesco Carraro's avatar Francesco Carraro
Browse files

added saving of ref segment for alignment

parent 200879f4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ namespace INAF.Apps.Uwp.SLabDataManager
            Ioc.Default.ConfigureServices(
                new ServiceCollection()
                /* singletons */
                .AddSingleton<SelectedRefBand>()
                .AddSingleton<SpectrumAlignmentConfigModel>()
                .AddSingleton<SpectrumChartOptionsModel>()
                .AddSingleton<Logger>(logger)
+63 −9
Original line number Diff line number Diff line
using INAF.Apps.Uwp.SLabDataManager.Helpers;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using INAF.Libraries.NetStandard.Extensions;
using INAF.Libraries.Uwp.Settings;

namespace INAF.Apps.Uwp.SLabDataManager.Charts
{
    public sealed class SelectedRefBand : ObservableObject
    {
        public SelectedRefBand()
        private readonly SettingsHelper settingsHelper;

        public SelectedRefBand(SettingsHelper settingsHelper)
        {
            XMin = 0d;
            XMax = 0d;
            this.settingsHelper = settingsHelper;

            if (!tryReadXMin())
                xMin = 0d;

            if (!tryReadXMax())
                xMax = 0d;

            IsReady = false;
        }
@@ -30,11 +38,14 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            get { return xMax; }
            private set
            {
                SetProperty(ref xMax, value);
                if (SetProperty(ref xMax, value))
                {
                    saveXMax(value);
                    if (XMin != 0 && XMax != 0)
                        IsReady = true;
                }
            }
        }

        private double xMin;
        public double XMin
@@ -42,11 +53,54 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            get { return xMin; }
            private set
            {
                SetProperty(ref xMin, value);
                if (SetProperty(ref xMin, value))
                {
                    saveXMin(value);
                    if (XMin != 0 && XMax != 0)
                        IsReady = true;
                }
            }
        }
        #endregion

        #region save/read settings
        private void saveXMax(double xMax)
        {
            settingsHelper.save(Constants.Constants.SELECTED_REF_BAND_XMAX, xMax.ToString());
        }

        private void saveXMin(double xMin)
        {
            settingsHelper.save(Constants.Constants.SELECTED_REF_BAND_XMIN, xMin.ToString());
        }

        public bool tryReadXMax()
        {
            bool isFound = false;

            string value = settingsHelper.get(Constants.Constants.SELECTED_REF_BAND_XMAX);
            if (!string.IsNullOrEmpty(value))
            {
                xMax = value.ToDoubleInvariant();
                isFound = true;
            }

            return isFound;
        }

        public bool tryReadXMin()
        {
            bool isFound = false;

            string value = settingsHelper.get(Constants.Constants.SELECTED_REF_BAND_XMIN);
            if (!string.IsNullOrEmpty(value))
            {
                xMin = value.ToDoubleInvariant();
                isFound = true;
            }

            return isFound;
        }
        #endregion

        public void setBoundaries(double xMin, double xMax)
+3 −1
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts

            SpectrumAlignmentConfig = serviceProvider.GetRequiredService<SpectrumAlignmentConfigModel>();

            SelectedRefBand = serviceProvider.GetRequiredService<SelectedRefBand>();

            Spectra = new ObservableCollection<SpectrumModel>();

            XAxisMajorStepValues = new List<double>(2);
@@ -40,7 +42,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            set { SetProperty(ref isError, value); }
        }

        public SelectedRefBand SelectedRefBand { get; private set; } = new SelectedRefBand();
        public SelectedRefBand SelectedRefBand { get; private set; }

        private ObservableCollection<SpectrumModel> spectra;
        public ObservableCollection<SpectrumModel> Spectra
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@
        public static readonly string ARE_SEPARATORS_VISIBLE = "areseparatorsvisible";
        public static readonly string NUM_OF_POINTS_FOR_ALIGNMENT = "numofpointsforalignment";

        public static readonly string SELECTED_REF_BAND_XMAX = "selectedrefbandxmax";
        public static readonly string SELECTED_REF_BAND_XMIN = "selectedrefbandxmin";

        public static readonly string INPUT_RAW_SPECTRA_FOLDER = "inputrawspectrafolder";
        public static readonly string INPUT_RAW_SPECTRA_FOLDER_TOKEN = "inputrawspectrafoldertoken";
        public static readonly string OUTPUT_SPECTRA_FOLDER = "outputspectrafolder";