Loading INAF.Apps.Uwp.SLabDataManager/Converters/SpectraConverters.cs +27 −0 Original line number Diff line number Diff line using CommunityToolkit.Mvvm.DependencyInjection; using INAF.Apps.Uwp.SLabDataManager.Charts.Containers; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Apps.Uwp.SLabDataManager.ViewModels.UserControlViewModels; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using System; using System.Collections.Generic; Loading Loading @@ -147,6 +148,32 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters } } public sealed class IsSpectrumOfTypeSelectedSmoothedConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { var smoothingViewModel = Ioc.Default.GetRequiredService<SmoothingViewModel>(); var spectraContainer = Ioc.Default.GetService<WorkingItemsModel>().SpectraContainer; var destSpectrumType = smoothingViewModel.getDestSpectrumType(smoothingViewModel.SelectedSpectrumType); return spectraContainer.isAnySpectrumOfType(destSpectrumType); } catch (Exception) { return false; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class IsSpectrumSavedOnCloudConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) Loading INAF.Apps.Uwp.SLabDataManager/Helpers/UI/XamlHelpers.cs +0 −10 Original line number Diff line number Diff line Loading @@ -2,11 +2,7 @@ using INAF.Apps.Uwp.SLabDataManager.Charts.Containers; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Apps.Uwp.SLabDataManager.Models.Spectrum; using INAF.Apps.Uwp.SLabDataManager.ViewModels; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI Loading Loading @@ -55,12 +51,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI return spectraContainer.isAnySpectrumOfType(type.ToSpectrumType()); } public static SolidColorBrush IsSaveAsCopyEnabled() { var segmentsFitViewModel = Ioc.Default.GetRequiredService<ChartViewModel>().SegmentsFitViewModel; return (segmentsFitViewModel.IsSaveAsCopyAllowed ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.LightGray)); } public static bool IsSaveOnCloudPermissionDenied() { var permissionHelper = Ioc.Default.GetRequiredService<PermissionsHelper>(); Loading INAF.Apps.Uwp.SLabDataManager/Styles/Custom.xaml +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ <converters:IsAnySpectrumOfTypeConverter x:Key="IsAnySpectrumOfTypeConverter" /> <converters:IsAnySpectrumOfTypeVisibilityConverter x:Key="IsAnySpectrumOfTypeVisibilityConverter" /> <converters:IsSpectrumAvailablelWithParameterConverter x:Key="IsSpectrumAvailablelWithParameterConverter" /> <converters:IsSpectrumOfTypeSelectedSmoothedConverter x:Key="IsSpectrumOfTypeSelectedSmoothedConverter" /> <converters:IsSpectrumSavedOnCloudConverter x:Key="IsSpectrumSavedOnCloudConverter" /> <converters:IsUserControlAvailableConverter x:Key="IsUserControlAvailableConverter" /> <converters:HalfWidthConverter x:Key="HalfWidthConverter" /> Loading INAF.Apps.Uwp.SLabDataManager/ViewModels/ChartBaseViewModel.cs +4 −2 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ using INAF.Libraries.Uwp.StorageItemsAccess; using Microsoft.Extensions.DependencyInjection; using System; using System.Threading.Tasks; using Windows.Storage; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums; Loading Loading @@ -142,7 +143,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels #region save local file protected async Task saveSpectrumOfTypeLocalAsync(SpectrumType spectrumType, FileExt fileExt) FileExt fileExt, CreationCollisionOption creationCollisionOption = CreationCollisionOption.ReplaceExisting) { /* raise error message if no aligned spectrum existing */ if (!WorkingItems.SpectraContainer.isAnySpectrumOfType(spectrumType)) Loading @@ -157,7 +159,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels if (await isOutputFolderDefinedAsync()) { var userControlsViewModelFactory = serviceProvider.GetRequiredService<UserControlsViewModelFactory>(); (bool isOk, string exMsg) saveLocalFileResult = await userControlsViewModelFactory.createUserControlViewModel().saveSpectrumOfTypeAsLocalFileAsync(spectrumType, fileExt); (bool isOk, string exMsg) saveLocalFileResult = await userControlsViewModelFactory.createUserControlViewModel().saveSpectrumOfTypeAsLocalFileAsync(spectrumType, fileExt, creationCollisionOption); if (!saveLocalFileResult.isOk) showDialogMessage(saveLocalFileResult.exMsg, DialogMessageType.Warning); } Loading INAF.Apps.Uwp.SLabDataManager/ViewModels/ChartViewModelSegmentsFit.cs +32 −66 Original line number Diff line number Diff line using CommunityToolkit.Mvvm.Input; using INAF.Apps.Uwp.SLabDataManager.Extensions; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations; using INAF.Apps.Uwp.SLabDataManager.Models.Fit; using INAF.Apps.Uwp.SLabDataManager.Models.Processing; using INAF.Apps.Uwp.SLabDataManager.Views.UserControls; using INAF.Libraries.NetStandard.Extensions; using INAF.Libraries.NetStandard.ScienceModels.Spectra; using INAF.Libraries.NetStandard.SLabCommonModels.Models.WebApp.Requests; using INAF.Libraries.NetStandard.SLabCommonModels.Models.WebApp.Requests.SaveSpectrum; using INAF.Libraries.NetStandard.SLabCommonModels.Models.WebApp.Responses; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Windows.Storage; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums; Loading Loading @@ -68,7 +63,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels private async Task clearSegmentsFitAsync(bool isAskDeleteContinuumRemovedSpectrumRequired = true) { /* remove all items in left-panel with data about segments fit */ SegmentsFitViewModel?.clear(); SegmentsFitViewModel?.init(); SegmentsFitViewModel.raiseIsPointsRemovalRequired(); /* remove continuum spectrum */ Loading Loading @@ -174,37 +169,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels SegmentsFitViewModel.raiseIsSegmentsLowlightRequired(); } //private async Task showContinuumRemovedResultAsync() //{ // ProcessingResult result = ContinuumRemovalHelper.ProcessingResult; // IsLoading = false; // if (result == null) // return; // /* disable focus on aligned+continuum */ // raiseIsDisableFitFocusRequired(); // 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 */ // await initSmoothingViewModelAsync(); // SmoothingViewModel.selectTargetSpectrumType(); // /* show success message */ // showInfoBar(Microsoft.UI.Xaml.Controls.InfoBarSeverity.Informational, // "ContinuumRemovalTitle".GetText(), // "ContinuumRemovalSuccess".GetText(), // autoHide: true); // } // else // showDialogMessage(result.DialogMessage); //} public void trySetIsContinuumRemovalEnabled() { if (WorkingItems.SpectraContainer.isAnySpectrumOfType(SpectrumType.Raw) && isContinuumSpectrumCompleted()) Loading Loading @@ -246,40 +210,24 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels #endregion #region save private async Task saveSpectrumOfTypeContinuumRemovedAsync(SaveFileOperationType saveFileOperationType) { /* raise error message if no aligned spectrum existing */ if (!WorkingItems.SpectraContainer.isAnySpectrumOfType(SpectrumType.ContinuumRemoved)) private async Task saveSpectrumOfTypeContinuumRemovedCloudAndLocalAsync(FileExt fileExt, CreationCollisionOption creationCollisionOption) { showDialogMessage("ContinuumRemovalNotExecutedErrorMessage".GetText()); /* if 'save as copy' has been called but function is not allowed, then return */ if (creationCollisionOption == CreationCollisionOption.GenerateUniqueName && !SegmentsFitViewModel.IsSaveAsCopyAllowed) return; } IsLoading = true; /* save aligned spectrum locally, in a local folder */ if (await isOutputFolderDefinedAsync()) { /* determine whether replace or create new version of local file */ Windows.Storage.CreationCollisionOption creationCollisionOption = Windows.Storage.CreationCollisionOption.ReplaceExisting; if (saveFileOperationType == SaveFileOperationType.SaveAsCopy) creationCollisionOption = Windows.Storage.CreationCollisionOption.GenerateUniqueName; /* save spectrum locally */ await saveSpectrumOfTypeLocalAsync(SpectrumType.ContinuumRemoved, fileExt, creationCollisionOption); (bool isOk, string exMsg) saveLocalFileResult = await SegmentsFitViewModel.saveSpectrumOfTypeAsLocalFileAsync(SpectrumType.ContinuumRemoved, FileExt.Txt, creationCollisionOption); if (!saveLocalFileResult.isOk) showDialogMessage(saveLocalFileResult.exMsg, DialogMessageType.Warning); } else showDialogMessage("SaveSpectrumLocalOutputFolderNotDefinedMessage".GetText(), DialogMessageType.Warning); SegmentsFitViewModel.tryRaiseIsSaveAsCopyAllowed(); //SegmentsFitViewModel.IsSaveAsCopyAllowed = true; /* if no permission to save/delete on cloud is granted, then return */ if (getPermissionsHelper().isSaveOnCloudFromAppAllowed()) { /* determine whether replace or create new version on cloud */ RemoteOperationType remoteOperationType = RemoteOperationType.SaveSpectrumOfTypeContinuumRemoved; if (saveFileOperationType == SaveFileOperationType.SaveAsCopy) if (creationCollisionOption == CreationCollisionOption.GenerateUniqueName) remoteOperationType = RemoteOperationType.SaveAsCopySpectrumOfTypeContinuumRemoved; /* save continuum-removed spectrum on cloud */ Loading Loading @@ -322,6 +270,18 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels "ContinuumSpectrumSavedSuccessfullyMessage".GetText(), autoHide: true); } private async Task saveSpectrumOfTypeContinuumRemovedLocalAsync(FileExt fileExt, CreationCollisionOption creationCollisionOption) { /* if 'save as copy' has been called but function is not allowed, then return */ if (creationCollisionOption == CreationCollisionOption.GenerateUniqueName && !SegmentsFitViewModel.IsSaveAsCopyAllowed) return; /* save spectrum locally */ await saveSpectrumOfTypeLocalAsync(SpectrumType.ContinuumRemoved, fileExt, creationCollisionOption); SegmentsFitViewModel.tryRaiseIsSaveAsCopyAllowed(); } #endregion #region segments-fit panel Loading Loading @@ -380,11 +340,17 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels private RelayCommand commandExecuteContinuumRemoval; public RelayCommand CommandExecuteContinuumRemoval => commandExecuteContinuumRemoval ?? (commandExecuteContinuumRemoval = new RelayCommand(() => executeContinuumRemovalProcedurePart1())); private RelayCommand commandSaveContinuumRemovedSpectrum; public RelayCommand CommandSaveContinuumRemovedSpectrum => commandSaveContinuumRemovedSpectrum ?? (commandSaveContinuumRemovedSpectrum = new RelayCommand(() => saveSpectrumOfTypeContinuumRemovedAsync(SaveFileOperationType.ReplaceExisting))); private RelayCommand<FileExt> commandSaveAsCopyContinuumRemovedCoudAndLocal; public RelayCommand<FileExt> CommandSaveAsCopyContinuumRemovedCoudAndLocal => commandSaveAsCopyContinuumRemovedCoudAndLocal ?? (commandSaveAsCopyContinuumRemovedCoudAndLocal = new RelayCommand<FileExt>((fileExt) => saveSpectrumOfTypeContinuumRemovedCloudAndLocalAsync(fileExt, CreationCollisionOption.GenerateUniqueName))); private RelayCommand<FileExt> commandSaveAsCopyContinuumRemovedLocal; public RelayCommand<FileExt> CommandSaveAsCopyContinuumRemovedLocal => commandSaveAsCopyContinuumRemovedLocal ?? (commandSaveAsCopyContinuumRemovedLocal = new RelayCommand<FileExt>((fileExt) => saveSpectrumOfTypeContinuumRemovedLocalAsync(fileExt, CreationCollisionOption.GenerateUniqueName))); private RelayCommand<FileExt> commandSaveContinuumRemovedCoudAndLocal; public RelayCommand<FileExt> CommandSaveContinuumRemovedCoudAndLocal => commandSaveContinuumRemovedCoudAndLocal ?? (commandSaveContinuumRemovedCoudAndLocal = new RelayCommand<FileExt>((fileExt) => saveSpectrumOfTypeContinuumRemovedCloudAndLocalAsync(fileExt, CreationCollisionOption.ReplaceExisting))); private RelayCommand commandSaveAsCopyContinuumRemovedSpectrum; public RelayCommand CommandSaveAsCopyContinuumRemovedSpectrum => commandSaveAsCopyContinuumRemovedSpectrum ?? (commandSaveAsCopyContinuumRemovedSpectrum = new RelayCommand(() => saveSpectrumOfTypeContinuumRemovedAsync(SaveFileOperationType.SaveAsCopy))); private RelayCommand<FileExt> commandSaveContinuumRemovedLocal; public RelayCommand<FileExt> CommandSaveContinuumRemovedLocal => commandSaveContinuumRemovedLocal ?? (commandSaveContinuumRemovedLocal = new RelayCommand<FileExt>((fileExt) => saveSpectrumOfTypeContinuumRemovedLocalAsync(fileExt, CreationCollisionOption.ReplaceExisting))); private RelayCommand<SegmentFitModel> commandSegmentHighlight; public RelayCommand<SegmentFitModel> CommandSegmentHighlight => commandSegmentHighlight ?? (commandSegmentHighlight = new RelayCommand<SegmentFitModel>((item) => setSegmentHighlight(item))); Loading Loading
INAF.Apps.Uwp.SLabDataManager/Converters/SpectraConverters.cs +27 −0 Original line number Diff line number Diff line using CommunityToolkit.Mvvm.DependencyInjection; using INAF.Apps.Uwp.SLabDataManager.Charts.Containers; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Apps.Uwp.SLabDataManager.ViewModels.UserControlViewModels; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using System; using System.Collections.Generic; Loading Loading @@ -147,6 +148,32 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters } } public sealed class IsSpectrumOfTypeSelectedSmoothedConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { var smoothingViewModel = Ioc.Default.GetRequiredService<SmoothingViewModel>(); var spectraContainer = Ioc.Default.GetService<WorkingItemsModel>().SpectraContainer; var destSpectrumType = smoothingViewModel.getDestSpectrumType(smoothingViewModel.SelectedSpectrumType); return spectraContainer.isAnySpectrumOfType(destSpectrumType); } catch (Exception) { return false; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class IsSpectrumSavedOnCloudConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) Loading
INAF.Apps.Uwp.SLabDataManager/Helpers/UI/XamlHelpers.cs +0 −10 Original line number Diff line number Diff line Loading @@ -2,11 +2,7 @@ using INAF.Apps.Uwp.SLabDataManager.Charts.Containers; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Apps.Uwp.SLabDataManager.Models.Spectrum; using INAF.Apps.Uwp.SLabDataManager.ViewModels; using INAF.Libraries.NetStandard.ScienceModels.Extensions; using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Media; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI Loading Loading @@ -55,12 +51,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI return spectraContainer.isAnySpectrumOfType(type.ToSpectrumType()); } public static SolidColorBrush IsSaveAsCopyEnabled() { var segmentsFitViewModel = Ioc.Default.GetRequiredService<ChartViewModel>().SegmentsFitViewModel; return (segmentsFitViewModel.IsSaveAsCopyAllowed ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.LightGray)); } public static bool IsSaveOnCloudPermissionDenied() { var permissionHelper = Ioc.Default.GetRequiredService<PermissionsHelper>(); Loading
INAF.Apps.Uwp.SLabDataManager/Styles/Custom.xaml +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ <converters:IsAnySpectrumOfTypeConverter x:Key="IsAnySpectrumOfTypeConverter" /> <converters:IsAnySpectrumOfTypeVisibilityConverter x:Key="IsAnySpectrumOfTypeVisibilityConverter" /> <converters:IsSpectrumAvailablelWithParameterConverter x:Key="IsSpectrumAvailablelWithParameterConverter" /> <converters:IsSpectrumOfTypeSelectedSmoothedConverter x:Key="IsSpectrumOfTypeSelectedSmoothedConverter" /> <converters:IsSpectrumSavedOnCloudConverter x:Key="IsSpectrumSavedOnCloudConverter" /> <converters:IsUserControlAvailableConverter x:Key="IsUserControlAvailableConverter" /> <converters:HalfWidthConverter x:Key="HalfWidthConverter" /> Loading
INAF.Apps.Uwp.SLabDataManager/ViewModels/ChartBaseViewModel.cs +4 −2 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ using INAF.Libraries.Uwp.StorageItemsAccess; using Microsoft.Extensions.DependencyInjection; using System; using System.Threading.Tasks; using Windows.Storage; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums; Loading Loading @@ -142,7 +143,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels #region save local file protected async Task saveSpectrumOfTypeLocalAsync(SpectrumType spectrumType, FileExt fileExt) FileExt fileExt, CreationCollisionOption creationCollisionOption = CreationCollisionOption.ReplaceExisting) { /* raise error message if no aligned spectrum existing */ if (!WorkingItems.SpectraContainer.isAnySpectrumOfType(spectrumType)) Loading @@ -157,7 +159,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels if (await isOutputFolderDefinedAsync()) { var userControlsViewModelFactory = serviceProvider.GetRequiredService<UserControlsViewModelFactory>(); (bool isOk, string exMsg) saveLocalFileResult = await userControlsViewModelFactory.createUserControlViewModel().saveSpectrumOfTypeAsLocalFileAsync(spectrumType, fileExt); (bool isOk, string exMsg) saveLocalFileResult = await userControlsViewModelFactory.createUserControlViewModel().saveSpectrumOfTypeAsLocalFileAsync(spectrumType, fileExt, creationCollisionOption); if (!saveLocalFileResult.isOk) showDialogMessage(saveLocalFileResult.exMsg, DialogMessageType.Warning); } Loading
INAF.Apps.Uwp.SLabDataManager/ViewModels/ChartViewModelSegmentsFit.cs +32 −66 Original line number Diff line number Diff line using CommunityToolkit.Mvvm.Input; using INAF.Apps.Uwp.SLabDataManager.Extensions; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations; using INAF.Apps.Uwp.SLabDataManager.Models.Fit; using INAF.Apps.Uwp.SLabDataManager.Models.Processing; using INAF.Apps.Uwp.SLabDataManager.Views.UserControls; using INAF.Libraries.NetStandard.Extensions; using INAF.Libraries.NetStandard.ScienceModels.Spectra; using INAF.Libraries.NetStandard.SLabCommonModels.Models.WebApp.Requests; using INAF.Libraries.NetStandard.SLabCommonModels.Models.WebApp.Requests.SaveSpectrum; using INAF.Libraries.NetStandard.SLabCommonModels.Models.WebApp.Responses; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Windows.Storage; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums; Loading Loading @@ -68,7 +63,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels private async Task clearSegmentsFitAsync(bool isAskDeleteContinuumRemovedSpectrumRequired = true) { /* remove all items in left-panel with data about segments fit */ SegmentsFitViewModel?.clear(); SegmentsFitViewModel?.init(); SegmentsFitViewModel.raiseIsPointsRemovalRequired(); /* remove continuum spectrum */ Loading Loading @@ -174,37 +169,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels SegmentsFitViewModel.raiseIsSegmentsLowlightRequired(); } //private async Task showContinuumRemovedResultAsync() //{ // ProcessingResult result = ContinuumRemovalHelper.ProcessingResult; // IsLoading = false; // if (result == null) // return; // /* disable focus on aligned+continuum */ // raiseIsDisableFitFocusRequired(); // 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 */ // await initSmoothingViewModelAsync(); // SmoothingViewModel.selectTargetSpectrumType(); // /* show success message */ // showInfoBar(Microsoft.UI.Xaml.Controls.InfoBarSeverity.Informational, // "ContinuumRemovalTitle".GetText(), // "ContinuumRemovalSuccess".GetText(), // autoHide: true); // } // else // showDialogMessage(result.DialogMessage); //} public void trySetIsContinuumRemovalEnabled() { if (WorkingItems.SpectraContainer.isAnySpectrumOfType(SpectrumType.Raw) && isContinuumSpectrumCompleted()) Loading Loading @@ -246,40 +210,24 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels #endregion #region save private async Task saveSpectrumOfTypeContinuumRemovedAsync(SaveFileOperationType saveFileOperationType) { /* raise error message if no aligned spectrum existing */ if (!WorkingItems.SpectraContainer.isAnySpectrumOfType(SpectrumType.ContinuumRemoved)) private async Task saveSpectrumOfTypeContinuumRemovedCloudAndLocalAsync(FileExt fileExt, CreationCollisionOption creationCollisionOption) { showDialogMessage("ContinuumRemovalNotExecutedErrorMessage".GetText()); /* if 'save as copy' has been called but function is not allowed, then return */ if (creationCollisionOption == CreationCollisionOption.GenerateUniqueName && !SegmentsFitViewModel.IsSaveAsCopyAllowed) return; } IsLoading = true; /* save aligned spectrum locally, in a local folder */ if (await isOutputFolderDefinedAsync()) { /* determine whether replace or create new version of local file */ Windows.Storage.CreationCollisionOption creationCollisionOption = Windows.Storage.CreationCollisionOption.ReplaceExisting; if (saveFileOperationType == SaveFileOperationType.SaveAsCopy) creationCollisionOption = Windows.Storage.CreationCollisionOption.GenerateUniqueName; /* save spectrum locally */ await saveSpectrumOfTypeLocalAsync(SpectrumType.ContinuumRemoved, fileExt, creationCollisionOption); (bool isOk, string exMsg) saveLocalFileResult = await SegmentsFitViewModel.saveSpectrumOfTypeAsLocalFileAsync(SpectrumType.ContinuumRemoved, FileExt.Txt, creationCollisionOption); if (!saveLocalFileResult.isOk) showDialogMessage(saveLocalFileResult.exMsg, DialogMessageType.Warning); } else showDialogMessage("SaveSpectrumLocalOutputFolderNotDefinedMessage".GetText(), DialogMessageType.Warning); SegmentsFitViewModel.tryRaiseIsSaveAsCopyAllowed(); //SegmentsFitViewModel.IsSaveAsCopyAllowed = true; /* if no permission to save/delete on cloud is granted, then return */ if (getPermissionsHelper().isSaveOnCloudFromAppAllowed()) { /* determine whether replace or create new version on cloud */ RemoteOperationType remoteOperationType = RemoteOperationType.SaveSpectrumOfTypeContinuumRemoved; if (saveFileOperationType == SaveFileOperationType.SaveAsCopy) if (creationCollisionOption == CreationCollisionOption.GenerateUniqueName) remoteOperationType = RemoteOperationType.SaveAsCopySpectrumOfTypeContinuumRemoved; /* save continuum-removed spectrum on cloud */ Loading Loading @@ -322,6 +270,18 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels "ContinuumSpectrumSavedSuccessfullyMessage".GetText(), autoHide: true); } private async Task saveSpectrumOfTypeContinuumRemovedLocalAsync(FileExt fileExt, CreationCollisionOption creationCollisionOption) { /* if 'save as copy' has been called but function is not allowed, then return */ if (creationCollisionOption == CreationCollisionOption.GenerateUniqueName && !SegmentsFitViewModel.IsSaveAsCopyAllowed) return; /* save spectrum locally */ await saveSpectrumOfTypeLocalAsync(SpectrumType.ContinuumRemoved, fileExt, creationCollisionOption); SegmentsFitViewModel.tryRaiseIsSaveAsCopyAllowed(); } #endregion #region segments-fit panel Loading Loading @@ -380,11 +340,17 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels private RelayCommand commandExecuteContinuumRemoval; public RelayCommand CommandExecuteContinuumRemoval => commandExecuteContinuumRemoval ?? (commandExecuteContinuumRemoval = new RelayCommand(() => executeContinuumRemovalProcedurePart1())); private RelayCommand commandSaveContinuumRemovedSpectrum; public RelayCommand CommandSaveContinuumRemovedSpectrum => commandSaveContinuumRemovedSpectrum ?? (commandSaveContinuumRemovedSpectrum = new RelayCommand(() => saveSpectrumOfTypeContinuumRemovedAsync(SaveFileOperationType.ReplaceExisting))); private RelayCommand<FileExt> commandSaveAsCopyContinuumRemovedCoudAndLocal; public RelayCommand<FileExt> CommandSaveAsCopyContinuumRemovedCoudAndLocal => commandSaveAsCopyContinuumRemovedCoudAndLocal ?? (commandSaveAsCopyContinuumRemovedCoudAndLocal = new RelayCommand<FileExt>((fileExt) => saveSpectrumOfTypeContinuumRemovedCloudAndLocalAsync(fileExt, CreationCollisionOption.GenerateUniqueName))); private RelayCommand<FileExt> commandSaveAsCopyContinuumRemovedLocal; public RelayCommand<FileExt> CommandSaveAsCopyContinuumRemovedLocal => commandSaveAsCopyContinuumRemovedLocal ?? (commandSaveAsCopyContinuumRemovedLocal = new RelayCommand<FileExt>((fileExt) => saveSpectrumOfTypeContinuumRemovedLocalAsync(fileExt, CreationCollisionOption.GenerateUniqueName))); private RelayCommand<FileExt> commandSaveContinuumRemovedCoudAndLocal; public RelayCommand<FileExt> CommandSaveContinuumRemovedCoudAndLocal => commandSaveContinuumRemovedCoudAndLocal ?? (commandSaveContinuumRemovedCoudAndLocal = new RelayCommand<FileExt>((fileExt) => saveSpectrumOfTypeContinuumRemovedCloudAndLocalAsync(fileExt, CreationCollisionOption.ReplaceExisting))); private RelayCommand commandSaveAsCopyContinuumRemovedSpectrum; public RelayCommand CommandSaveAsCopyContinuumRemovedSpectrum => commandSaveAsCopyContinuumRemovedSpectrum ?? (commandSaveAsCopyContinuumRemovedSpectrum = new RelayCommand(() => saveSpectrumOfTypeContinuumRemovedAsync(SaveFileOperationType.SaveAsCopy))); private RelayCommand<FileExt> commandSaveContinuumRemovedLocal; public RelayCommand<FileExt> CommandSaveContinuumRemovedLocal => commandSaveContinuumRemovedLocal ?? (commandSaveContinuumRemovedLocal = new RelayCommand<FileExt>((fileExt) => saveSpectrumOfTypeContinuumRemovedLocalAsync(fileExt, CreationCollisionOption.ReplaceExisting))); private RelayCommand<SegmentFitModel> commandSegmentHighlight; public RelayCommand<SegmentFitModel> CommandSegmentHighlight => commandSegmentHighlight ?? (commandSegmentHighlight = new RelayCommand<SegmentFitModel>((item) => setSegmentHighlight(item))); Loading