Commit 1d354140 authored by Francesco Carraro's avatar Francesco Carraro
Browse files

fixed app cleaning when opened a different RAW file

parent 1e340c75
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI
    public class AnimationsHelper
    {
        private static readonly int TO = -20;
        public static readonly int ANIMATION_DURATION_MS = 300;

        public static Storyboard GetExpandWidthStoryboard(FrameworkElement frameworkElement,
                                                          double refWidth)
@@ -34,7 +35,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI
            {
                From = frameworkElement.Width,
                To = destWidth,
                Duration = TimeSpan.FromMilliseconds(300),
                Duration = TimeSpan.FromMilliseconds(ANIMATION_DURATION_MS),
                EnableDependentAnimation = true,
                EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
            };
@@ -53,7 +54,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI
            {
                From = from,
                To = TO,
                Duration = TimeSpan.FromMilliseconds(300),
                Duration = TimeSpan.FromMilliseconds(ANIMATION_DURATION_MS),
                EnableDependentAnimation = true,
                EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn }
            };
@@ -72,7 +73,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI
            {
                From = TO,
                To = to,
                Duration = TimeSpan.FromMilliseconds(300),
                Duration = TimeSpan.FromMilliseconds(ANIMATION_DURATION_MS),
                EnableDependentAnimation = true,
                EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
            };
+26 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI

        public int UserControlsNum { get { return UserControls.Count; } }

        public List<string> UserControlsToBeClosed { get; private set; }

        #endregion

        #region methods
@@ -115,6 +117,30 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI
            /* set visibility of each tabViewItem */
            raiseIsAnyUserControlAddedOrRemoved();
        }

        #region usercontrols to be closed
        public void addUserControlToBeClosed(string userControlName)
        {
            if (UserControlsToBeClosed.Any(x => x.Equals(userControlName)))
                return;

            /* add usercontrol to collection */
            UserControlsToBeClosed.Add(userControlName);
        }

        public bool areUserControleToBeClosedAvailable()
        {
            return UserControlsToBeClosed.Any();
        }

        public void initUserControlsToBeClosed()
        {
            if (UserControlsToBeClosed == null)
                UserControlsToBeClosed = new List<string>();
            else
                UserControlsToBeClosed.Clear();
        }
        #endregion
        #endregion
    }
}
+2 −5
Original line number Diff line number Diff line
@@ -708,11 +708,8 @@
  <data name="SmoothingButtonLabel.Text" xml:space="preserve">
    <value>Open smoothing panel</value>
  </data>
  <data name="SmoothingComboBox.Header" xml:space="preserve">
    <value>Available spectra types</value>
  </data>
  <data name="SmoothingComboBox.PlaceholderText" xml:space="preserve">
    <value>Select spectrum type</value>
  <data name="SmoothingSelectedTargetSpectrumTypeLabel.Text" xml:space="preserve">
    <value>Target spectrum type</value>
  </data>
  <data name="SmoothingTitle.Text" xml:space="preserve">
    <value>Smoothing</value>
+15 −3
Original line number Diff line number Diff line
@@ -327,8 +327,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels

        public async Task deleteDerivedSpectraAsync()
        {
            UserControlsHelper.initUserControlsToBeClosed();

            foreach (SpectrumType spectrumType in Enum.GetValues(typeof(SpectrumType)))
            {
                System.Diagnostics.Debug.WriteLine($"closing {spectrumType.ToString()}...");
                if (spectrumType == SpectrumType.Ref || spectrumType == SpectrumType.RefWhite)
                    continue;

@@ -344,7 +347,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels
                        /* set toggleSwitch for adding points for fitting continuum to 'off' */
                        ContinuumRemovalHelper.IsAddingPointsForContinuumRemovalAllowed = false;
                        /* hide panel for creating continuum */
                        raiseUserControlClosing(nameof(AlignmentConfigUserControl).FirstCharToLowerCase());
                        if (UserControlsHelper.containsUserControl(nameof(AlignmentConfigUserControl).FirstCharToLowerCase()))
                            UserControlsHelper.addUserControlToBeClosed(nameof(AlignmentConfigUserControl).FirstCharToLowerCase());
                        break;

                    case SpectrumType.AlignedSmoothedBySegments:
@@ -352,7 +356,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels
                    case SpectrumType.ContinuumRemovedSmoothedBySegments:
                    case SpectrumType.ContinuumRemovedSmoothed:
                        /* hide panel for creating continuum */
                        raiseUserControlClosing(nameof(SmoothingUserControl).FirstCharToLowerCase());
                        if (UserControlsHelper.containsUserControl(nameof(SmoothingUserControl).FirstCharToLowerCase()))
                            UserControlsHelper.addUserControlToBeClosed(nameof(SmoothingUserControl).FirstCharToLowerCase());
                        break;
                    case SpectrumType.Continuum:
                        break;
@@ -360,7 +365,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels
                        /* remove all points and segments for creating continuum */
                        await clearSegmentsFitAndContinuumSpectraAsync();
                        /* hide panel for creating continuum */
                        raiseUserControlClosing(nameof(SegmentsFitUserControl).FirstCharToLowerCase());
                        if (UserControlsHelper.containsUserControl(nameof(SegmentsFitUserControl).FirstCharToLowerCase()))
                            UserControlsHelper.addUserControlToBeClosed(nameof(SegmentsFitUserControl).FirstCharToLowerCase());
                        break;
                    default:
                        break;
@@ -833,7 +839,13 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels

            if (string.IsNullOrEmpty(result.DialogMessage))
            {
                /* add continuum-removed spectrum */
                await WorkingItems.SpectraContainer.addOrUpdateSpectrumAsync(result.Spectrum);

                /* update target spectrum type for smoothing, if panel is already opened */
                SmoothingViewModel.selectTargetSpectrumType();

                /* show success message */
                showInfoBar(Microsoft.UI.Xaml.Controls.InfoBarSeverity.Informational,
                            "ContinuumRemovalTitle".GetText(),
                            "ContinuumRemovalSuccess".GetText(),
+6 −13
Original line number Diff line number Diff line
@@ -79,15 +79,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels.UserControlViewModels
            get { return spectrumSmoothingBoundariesItem; }
            private set { SetProperty(ref spectrumSmoothingBoundariesItem, value); }
        }

        private SpectrumType[] targetSpectraTypes { get; set; }
        #endregion

        #region methods
        private void init()
        {
            targetSpectraTypes = new SpectrumType[] { SpectrumType.Aligned, SpectrumType.ContinuumRemoved };

            SelectedSpectrumType = SpectrumType.None;

            IsDeleteSmoothingBySegmentsAllowed = false;
@@ -96,7 +92,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels.UserControlViewModels

        public async Task initAsync()
        {
            initAvailableSpectraTypes();
            selectTargetSpectrumType();

            /* read default boundary values */
            SmoothingDefaultBoundariesReader reader = serviceProvider.GetRequiredService<SmoothingDefaultBoundariesReader>();
@@ -117,15 +113,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels.UserControlViewModels
            SpectrumSmoothingBoundariesItem.All(x => { x.PropertyChanged += X_PropertyChanged; return true; });
        }

        private void initAvailableSpectraTypes()
        public void selectTargetSpectrumType()
        {
            AvailableSpectraTypes = new ObservableCollection<SpectrumType>();

            foreach (var type in targetSpectraTypes)
            {
                if (spectraContainer.isAnySpectrumOfType(type))
                    AvailableSpectraTypes.Add(type);
            }
            if (spectraContainer.isAnySpectrumOfType(SpectrumType.ContinuumRemoved))
                SelectedSpectrumType = SpectrumType.ContinuumRemoved;
            else if (spectraContainer.isAnySpectrumOfType(SpectrumType.Aligned))
                SelectedSpectrumType = SpectrumType.Aligned;
        }

        public void setIsDeleteSmoothingBySegmentsAllowed()
Loading