Loading INAF.Apps.Uwp.SLabDataManager/Assets/xml/remoteoperations.xml +2 −0 Original line number Diff line number Diff line Loading @@ -21,5 +21,7 @@ <operation type="GetChildrenSpectraTypes">AppSpectraFilesActions/GetChildrenSpectraTypes</operation> <!-- USERS --> <operation type="GetUserPermissions">Users/GetUserPermissions</operation> <!-- PERMISSIONS --> <operation type="IsSaveOnCloudFromAppPermissionGranted">Permissions/IsSaveOnCloudFromAppPermissionGranted</operation> </operationUrls> </remoteOperationsData> No newline at end of file INAF.Apps.Uwp.SLabDataManager/Charts/Containers/SpectraContainer.cs +20 −2 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers public override async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) { if (isAnySummaryOfType(spectrum.Type)) tryGetSummaryOfType(spectrum.Type).init(spectrum); tryGetSummaryOfType(spectrum.Type).create(spectrum); /* set color for spectrum */ spectrum.setColor(); Loading Loading @@ -215,11 +215,24 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers } } public void resetSummaries() { var summaries = tryGetSummaries(); if (summaries.Any()) { foreach (var summary in summaries) { summary.reset(summary.Type); } } } public void resetSummaryOfType(SpectrumType type) { var requestedSummary = tryGetSummaryOfType(type); if (requestedSummary != null) requestedSummary.reset(); requestedSummary.reset(type); } public bool isAnySummaryOfType(SpectrumType spectrumType) Loading @@ -227,6 +240,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers return Summaries.Any(x => x.Type == spectrumType); } public List<SpectrumSummaryModel> tryGetSummaries() { return Summaries.ToList(); } public SpectrumSummaryModel tryGetSummaryOfType(SpectrumType spectrumType) { return Summaries.FirstOrDefault(x => x.Type == spectrumType); Loading INAF.Apps.Uwp.SLabDataManager/Models/SpectrumSummaryModel.cs +11 −6 Original line number Diff line number Diff line Loading @@ -11,10 +11,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models { public SpectrumSummaryModel(SpectrumType type) { Type = type; Filepath = "SpectrumFileNotSelectedMessage".GetText(); FileReadingStatus = FileReadingStatus.None; IsReady = false; init(type); } #region properties Loading Loading @@ -79,7 +76,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models } #endregion public void init(SpectrumModel spectrum) public void create(SpectrumModel spectrum) { double xMinValue = spectrum.Elements.Min(x => x.X); double xMaxValue = spectrum.Elements.Max(x => x.X); Loading @@ -103,14 +100,22 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models IsReady = true; } public void reset() private void init(SpectrumType type) { Type = type; Filepath = "SpectrumFileNotSelectedMessage".GetText(); FileReadingStatus = FileReadingStatus.None; XAxisReportText = string.Empty; YAxisReportText = string.Empty; LinesNumText = string.Empty; IsReady = false; } public void reset(SpectrumType type) { init(type); } public void updateFilepath(string filepath) { Filepath = filepath; Loading INAF.Apps.Uwp.SLabDataManager/ViewModels/BaseViewModel.cs +50 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.Input; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Apps.Uwp.SLabDataManager.Views; using INAF.Libraries.NetStandard.Extensions; using INAF.Libraries.Uwp.Logging; using INAF.Libraries.Uwp.Settings; Loading @@ -15,6 +16,7 @@ using System.Threading.Tasks; using System.Timers; using Windows.Storage; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums; Loading @@ -29,6 +31,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels protected readonly StorageItemsHelper storageItemsHelper; protected Windows.UI.Xaml.Controls.Page page; protected PermissionsHelper permissionsHelper; public BaseViewModel(IServiceProvider serviceProvider) { Loading @@ -49,6 +52,18 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels this.logger = logger; } public async Task OnNavigatingFrom(NavigatingCancelEventArgs e) { if (e.SourcePageType.Name.Equals(nameof(LoginPage))) { IsLoading = true; await clearFilesAsync(); IsLoading = false; } } protected async Task<StorageFile> selectFileAsync(SpectrumType spectrumType, List<FileExt> fileExts) { StorageFile file = null; Loading Loading @@ -163,6 +178,40 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels #endregion #endregion #region clear all protected async Task clearChartPageAsync() { /* retrieve chartViewModel and delete RAW file and derived ones */ var chartViewModel = serviceProvider.GetRequiredService<ChartViewModel>(); chartViewModel.SpectrumTypeToBeDeleted = SpectrumType.Raw; /* delete all spectra and close panels */ await chartViewModel.deleteProcessedSpectraProcedureAsync(); /* add all sercontrols to the list for being closed */ chartViewModel.closeAllUserControlsProcedure(); } private async Task clearFilesAsync() { /* reset summaries about read files */ WorkingItems.SpectraContainer.resetSummaries(); /* clear chart page (remove all spectra) and close usercontrols */ await clearChartPageAsync(); /* clear REF white (is not removed by removing the RAW one 'cause is not considered as a 'child' spectrum) */ WorkingItems.SpectraContainer.tryRemoveSpectrumOfTypeAsync(SpectrumType.Ref); } #endregion #region methods protected PermissionsHelper getPermissionsHelper() { if (permissionsHelper == null) permissionsHelper = serviceProvider.GetRequiredService<PermissionsHelper>(); return permissionsHelper; } protected Timer getTimer(double millisecs, Action action) { Loading Loading @@ -216,6 +265,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels { this.page = page; } #endregion #region success/error messages public void showDialogMessage(string dialogText, Loading INAF.Apps.Uwp.SLabDataManager/ViewModels/ChartViewModel.cs +38 −33 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels raiseIsChartLayoutUpdateRequired(); } public void OnNavigatingFrom(NavigatingCancelEventArgs e) public new async void OnNavigatingFrom(NavigatingCancelEventArgs e) { if (!App.AppDictionary.TryAdd(Constants.Constants.LAST_PAGE, nameof(ChartPage))) App.AppDictionary[Constants.Constants.LAST_PAGE] = nameof(ChartPage); Loading @@ -81,6 +81,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels saveIsSegmentsFitUserControlAutoOpenEnabled(); clear(); await base.OnNavigatingFrom(e); } #endregion Loading Loading @@ -416,6 +418,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels var remoteOperationsManager = serviceProvider.GetRequiredService<RemoteOperationsManager>(); IEnumerable<SpectrumType> retrievedSpectraTypesToBeDeleted = await remoteOperationsManager.getChildrenSpectraTypes(SpectrumTypeToBeDeleted); if (retrievedSpectraTypesToBeDeleted != null) { /* iterate on retrieved spectra types to delete them (if available) */ foreach (var retrievedSpectrumTypeToBeDeleted in retrievedSpectraTypesToBeDeleted) { Loading Loading @@ -452,6 +456,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels /* remove retrieved spectrum type from SpectraContainer (and then from chart) */ await WorkingItems.SpectraContainer.tryRemoveSpectrumOfTypeAsync(retrievedSpectrumTypeToBeDeleted); } } /* hide action user control */ tryRemoveActionUserControl(); Loading Loading
INAF.Apps.Uwp.SLabDataManager/Assets/xml/remoteoperations.xml +2 −0 Original line number Diff line number Diff line Loading @@ -21,5 +21,7 @@ <operation type="GetChildrenSpectraTypes">AppSpectraFilesActions/GetChildrenSpectraTypes</operation> <!-- USERS --> <operation type="GetUserPermissions">Users/GetUserPermissions</operation> <!-- PERMISSIONS --> <operation type="IsSaveOnCloudFromAppPermissionGranted">Permissions/IsSaveOnCloudFromAppPermissionGranted</operation> </operationUrls> </remoteOperationsData> No newline at end of file
INAF.Apps.Uwp.SLabDataManager/Charts/Containers/SpectraContainer.cs +20 −2 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers public override async Task addOrUpdateSpectrumAsync(SpectrumModel spectrum) { if (isAnySummaryOfType(spectrum.Type)) tryGetSummaryOfType(spectrum.Type).init(spectrum); tryGetSummaryOfType(spectrum.Type).create(spectrum); /* set color for spectrum */ spectrum.setColor(); Loading Loading @@ -215,11 +215,24 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers } } public void resetSummaries() { var summaries = tryGetSummaries(); if (summaries.Any()) { foreach (var summary in summaries) { summary.reset(summary.Type); } } } public void resetSummaryOfType(SpectrumType type) { var requestedSummary = tryGetSummaryOfType(type); if (requestedSummary != null) requestedSummary.reset(); requestedSummary.reset(type); } public bool isAnySummaryOfType(SpectrumType spectrumType) Loading @@ -227,6 +240,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers return Summaries.Any(x => x.Type == spectrumType); } public List<SpectrumSummaryModel> tryGetSummaries() { return Summaries.ToList(); } public SpectrumSummaryModel tryGetSummaryOfType(SpectrumType spectrumType) { return Summaries.FirstOrDefault(x => x.Type == spectrumType); Loading
INAF.Apps.Uwp.SLabDataManager/Models/SpectrumSummaryModel.cs +11 −6 Original line number Diff line number Diff line Loading @@ -11,10 +11,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models { public SpectrumSummaryModel(SpectrumType type) { Type = type; Filepath = "SpectrumFileNotSelectedMessage".GetText(); FileReadingStatus = FileReadingStatus.None; IsReady = false; init(type); } #region properties Loading Loading @@ -79,7 +76,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models } #endregion public void init(SpectrumModel spectrum) public void create(SpectrumModel spectrum) { double xMinValue = spectrum.Elements.Min(x => x.X); double xMaxValue = spectrum.Elements.Max(x => x.X); Loading @@ -103,14 +100,22 @@ namespace INAF.Apps.Uwp.SLabDataManager.Models IsReady = true; } public void reset() private void init(SpectrumType type) { Type = type; Filepath = "SpectrumFileNotSelectedMessage".GetText(); FileReadingStatus = FileReadingStatus.None; XAxisReportText = string.Empty; YAxisReportText = string.Empty; LinesNumText = string.Empty; IsReady = false; } public void reset(SpectrumType type) { init(type); } public void updateFilepath(string filepath) { Filepath = filepath; Loading
INAF.Apps.Uwp.SLabDataManager/ViewModels/BaseViewModel.cs +50 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.Input; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Apps.Uwp.SLabDataManager.Views; using INAF.Libraries.NetStandard.Extensions; using INAF.Libraries.Uwp.Logging; using INAF.Libraries.Uwp.Settings; Loading @@ -15,6 +16,7 @@ using System.Threading.Tasks; using System.Timers; using Windows.Storage; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums; Loading @@ -29,6 +31,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels protected readonly StorageItemsHelper storageItemsHelper; protected Windows.UI.Xaml.Controls.Page page; protected PermissionsHelper permissionsHelper; public BaseViewModel(IServiceProvider serviceProvider) { Loading @@ -49,6 +52,18 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels this.logger = logger; } public async Task OnNavigatingFrom(NavigatingCancelEventArgs e) { if (e.SourcePageType.Name.Equals(nameof(LoginPage))) { IsLoading = true; await clearFilesAsync(); IsLoading = false; } } protected async Task<StorageFile> selectFileAsync(SpectrumType spectrumType, List<FileExt> fileExts) { StorageFile file = null; Loading Loading @@ -163,6 +178,40 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels #endregion #endregion #region clear all protected async Task clearChartPageAsync() { /* retrieve chartViewModel and delete RAW file and derived ones */ var chartViewModel = serviceProvider.GetRequiredService<ChartViewModel>(); chartViewModel.SpectrumTypeToBeDeleted = SpectrumType.Raw; /* delete all spectra and close panels */ await chartViewModel.deleteProcessedSpectraProcedureAsync(); /* add all sercontrols to the list for being closed */ chartViewModel.closeAllUserControlsProcedure(); } private async Task clearFilesAsync() { /* reset summaries about read files */ WorkingItems.SpectraContainer.resetSummaries(); /* clear chart page (remove all spectra) and close usercontrols */ await clearChartPageAsync(); /* clear REF white (is not removed by removing the RAW one 'cause is not considered as a 'child' spectrum) */ WorkingItems.SpectraContainer.tryRemoveSpectrumOfTypeAsync(SpectrumType.Ref); } #endregion #region methods protected PermissionsHelper getPermissionsHelper() { if (permissionsHelper == null) permissionsHelper = serviceProvider.GetRequiredService<PermissionsHelper>(); return permissionsHelper; } protected Timer getTimer(double millisecs, Action action) { Loading Loading @@ -216,6 +265,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels { this.page = page; } #endregion #region success/error messages public void showDialogMessage(string dialogText, Loading
INAF.Apps.Uwp.SLabDataManager/ViewModels/ChartViewModel.cs +38 −33 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels raiseIsChartLayoutUpdateRequired(); } public void OnNavigatingFrom(NavigatingCancelEventArgs e) public new async void OnNavigatingFrom(NavigatingCancelEventArgs e) { if (!App.AppDictionary.TryAdd(Constants.Constants.LAST_PAGE, nameof(ChartPage))) App.AppDictionary[Constants.Constants.LAST_PAGE] = nameof(ChartPage); Loading @@ -81,6 +81,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels saveIsSegmentsFitUserControlAutoOpenEnabled(); clear(); await base.OnNavigatingFrom(e); } #endregion Loading Loading @@ -416,6 +418,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels var remoteOperationsManager = serviceProvider.GetRequiredService<RemoteOperationsManager>(); IEnumerable<SpectrumType> retrievedSpectraTypesToBeDeleted = await remoteOperationsManager.getChildrenSpectraTypes(SpectrumTypeToBeDeleted); if (retrievedSpectraTypesToBeDeleted != null) { /* iterate on retrieved spectra types to delete them (if available) */ foreach (var retrievedSpectrumTypeToBeDeleted in retrievedSpectraTypesToBeDeleted) { Loading Loading @@ -452,6 +456,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.ViewModels /* remove retrieved spectrum type from SpectraContainer (and then from chart) */ await WorkingItems.SpectraContainer.tryRemoveSpectrumOfTypeAsync(retrievedSpectrumTypeToBeDeleted); } } /* hide action user control */ tryRemoveActionUserControl(); Loading