Commit 5f82c9e1 authored by Francesco Carraro's avatar Francesco Carraro
Browse files

fixing behavior of save/delete/open/close of panels

parent 02be8041
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ namespace INAF.Apps.Uwp.SLabDataManager

        public static Dictionary<string, object> AppDictionary;
        public static Dictionary<UIContext, AppWindow> AppWindows;
        public static bool IsFirstRawFileReading;

        private ActivationService ActivationService
        {
@@ -110,6 +111,8 @@ namespace INAF.Apps.Uwp.SLabDataManager

        private void initServices()
        {
            IsFirstRawFileReading = true;

            /* create app dictionary shared across all app */
            AppDictionary = new Dictionary<string, object>();

@@ -147,11 +150,6 @@ namespace INAF.Apps.Uwp.SLabDataManager
                .AddSingleton<WorkingItemsModel>()
                /* scoped */
                .AddScoped<ActionQuestionViewModel>()
                .AddScoped<AlignmentViewModel>()
                .AddScoped<MeasurementInfoViewModel>()
                .AddScoped<SampleDataViewModel>()
                .AddScoped<SegmentsFitViewModel>()
                .AddScoped<SmoothingViewModel>()
                .AddScoped<StorageItemsHelper>()
                /* transient */
                .AddTransient<AnimationsHelper>()
@@ -172,6 +170,13 @@ namespace INAF.Apps.Uwp.SLabDataManager
                .AddTransient<SplineFitHelper>()
                .AddTransient<ZoomHelper>()
                .AddTransient<XmlHelper>()
                /* usercontrols viewmodels */
                .AddScoped<AlignmentViewModel>()
                .AddScoped<MeasurementInfoViewModel>()
                .AddScoped<SampleDataViewModel>()
                .AddSingleton<SegmentsFitViewModel>()
                .AddScoped<SmoothingViewModel>()
                .AddSingleton<UserControlsViewModelFactory>()
                /* view models */
                .AddSingleton<ChartViewModel>()
                .AddSingleton<ContinuumAnalysisViewModel>()
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers

        public SpectrumType SelectedSpectrumType { get; protected set; }

        #region spectra
        #region spectra methods
        public override async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum)
        {
            if (isAnySummaryOfType(spectrum.Type))
+19 −0
Original line number Diff line number Diff line
@@ -60,6 +60,13 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
            set { SetProperty(ref isAnySpectrumLoaded, value); }
        }

        private bool isAnySpectrumLoadedOrRemoved;
        public bool IsAnySpectrumLoadedOrRemoved
        {
            get { return isAnySpectrumLoadedOrRemoved; }
            set { SetProperty(ref isAnySpectrumLoadedOrRemoved, value); }
        }

        protected bool isAnySpectrumRemoved;
        public bool IsAnySpectrumRemoved
        {
@@ -134,12 +141,22 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
        {
            IsAnySpectrumLoaded = true;
            isAnySpectrumLoaded = false;// trick to enable for the next added spectrum

            raiseIsAnySpectrumLoadedOrRemoved();
        }

        public void raiseIsAnySpectrumLoadedOrRemoved()
        {
            IsAnySpectrumLoadedOrRemoved = true;
            isAnySpectrumLoadedOrRemoved = false;
        }

        public void raiseIsAnySpectrumRemoved()
        {
            IsAnySpectrumRemoved = true;
            isAnySpectrumRemoved = false;// trick to enable for the next added spectrum

            raiseIsAnySpectrumLoadedOrRemoved();
        }

        public void raiseIsAnySpectrumUpdated()
@@ -232,6 +249,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
        public virtual void init()
        {
            IsAnySpectrumLoaded = false;
            IsAnySpectrumLoadedOrRemoved = false;
            IsAnySpectrumRemoved = false;

            XAxisMajorStepValues = new List<double>(2);
            XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_0DOT1);
+0 −51
Original line number Diff line number Diff line
@@ -232,57 +232,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters
        }
    }

    public sealed class SmoothedSpectrumCreatedConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            try
            {
                bool isEnableButtonRequested = System.Convert.ToBoolean(value);

                SpectrumType destSpectrumType = ((string)parameter).ToSpectrumType();

                SpectraContainer spectraContainer = Ioc.Default.GetService<SpectraContainer>();

                return isEnableButtonRequested && spectraContainer.isAnySpectrumOfType(destSpectrumType);
            }
            catch (Exception)
            {
                return Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }


    public sealed class SmoothingButtonVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            try
            {
                SpectraContainer spectraContainer = Ioc.Default.GetService<WorkingItemsModel>().SpectraContainer;
                if (spectraContainer.isAnySpectrumOfType(SpectrumType.Aligned) || spectraContainer.isAnySpectrumOfType(SpectrumType.ContinuumRemoved))
                    return Visibility.Visible;
                else
                    return Visibility.Collapsed;
            }
            catch (Exception)
            {
                return Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }

    public sealed class SpectrumTypeDescriptionConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
+73 −9
Original line number Diff line number Diff line
@@ -3,6 +3,9 @@ using INAF.Apps.Uwp.SLabDataManager.Charts.Containers;
using INAF.Apps.Uwp.SLabDataManager.Models;
using INAF.Libraries.NetStandard.ScienceModels.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums;
using SpectrumModel = INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel;
@@ -15,20 +18,81 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters
        {
            try
            {
                string _spectrumType = (string)parameter;
                SpectrumType spectrumType = _spectrumType.ToSpectrumType();
                List<string> spectrumTypes = null;

                string _parameter = (string)parameter;
                if (_parameter.Contains("+"))
                {
                    spectrumTypes = _parameter.Split("+").ToList();
                }
                else
                {
                    spectrumTypes = new List<string>();
                    spectrumTypes.Add((string)parameter);
                }

                SpectraContainer spectraContainer = Ioc.Default.GetService<WorkingItemsModel>().SpectraContainer;
                return spectraContainer.isAnySpectrumOfType(spectrumType);
                //SpectrumModel spectrum = spectraContainer.tryGetSpectrumOfType(spectrumType);
                //if (spectrum != null)
                //    return true;
                //else
                //    return false;
                bool isSpectrumFound = false;

                foreach (string spectrumType in spectrumTypes)
                {
                    if (spectraContainer.isAnySpectrumOfType(spectrumType.ToSpectrumType()))
                    {
                        isSpectrumFound = true;
                        break;
                    }
                }

                return isSpectrumFound;
            }
            catch (Exception)
            {
                return string.Empty;
                return false;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }

    public sealed class IsAnySpectrumOfTypeVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            try
            {
                List<string> spectrumTypes = null;

                string _parameter = (string)parameter;
                if (_parameter.Contains("+"))
                {
                    spectrumTypes = _parameter.Split("+").ToList();
                }
                else
                {
                    spectrumTypes = new List<string>();
                    spectrumTypes.Add((string)parameter);
                }

                SpectraContainer spectraContainer = Ioc.Default.GetService<WorkingItemsModel>().SpectraContainer;
                bool isSpectrumFound = false;

                foreach (string spectrumType in spectrumTypes)
                {
                    if (spectraContainer.isAnySpectrumOfType(spectrumType.ToSpectrumType()))
                    {
                        isSpectrumFound = true;
                        break;
                    }
                }

                return (isSpectrumFound ? Visibility.Visible : Visibility.Collapsed);
            }
            catch (Exception)
            {
                return Visibility.Collapsed;
            }
        }

Loading