Loading INAF.Apps.Uwp.SLabDataManager/Charts/SpectraContainer.cs +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts Spectra = new ObservableCollection<SpectrumModel>(); Summaries = new ObservableCollection<SpectrumSummaryModel>(); IsSpectrumAligned = false; XAxisMajorStepValues = new List<double>(2); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_0DOT1); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_100); Loading @@ -52,6 +54,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts set { SetProperty(ref isAnySummaryUpdated, value); } } public bool IsSpectrumAligned { get; set; } public SelectedRefBand SelectedRefBand { get; private set; } private ObservableCollection<SpectrumModel> spectra; Loading INAF.Apps.Uwp.SLabDataManager/Charts/SpectrumAlignmentConfigModel.cs +43 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts if (!tryReadNumOfPointsForAlignment()) NumOfPointsForAlignment = 3; if (!tryReadIsPinned()) IsPinned = false; tryReadWavelengthModels(); } Loading @@ -37,6 +40,27 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts set { areSeparatorsVisible = value; saveAreSeparatorsVisible(value); RaisePropertyChanged(nameof(AreSeparatorsVisible)); } } private bool isPinned; public bool IsPinned { get { return isPinned; } set { isPinned = value; RaisePropertyChanged(nameof(IsPinned)); } } private bool isPinRequested; public bool IsPinRequested { get { return isPinRequested; } set { isPinRequested = value; RaisePropertyChanged(nameof(IsPinRequested)); } } private bool isUnpinRequested; public bool IsUnpinRequested { get { return isUnpinRequested; } set { isUnpinRequested = value; RaisePropertyChanged(nameof(IsUnpinRequested)); } } private int numOfPointsForAlignment; public int NumOfPointsForAlignment { Loading @@ -53,6 +77,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts settingsHelper.save(Constants.Constants.ARE_SEPARATORS_VISIBLE, areVisible.ToString()); } private void saveIsPinned(bool isPinned) { settingsHelper.save(Constants.Constants.IS_ALIGNMENT_FLYOUT_PINNED, isPinned.ToString()); } private void saveNumOfPointsForAlignment(int numOfPoints) { settingsHelper.save(Constants.Constants.NUM_OF_POINTS_FOR_ALIGNMENT, numOfPoints.ToString()); Loading @@ -77,6 +106,20 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts return isFound; } public bool tryReadIsPinned() { bool isFound = false; string value = settingsHelper.get(Constants.Constants.IS_ALIGNMENT_FLYOUT_PINNED); if (!string.IsNullOrEmpty(value)) { IsPinned = value.ToBool(); isFound = true; } return isFound; } public bool tryReadNumOfPointsForAlignment() { bool isFound = false; Loading INAF.Apps.Uwp.SLabDataManager/Constants/Constants.cs +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ public static readonly string ARE_SEPARATORS_VISIBLE = "areseparatorsvisible"; public static readonly string NUM_OF_POINTS_FOR_ALIGNMENT = "numofpointsforalignment"; public static readonly string IS_ALIGNMENT_FLYOUT_PINNED = "isalignmentflyoutpinned"; public static readonly string SELECTED_REF_BAND_XMAX = "selectedrefbandxmax"; public static readonly string SELECTED_REF_BAND_XMIN = "selectedrefbandxmin"; Loading INAF.Apps.Uwp.SLabDataManager/Extensions/Extensions.cs +16 −0 Original line number Diff line number Diff line using INAF.Libraries.NetStandard.ScienceModels.Spectra; using System.Collections.Generic; using System.Linq; using Windows.UI; using Windows.UI.Xaml.Media; namespace INAF.Apps.Uwp.SLabDataManager.Extensions { Loading Loading @@ -87,5 +89,19 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions } #endregion #endregion public static SolidColorBrush SolidColorBrushFromHexString(this string hexstring) { hexstring = hexstring.Replace("#", string.Empty); // from #RRGGBB string var a = (byte)System.Convert.ToUInt32(hexstring.Substring(0, 2), 16); var r = (byte)System.Convert.ToUInt32(hexstring.Substring(2, 2), 16); var g = (byte)System.Convert.ToUInt32(hexstring.Substring(4, 2), 16); var b = (byte)System.Convert.ToUInt32(hexstring.Substring(6, 2), 16); //get the color Color color = Color.FromArgb(a, r, g, b); // create the solidColorbrush return new SolidColorBrush(color); } } } INAF.Apps.Uwp.SLabDataManager/Helpers/RemoteOperations/RemoteOperationsManager.cs +20 −3 Original line number Diff line number Diff line using INAF.Libraries.NetStandard.SLabCommonModels.Models.SaveAlignedSpectrum; using INAF.Libraries.NetStandard.SLabCommonModels.Authentication; using INAF.Libraries.NetStandard.SLabCommonModels.Models.SaveAlignedSpectrum; using INAF.Libraries.Uwp.Logging; using INAF.Libraries.Uwp.Settings; using Newtonsoft.Json; using System; using System.Net.Http.Headers; using System.Threading.Tasks; using Windows.Web.Http; using Windows.Web.Http.Headers; using static INAF.Libraries.NetStandard.SLabCommonModels.RemoteOperations.Enums; namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations { public sealed class RemoteOperationsManager : IDisposable { private readonly SettingsHelper settingsHelper; private readonly RemoteOperationsRepository remoteOperationsRepository; private readonly Logger logger; private bool disposedValue; public RemoteOperationsManager(RemoteOperationsRepository remoteOperationsRepository, public RemoteOperationsManager(SettingsHelper settingsHelper, RemoteOperationsRepository remoteOperationsRepository, Logger logger) { this.settingsHelper = settingsHelper; this.remoteOperationsRepository = remoteOperationsRepository; this.logger = logger; } Loading @@ -29,7 +36,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations { using (var httpClient = new HttpClient()) { using (var httpContent = new HttpStringContent(JsonConvert.SerializeObject(saveAlignedSpectrumRequestModel), Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json")) JwtTokenModel tokenModel = settingsHelper.get<JwtTokenModel>(Constants.Constants.AUTHENTICATION_TOKEN); httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", tokenModel.Token); //saveAlignedSpectrumRequestModel.setAuthorization(tokenModel.Token); using (var httpContent = getHttpStringContent(saveAlignedSpectrumRequestModel)) { var url = remoteOperationsRepository.getUrl(RemoteOperationType.SaveAlignedFile); using (var response = await httpClient.PostAsync(new Uri(url), httpContent)) Loading @@ -47,12 +58,18 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations } catch (Exception ex) { isOk = false; logger.Write<RemoteOperationsManager>($"{nameof(saveAlignedSpectrumAsync)} - ex: {ex.Message}", Serilog.Events.LogEventLevel.Error); } return isOk; } private HttpStringContent getHttpStringContent(Object objectToBeSerialized) { return new HttpStringContent(JsonConvert.SerializeObject(objectToBeSerialized), Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json"); } private void Dispose(bool disposing) { if (!disposedValue) Loading Loading
INAF.Apps.Uwp.SLabDataManager/Charts/SpectraContainer.cs +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts Spectra = new ObservableCollection<SpectrumModel>(); Summaries = new ObservableCollection<SpectrumSummaryModel>(); IsSpectrumAligned = false; XAxisMajorStepValues = new List<double>(2); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_0DOT1); XAxisMajorStepValues.Add(Constants.Constants.X_AXIS_MAJOR_STEP_100); Loading @@ -52,6 +54,8 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts set { SetProperty(ref isAnySummaryUpdated, value); } } public bool IsSpectrumAligned { get; set; } public SelectedRefBand SelectedRefBand { get; private set; } private ObservableCollection<SpectrumModel> spectra; Loading
INAF.Apps.Uwp.SLabDataManager/Charts/SpectrumAlignmentConfigModel.cs +43 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts if (!tryReadNumOfPointsForAlignment()) NumOfPointsForAlignment = 3; if (!tryReadIsPinned()) IsPinned = false; tryReadWavelengthModels(); } Loading @@ -37,6 +40,27 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts set { areSeparatorsVisible = value; saveAreSeparatorsVisible(value); RaisePropertyChanged(nameof(AreSeparatorsVisible)); } } private bool isPinned; public bool IsPinned { get { return isPinned; } set { isPinned = value; RaisePropertyChanged(nameof(IsPinned)); } } private bool isPinRequested; public bool IsPinRequested { get { return isPinRequested; } set { isPinRequested = value; RaisePropertyChanged(nameof(IsPinRequested)); } } private bool isUnpinRequested; public bool IsUnpinRequested { get { return isUnpinRequested; } set { isUnpinRequested = value; RaisePropertyChanged(nameof(IsUnpinRequested)); } } private int numOfPointsForAlignment; public int NumOfPointsForAlignment { Loading @@ -53,6 +77,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts settingsHelper.save(Constants.Constants.ARE_SEPARATORS_VISIBLE, areVisible.ToString()); } private void saveIsPinned(bool isPinned) { settingsHelper.save(Constants.Constants.IS_ALIGNMENT_FLYOUT_PINNED, isPinned.ToString()); } private void saveNumOfPointsForAlignment(int numOfPoints) { settingsHelper.save(Constants.Constants.NUM_OF_POINTS_FOR_ALIGNMENT, numOfPoints.ToString()); Loading @@ -77,6 +106,20 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts return isFound; } public bool tryReadIsPinned() { bool isFound = false; string value = settingsHelper.get(Constants.Constants.IS_ALIGNMENT_FLYOUT_PINNED); if (!string.IsNullOrEmpty(value)) { IsPinned = value.ToBool(); isFound = true; } return isFound; } public bool tryReadNumOfPointsForAlignment() { bool isFound = false; Loading
INAF.Apps.Uwp.SLabDataManager/Constants/Constants.cs +1 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ public static readonly string ARE_SEPARATORS_VISIBLE = "areseparatorsvisible"; public static readonly string NUM_OF_POINTS_FOR_ALIGNMENT = "numofpointsforalignment"; public static readonly string IS_ALIGNMENT_FLYOUT_PINNED = "isalignmentflyoutpinned"; public static readonly string SELECTED_REF_BAND_XMAX = "selectedrefbandxmax"; public static readonly string SELECTED_REF_BAND_XMIN = "selectedrefbandxmin"; Loading
INAF.Apps.Uwp.SLabDataManager/Extensions/Extensions.cs +16 −0 Original line number Diff line number Diff line using INAF.Libraries.NetStandard.ScienceModels.Spectra; using System.Collections.Generic; using System.Linq; using Windows.UI; using Windows.UI.Xaml.Media; namespace INAF.Apps.Uwp.SLabDataManager.Extensions { Loading Loading @@ -87,5 +89,19 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions } #endregion #endregion public static SolidColorBrush SolidColorBrushFromHexString(this string hexstring) { hexstring = hexstring.Replace("#", string.Empty); // from #RRGGBB string var a = (byte)System.Convert.ToUInt32(hexstring.Substring(0, 2), 16); var r = (byte)System.Convert.ToUInt32(hexstring.Substring(2, 2), 16); var g = (byte)System.Convert.ToUInt32(hexstring.Substring(4, 2), 16); var b = (byte)System.Convert.ToUInt32(hexstring.Substring(6, 2), 16); //get the color Color color = Color.FromArgb(a, r, g, b); // create the solidColorbrush return new SolidColorBrush(color); } } }
INAF.Apps.Uwp.SLabDataManager/Helpers/RemoteOperations/RemoteOperationsManager.cs +20 −3 Original line number Diff line number Diff line using INAF.Libraries.NetStandard.SLabCommonModels.Models.SaveAlignedSpectrum; using INAF.Libraries.NetStandard.SLabCommonModels.Authentication; using INAF.Libraries.NetStandard.SLabCommonModels.Models.SaveAlignedSpectrum; using INAF.Libraries.Uwp.Logging; using INAF.Libraries.Uwp.Settings; using Newtonsoft.Json; using System; using System.Net.Http.Headers; using System.Threading.Tasks; using Windows.Web.Http; using Windows.Web.Http.Headers; using static INAF.Libraries.NetStandard.SLabCommonModels.RemoteOperations.Enums; namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations { public sealed class RemoteOperationsManager : IDisposable { private readonly SettingsHelper settingsHelper; private readonly RemoteOperationsRepository remoteOperationsRepository; private readonly Logger logger; private bool disposedValue; public RemoteOperationsManager(RemoteOperationsRepository remoteOperationsRepository, public RemoteOperationsManager(SettingsHelper settingsHelper, RemoteOperationsRepository remoteOperationsRepository, Logger logger) { this.settingsHelper = settingsHelper; this.remoteOperationsRepository = remoteOperationsRepository; this.logger = logger; } Loading @@ -29,7 +36,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations { using (var httpClient = new HttpClient()) { using (var httpContent = new HttpStringContent(JsonConvert.SerializeObject(saveAlignedSpectrumRequestModel), Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json")) JwtTokenModel tokenModel = settingsHelper.get<JwtTokenModel>(Constants.Constants.AUTHENTICATION_TOKEN); httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", tokenModel.Token); //saveAlignedSpectrumRequestModel.setAuthorization(tokenModel.Token); using (var httpContent = getHttpStringContent(saveAlignedSpectrumRequestModel)) { var url = remoteOperationsRepository.getUrl(RemoteOperationType.SaveAlignedFile); using (var response = await httpClient.PostAsync(new Uri(url), httpContent)) Loading @@ -47,12 +58,18 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations } catch (Exception ex) { isOk = false; logger.Write<RemoteOperationsManager>($"{nameof(saveAlignedSpectrumAsync)} - ex: {ex.Message}", Serilog.Events.LogEventLevel.Error); } return isOk; } private HttpStringContent getHttpStringContent(Object objectToBeSerialized) { return new HttpStringContent(JsonConvert.SerializeObject(objectToBeSerialized), Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json"); } private void Dispose(bool disposing) { if (!disposedValue) Loading