Loading INAF.Apps.Uwp.SLabDataManager.sln +24 −2 Original line number Diff line number Diff line Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.32413.511 # Visual Studio Version 17 VisualStudioVersion = 17.1.32421.90 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "INAF.Apps.Uwp.SLabDataManager", "INAF.Apps.Uwp.SLabDataManager\INAF.Apps.Uwp.SLabDataManager.csproj", "{466403C4-CAC2-4FEC-93FB-8ED4805B5DF4}" EndProject Loading @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "INAF.Libraries.NetStandard. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "INAF.Libraries.Uwp.Converters", "..\..\Libraries\Uwp\INAF.Libraries.Uwp.Converters\INAF.Libraries.Uwp.Converters\INAF.Libraries.Uwp.Converters.csproj", "{974BA015-88F8-4948-BB8B-180EA417435B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "INAF.Libraries.Uwp.TelerikChartsExtensions", "..\..\Libraries\Uwp\INAF.Libraries.Uwp.TelerikChartsExtensions\INAF.Libraries.Uwp.TelerikChartsExtensions\INAF.Libraries.Uwp.TelerikChartsExtensions.csproj", "{BB43C3BA-3085-4D81-9733-2BF398EAA6CF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Loading Loading @@ -199,6 +201,26 @@ Global {974BA015-88F8-4948-BB8B-180EA417435B}.Release|x64.Build.0 = Release|x64 {974BA015-88F8-4948-BB8B-180EA417435B}.Release|x86.ActiveCfg = Release|x86 {974BA015-88F8-4948-BB8B-180EA417435B}.Release|x86.Build.0 = Release|x86 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|ARM.ActiveCfg = Debug|ARM {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|ARM.Build.0 = Debug|ARM {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|ARM64.ActiveCfg = Debug|ARM64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|ARM64.Build.0 = Debug|ARM64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|x64.ActiveCfg = Debug|x64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|x64.Build.0 = Debug|x64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|x86.ActiveCfg = Debug|x86 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|x86.Build.0 = Debug|x86 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|Any CPU.Build.0 = Release|Any CPU {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|ARM.ActiveCfg = Release|ARM {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|ARM.Build.0 = Release|ARM {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|ARM64.ActiveCfg = Release|ARM64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|ARM64.Build.0 = Release|ARM64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|x64.ActiveCfg = Release|x64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|x64.Build.0 = Release|x64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|x86.ActiveCfg = Release|x86 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Loading INAF.Apps.Uwp.SLabDataManager/App.xaml.cs +3 −1 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.Charts; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Apps.Uwp.SLabDataManager.Services; using INAF.Apps.Uwp.SLabDataManager.ViewModels; Loading Loading @@ -76,6 +77,7 @@ namespace INAF.Apps.Uwp.SLabDataManager Ioc.Default.ConfigureServices( new ServiceCollection() /* singletons */ .AddSingleton<SpectrumChartOptionsModel>() .AddSingleton<Logger>(logger) .AddSingleton<SettingsHelper>() .AddSingleton<StorageItemsSettingsHelper>() Loading INAF.Apps.Uwp.SLabDataManager/Charts/SpectrumChartOptionsModel.cs +185 −16 Original line number Diff line number Diff line using INAF.Libraries.NetStandard.ScienceModels; using INAF.Apps.Uwp.SLabDataManager.Constants; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Libraries.NetStandard.ScienceModels; using INAF.Libraries.NetStandard.ScienceModels.Spectra; using INAF.Libraries.Uwp.Settings; using INAF.Libraries.Uwp.TelerikChartsExtensions; using System; using System.Collections.Generic; using System.Linq; using Telerik.UI.Xaml.Controls.Chart; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; using static INAF.Libraries.NetStandard.ScienceModels.Enums.Enums; namespace INAF.Apps.Uwp.Charts { public class SpectrumChartOptionsModel : ObservableModel { public SpectrumChartOptionsModel(SpectrumModel spectrum) private readonly SettingsHelper settingsHelper; public SpectrumChartOptionsModel(SettingsHelper settingsHelper) { Spectrum = spectrum; this.settingsHelper = settingsHelper; WavelengthMeasureUnits = Enum.GetValues(typeof(WavelengthMeasureUnit)).Cast<WavelengthMeasureUnit>().ToList(); if (!tryReadWavelengthMeasureUnits()) SelectedWavelengthMeasureUnit = WavelengthMeasureUnit.Nanometers; MajorLinesVisibilityValues = Enum.GetValues(typeof(GridLineVisibility)).Cast<GridLineVisibility>().ToList(); if (!tryReadMajorLinesVisibility()) SelectedMajorLinesVisibility = GridLineVisibility.XY; StripLinesVisibilityValues = Enum.GetValues(typeof(GridLineVisibility)).Cast<GridLineVisibility>().ToList(); if (!tryReadStripLinesVisibility()) SelectedStripLinesVisibility = GridLineVisibility.XY; WavelengthMeasureUnits = Enum.GetValues(typeof(WavelengthMeasureUnit)).Cast<WavelengthMeasureUnit>().ToList(); SelectedWavelengthMeasureUnit = WavelengthMeasureUnit.Nanometers; ChartPanModeValues = Enum.GetValues(typeof(ChartPanZoomMode)).Cast<ChartPanZoomMode>().ToList(); if (!tryReadChartPanMode()) SelectedChartPanMode = ChartPanZoomMode.Both; ChartZoomModeValues = Enum.GetValues(typeof(ChartPanZoomMode)).Cast<ChartPanZoomMode>().ToList(); if (!tryReadChartZoomMode()) SelectedChartZoomMode = ChartPanZoomMode.Both; XAxisMajorStepValues = new List<double>(2); XAxisMajorStepValues.Add(0.1); XAxisMajorStepValues.Add(100); } public SpectrumModel Spectrum { get; set; } Loading @@ -47,7 +61,26 @@ namespace INAF.Apps.Uwp.Charts public GridLineVisibility SelectedMajorLinesVisibility { get { return selectedMajorLinesVisibility; } set { selectedMajorLinesVisibility = value; RaisePropertyChanged(nameof(SelectedMajorLinesVisibility)); } set { selectedMajorLinesVisibility = value; saveMajorLinesVisibility(value); RaisePropertyChanged(nameof(SelectedMajorLinesVisibility)); } } public bool tryReadMajorLinesVisibility() { bool isFound = false; string value = settingsHelper.get(Constants.MAJOR_LINES_VISIBILITY); if (!string.IsNullOrEmpty(value)) { SelectedMajorLinesVisibility = value.ToGridLineVisibility(); isFound = true; } return isFound; } private void saveMajorLinesVisibility(GridLineVisibility gridLineVisibility) { settingsHelper.save(Constants.MAJOR_LINES_VISIBILITY, gridLineVisibility.ToString()); } #endregion Loading @@ -56,7 +89,7 @@ namespace INAF.Apps.Uwp.Charts public GridLineVisibility SelectedStripLinesVisibility { get { return selectedStripLinesVisibility; } set { selectedStripLinesVisibility = value; RaisePropertyChanged(nameof(SelectedStripLinesVisibility)); } set { selectedStripLinesVisibility = value; saveStripLinesVisibility(value); RaisePropertyChanged(nameof(SelectedStripLinesVisibility)); } } private List<GridLineVisibility> stripLinesVisibilityValues; Loading @@ -65,6 +98,25 @@ namespace INAF.Apps.Uwp.Charts get { return stripLinesVisibilityValues; } set { stripLinesVisibilityValues = value; RaisePropertyChanged(nameof(StripLinesVisibilityValues)); } } public bool tryReadStripLinesVisibility() { bool isFound = false; string value = settingsHelper.get(Constants.STRIP_LINES_VISIBILITY); if (!string.IsNullOrEmpty(value)) { SelectedStripLinesVisibility = value.ToGridLineVisibility(); isFound = true; } return isFound; } private void saveStripLinesVisibility(GridLineVisibility gridLineVisibility) { settingsHelper.save(Constants.STRIP_LINES_VISIBILITY, gridLineVisibility.ToString()); } #endregion #region Pan mode Loading @@ -79,7 +131,26 @@ namespace INAF.Apps.Uwp.Charts public ChartPanZoomMode SelectedChartPanMode { get { return selectedChartPanMode; } set { selectedChartPanMode = value; RaisePropertyChanged(nameof(SelectedChartPanMode)); } set { selectedChartPanMode = value; saveChartPanMode(value); RaisePropertyChanged(nameof(SelectedChartPanMode)); } } public bool tryReadChartPanMode() { bool isFound = false; string value = settingsHelper.get(Constants.PAN_MODE); if (!string.IsNullOrEmpty(value)) { SelectedChartPanMode = value.ToChartPanZoomMode(); isFound = true; } return isFound; } private void saveChartPanMode(ChartPanZoomMode chartPanzoomMode) { settingsHelper.save(Constants.PAN_MODE, chartPanzoomMode.ToString()); } #endregion Loading @@ -95,7 +166,26 @@ namespace INAF.Apps.Uwp.Charts public ChartPanZoomMode SelectedChartZoomMode { get { return selectedChartZoomMode; } set { selectedChartZoomMode = value; RaisePropertyChanged(nameof(SelectedChartZoomMode)); } set { selectedChartZoomMode = value; saveChartZoomMode(value); RaisePropertyChanged(nameof(SelectedChartZoomMode)); } } public bool tryReadChartZoomMode() { bool isFound = false; string value = settingsHelper.get(Constants.ZOOM_MODE); if (!string.IsNullOrEmpty(value)) { SelectedChartZoomMode = value.ToChartPanZoomMode(); isFound = true; } return isFound; } private void saveChartZoomMode(ChartPanZoomMode chartPanzoomMode) { settingsHelper.save(Constants.ZOOM_MODE, chartPanzoomMode.ToString()); } #endregion Loading @@ -104,14 +194,93 @@ namespace INAF.Apps.Uwp.Charts public WavelengthMeasureUnit SelectedWavelengthMeasureUnit { get { return selectedWavelengthMeasureUnit; } set { selectedWavelengthMeasureUnit = value; RaisePropertyChanged(nameof(SelectedWavelengthMeasureUnit)); } set { selectedWavelengthMeasureUnit = value; saveWavelengthMeasureUnits(value); switchXAxisValues(); RaisePropertyChanged(nameof(SelectedWavelengthMeasureUnit)); } } public List<WavelengthMeasureUnit> WavelengthMeasureUnits { get; set; } public bool tryReadWavelengthMeasureUnits() { bool isFound = false; string value = settingsHelper.get(Constants.WAVELENGTH_MEASURE_UNITS); if (!string.IsNullOrEmpty(value)) { SelectedWavelengthMeasureUnit = value.ToWavelengthMeasureUnit(); isFound = true; } return isFound; } private void saveWavelengthMeasureUnits(WavelengthMeasureUnit wavelengthMeasureUnit) { settingsHelper.save(Constants.WAVELENGTH_MEASURE_UNITS, wavelengthMeasureUnit.ToString()); } #endregion #region major step private double selectedXAxisMajorStep; public double SelectedXAxisMajorStep { get { return selectedXAxisMajorStep; } set { selectedXAxisMajorStep = value; RaisePropertyChanged(nameof(SelectedXAxisMajorStep)); } } public List<double> XAxisMajorStepValues { get; private set; } private void setXAxisMajorStep() { switch (SelectedWavelengthMeasureUnit) { case WavelengthMeasureUnit.Nanometers: SelectedXAxisMajorStep = XAxisMajorStepValues.FirstOrDefault(x => x == Constants.X_AXIS_MAJOR_STEP_NANOMETERS); break; case WavelengthMeasureUnit.Microns: SelectedXAxisMajorStep = XAxisMajorStepValues.FirstOrDefault(x => x == Constants.X_AXIS_MAJOR_STEP_MICRONS); break; } } #endregion #region axes boundaries public AxisBoundariesModel XAxisBoundaries { get; private set; } public AxisBoundariesModel YAxisBoundaries { get; private set; } #endregion public string XAxisTitle { get; set; } public string YAxisTitle { get; set; } public void createSummary() { double xmax = Spectrum.Elements.Max(x => x.X); double xmin = Spectrum.Elements.Min(x => x.X); XAxisBoundaries = new AxisBoundariesModel("x", xmin, xmax, Spectrum.Elements.FirstOrDefault().MeasureUnit); double ymax = Spectrum.Elements.Max(x => x.Y); double ymin = Spectrum.Elements.Min(x => x.Y); YAxisBoundaries = new AxisBoundariesModel("y", ymin, ymax, Spectrum.Elements.FirstOrDefault().MeasureUnit); } public void setSpectrum(SpectrumModel spectrum) { Spectrum = spectrum; createSummary(); } private void switchXAxisValues() { if (Spectrum != null) { Spectrum.switchToMeasureUnit(SelectedWavelengthMeasureUnit); XAxisBoundaries.switchToMeasureUnit(SelectedWavelengthMeasureUnit); setXAxisMajorStep(); } } } } INAF.Apps.Uwp.SLabDataManager/Constants/Constants.cs +10 −0 Original line number Diff line number Diff line Loading @@ -10,5 +10,15 @@ public static readonly string RAW_SPECTRUM_FILE_TOKEN = "rawspectrumfiletoken"; public static readonly string REF_SPECTRUM_FILE = "refspectrumfile"; public static readonly string REF_SPECTRUM_FILE_TOKEN = "refspectrumfiletoken"; public static readonly string X_AXIS_MAJOR_STEP = "xaxismajorstep"; public static readonly string WAVELENGTH_MEASURE_UNITS = "wavelengthmeasureunits"; public static readonly string MAJOR_LINES_VISIBILITY = "majorlinesvisibility"; public static readonly string STRIP_LINES_VISIBILITY = "striplinesvisibility"; public static readonly string PAN_MODE = "panmode"; public static readonly string ZOOM_MODE = "zoommode"; public static readonly double X_AXIS_MAJOR_STEP_MICRONS = 0.1; public static readonly double X_AXIS_MAJOR_STEP_NANOMETERS = 100; } } INAF.Apps.Uwp.SLabDataManager/Converters/Converters.cs +83 −61 Original line number Diff line number Diff line Loading @@ -61,67 +61,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters } } public sealed class XAxisTitleConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { WorkingItemsModel workingItemsModel = Ioc.Default.GetService<WorkingItemsModel>(); return "SpectrumXAxisTitle".GetText().Replace("r_v", workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit.GetDescription()); } catch (Exception) { return string.Empty; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class XScaleLabelFormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { string format = string.Empty; WorkingItemsModel workingItemsModel = Ioc.Default.GetService<WorkingItemsModel>(); var selectedUnitMeasure = workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit; switch (selectedUnitMeasure) { //case Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Nanometers: // format = "N"; // break; case Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Microns: format = "{0:0.###E+0}"; break; default: format = "{0:G}"; break; } return format; } catch (Exception) { return "{0:G}"; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class StatusToImageConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) Loading Loading @@ -207,4 +146,87 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters throw new NotImplementedException(); } } public sealed class ThemeBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { return AppThemeHelper.GetThemeValue<SolidColorBrush>((string)parameter); } catch (Exception) { return string.Empty; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class XAxisTitleConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { WorkingItemsModel workingItemsModel = Ioc.Default.GetService<WorkingItemsModel>(); return "SpectrumXAxisTitle".GetText().Replace("r_v", workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit.GetDescription()); } catch (Exception) { return string.Empty; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class XScaleLabelFormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { //try //{ // string format = string.Empty; // WorkingItemsModel workingItemsModel = Ioc.Default.GetService<WorkingItemsModel>(); // var selectedUnitMeasure = workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit; // switch (selectedUnitMeasure) // { // //case Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Nanometers: // // format = "N"; // // break; // case Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Microns: // format = "{0:0.###E-0}"; // break; // default: // format = "{0:G}"; // break; // } // return format; //} //catch (Exception) //{ // return "{0:G}"; //} return "{0:G}"; ; } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } } Loading
INAF.Apps.Uwp.SLabDataManager.sln +24 −2 Original line number Diff line number Diff line Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.32413.511 # Visual Studio Version 17 VisualStudioVersion = 17.1.32421.90 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "INAF.Apps.Uwp.SLabDataManager", "INAF.Apps.Uwp.SLabDataManager\INAF.Apps.Uwp.SLabDataManager.csproj", "{466403C4-CAC2-4FEC-93FB-8ED4805B5DF4}" EndProject Loading @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "INAF.Libraries.NetStandard. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "INAF.Libraries.Uwp.Converters", "..\..\Libraries\Uwp\INAF.Libraries.Uwp.Converters\INAF.Libraries.Uwp.Converters\INAF.Libraries.Uwp.Converters.csproj", "{974BA015-88F8-4948-BB8B-180EA417435B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "INAF.Libraries.Uwp.TelerikChartsExtensions", "..\..\Libraries\Uwp\INAF.Libraries.Uwp.TelerikChartsExtensions\INAF.Libraries.Uwp.TelerikChartsExtensions\INAF.Libraries.Uwp.TelerikChartsExtensions.csproj", "{BB43C3BA-3085-4D81-9733-2BF398EAA6CF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Loading Loading @@ -199,6 +201,26 @@ Global {974BA015-88F8-4948-BB8B-180EA417435B}.Release|x64.Build.0 = Release|x64 {974BA015-88F8-4948-BB8B-180EA417435B}.Release|x86.ActiveCfg = Release|x86 {974BA015-88F8-4948-BB8B-180EA417435B}.Release|x86.Build.0 = Release|x86 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|ARM.ActiveCfg = Debug|ARM {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|ARM.Build.0 = Debug|ARM {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|ARM64.ActiveCfg = Debug|ARM64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|ARM64.Build.0 = Debug|ARM64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|x64.ActiveCfg = Debug|x64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|x64.Build.0 = Debug|x64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|x86.ActiveCfg = Debug|x86 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Debug|x86.Build.0 = Debug|x86 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|Any CPU.ActiveCfg = Release|Any CPU {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|Any CPU.Build.0 = Release|Any CPU {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|ARM.ActiveCfg = Release|ARM {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|ARM.Build.0 = Release|ARM {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|ARM64.ActiveCfg = Release|ARM64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|ARM64.Build.0 = Release|ARM64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|x64.ActiveCfg = Release|x64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|x64.Build.0 = Release|x64 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|x86.ActiveCfg = Release|x86 {BB43C3BA-3085-4D81-9733-2BF398EAA6CF}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Loading
INAF.Apps.Uwp.SLabDataManager/App.xaml.cs +3 −1 Original line number Diff line number Diff line using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.Charts; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Apps.Uwp.SLabDataManager.Models; using INAF.Apps.Uwp.SLabDataManager.Services; using INAF.Apps.Uwp.SLabDataManager.ViewModels; Loading Loading @@ -76,6 +77,7 @@ namespace INAF.Apps.Uwp.SLabDataManager Ioc.Default.ConfigureServices( new ServiceCollection() /* singletons */ .AddSingleton<SpectrumChartOptionsModel>() .AddSingleton<Logger>(logger) .AddSingleton<SettingsHelper>() .AddSingleton<StorageItemsSettingsHelper>() Loading
INAF.Apps.Uwp.SLabDataManager/Charts/SpectrumChartOptionsModel.cs +185 −16 Original line number Diff line number Diff line using INAF.Libraries.NetStandard.ScienceModels; using INAF.Apps.Uwp.SLabDataManager.Constants; using INAF.Apps.Uwp.SLabDataManager.Helpers; using INAF.Libraries.NetStandard.ScienceModels; using INAF.Libraries.NetStandard.ScienceModels.Spectra; using INAF.Libraries.Uwp.Settings; using INAF.Libraries.Uwp.TelerikChartsExtensions; using System; using System.Collections.Generic; using System.Linq; using Telerik.UI.Xaml.Controls.Chart; using static INAF.Apps.Uwp.SLabDataManager.Constants.Enums; using static INAF.Libraries.NetStandard.ScienceModels.Enums.Enums; namespace INAF.Apps.Uwp.Charts { public class SpectrumChartOptionsModel : ObservableModel { public SpectrumChartOptionsModel(SpectrumModel spectrum) private readonly SettingsHelper settingsHelper; public SpectrumChartOptionsModel(SettingsHelper settingsHelper) { Spectrum = spectrum; this.settingsHelper = settingsHelper; WavelengthMeasureUnits = Enum.GetValues(typeof(WavelengthMeasureUnit)).Cast<WavelengthMeasureUnit>().ToList(); if (!tryReadWavelengthMeasureUnits()) SelectedWavelengthMeasureUnit = WavelengthMeasureUnit.Nanometers; MajorLinesVisibilityValues = Enum.GetValues(typeof(GridLineVisibility)).Cast<GridLineVisibility>().ToList(); if (!tryReadMajorLinesVisibility()) SelectedMajorLinesVisibility = GridLineVisibility.XY; StripLinesVisibilityValues = Enum.GetValues(typeof(GridLineVisibility)).Cast<GridLineVisibility>().ToList(); if (!tryReadStripLinesVisibility()) SelectedStripLinesVisibility = GridLineVisibility.XY; WavelengthMeasureUnits = Enum.GetValues(typeof(WavelengthMeasureUnit)).Cast<WavelengthMeasureUnit>().ToList(); SelectedWavelengthMeasureUnit = WavelengthMeasureUnit.Nanometers; ChartPanModeValues = Enum.GetValues(typeof(ChartPanZoomMode)).Cast<ChartPanZoomMode>().ToList(); if (!tryReadChartPanMode()) SelectedChartPanMode = ChartPanZoomMode.Both; ChartZoomModeValues = Enum.GetValues(typeof(ChartPanZoomMode)).Cast<ChartPanZoomMode>().ToList(); if (!tryReadChartZoomMode()) SelectedChartZoomMode = ChartPanZoomMode.Both; XAxisMajorStepValues = new List<double>(2); XAxisMajorStepValues.Add(0.1); XAxisMajorStepValues.Add(100); } public SpectrumModel Spectrum { get; set; } Loading @@ -47,7 +61,26 @@ namespace INAF.Apps.Uwp.Charts public GridLineVisibility SelectedMajorLinesVisibility { get { return selectedMajorLinesVisibility; } set { selectedMajorLinesVisibility = value; RaisePropertyChanged(nameof(SelectedMajorLinesVisibility)); } set { selectedMajorLinesVisibility = value; saveMajorLinesVisibility(value); RaisePropertyChanged(nameof(SelectedMajorLinesVisibility)); } } public bool tryReadMajorLinesVisibility() { bool isFound = false; string value = settingsHelper.get(Constants.MAJOR_LINES_VISIBILITY); if (!string.IsNullOrEmpty(value)) { SelectedMajorLinesVisibility = value.ToGridLineVisibility(); isFound = true; } return isFound; } private void saveMajorLinesVisibility(GridLineVisibility gridLineVisibility) { settingsHelper.save(Constants.MAJOR_LINES_VISIBILITY, gridLineVisibility.ToString()); } #endregion Loading @@ -56,7 +89,7 @@ namespace INAF.Apps.Uwp.Charts public GridLineVisibility SelectedStripLinesVisibility { get { return selectedStripLinesVisibility; } set { selectedStripLinesVisibility = value; RaisePropertyChanged(nameof(SelectedStripLinesVisibility)); } set { selectedStripLinesVisibility = value; saveStripLinesVisibility(value); RaisePropertyChanged(nameof(SelectedStripLinesVisibility)); } } private List<GridLineVisibility> stripLinesVisibilityValues; Loading @@ -65,6 +98,25 @@ namespace INAF.Apps.Uwp.Charts get { return stripLinesVisibilityValues; } set { stripLinesVisibilityValues = value; RaisePropertyChanged(nameof(StripLinesVisibilityValues)); } } public bool tryReadStripLinesVisibility() { bool isFound = false; string value = settingsHelper.get(Constants.STRIP_LINES_VISIBILITY); if (!string.IsNullOrEmpty(value)) { SelectedStripLinesVisibility = value.ToGridLineVisibility(); isFound = true; } return isFound; } private void saveStripLinesVisibility(GridLineVisibility gridLineVisibility) { settingsHelper.save(Constants.STRIP_LINES_VISIBILITY, gridLineVisibility.ToString()); } #endregion #region Pan mode Loading @@ -79,7 +131,26 @@ namespace INAF.Apps.Uwp.Charts public ChartPanZoomMode SelectedChartPanMode { get { return selectedChartPanMode; } set { selectedChartPanMode = value; RaisePropertyChanged(nameof(SelectedChartPanMode)); } set { selectedChartPanMode = value; saveChartPanMode(value); RaisePropertyChanged(nameof(SelectedChartPanMode)); } } public bool tryReadChartPanMode() { bool isFound = false; string value = settingsHelper.get(Constants.PAN_MODE); if (!string.IsNullOrEmpty(value)) { SelectedChartPanMode = value.ToChartPanZoomMode(); isFound = true; } return isFound; } private void saveChartPanMode(ChartPanZoomMode chartPanzoomMode) { settingsHelper.save(Constants.PAN_MODE, chartPanzoomMode.ToString()); } #endregion Loading @@ -95,7 +166,26 @@ namespace INAF.Apps.Uwp.Charts public ChartPanZoomMode SelectedChartZoomMode { get { return selectedChartZoomMode; } set { selectedChartZoomMode = value; RaisePropertyChanged(nameof(SelectedChartZoomMode)); } set { selectedChartZoomMode = value; saveChartZoomMode(value); RaisePropertyChanged(nameof(SelectedChartZoomMode)); } } public bool tryReadChartZoomMode() { bool isFound = false; string value = settingsHelper.get(Constants.ZOOM_MODE); if (!string.IsNullOrEmpty(value)) { SelectedChartZoomMode = value.ToChartPanZoomMode(); isFound = true; } return isFound; } private void saveChartZoomMode(ChartPanZoomMode chartPanzoomMode) { settingsHelper.save(Constants.ZOOM_MODE, chartPanzoomMode.ToString()); } #endregion Loading @@ -104,14 +194,93 @@ namespace INAF.Apps.Uwp.Charts public WavelengthMeasureUnit SelectedWavelengthMeasureUnit { get { return selectedWavelengthMeasureUnit; } set { selectedWavelengthMeasureUnit = value; RaisePropertyChanged(nameof(SelectedWavelengthMeasureUnit)); } set { selectedWavelengthMeasureUnit = value; saveWavelengthMeasureUnits(value); switchXAxisValues(); RaisePropertyChanged(nameof(SelectedWavelengthMeasureUnit)); } } public List<WavelengthMeasureUnit> WavelengthMeasureUnits { get; set; } public bool tryReadWavelengthMeasureUnits() { bool isFound = false; string value = settingsHelper.get(Constants.WAVELENGTH_MEASURE_UNITS); if (!string.IsNullOrEmpty(value)) { SelectedWavelengthMeasureUnit = value.ToWavelengthMeasureUnit(); isFound = true; } return isFound; } private void saveWavelengthMeasureUnits(WavelengthMeasureUnit wavelengthMeasureUnit) { settingsHelper.save(Constants.WAVELENGTH_MEASURE_UNITS, wavelengthMeasureUnit.ToString()); } #endregion #region major step private double selectedXAxisMajorStep; public double SelectedXAxisMajorStep { get { return selectedXAxisMajorStep; } set { selectedXAxisMajorStep = value; RaisePropertyChanged(nameof(SelectedXAxisMajorStep)); } } public List<double> XAxisMajorStepValues { get; private set; } private void setXAxisMajorStep() { switch (SelectedWavelengthMeasureUnit) { case WavelengthMeasureUnit.Nanometers: SelectedXAxisMajorStep = XAxisMajorStepValues.FirstOrDefault(x => x == Constants.X_AXIS_MAJOR_STEP_NANOMETERS); break; case WavelengthMeasureUnit.Microns: SelectedXAxisMajorStep = XAxisMajorStepValues.FirstOrDefault(x => x == Constants.X_AXIS_MAJOR_STEP_MICRONS); break; } } #endregion #region axes boundaries public AxisBoundariesModel XAxisBoundaries { get; private set; } public AxisBoundariesModel YAxisBoundaries { get; private set; } #endregion public string XAxisTitle { get; set; } public string YAxisTitle { get; set; } public void createSummary() { double xmax = Spectrum.Elements.Max(x => x.X); double xmin = Spectrum.Elements.Min(x => x.X); XAxisBoundaries = new AxisBoundariesModel("x", xmin, xmax, Spectrum.Elements.FirstOrDefault().MeasureUnit); double ymax = Spectrum.Elements.Max(x => x.Y); double ymin = Spectrum.Elements.Min(x => x.Y); YAxisBoundaries = new AxisBoundariesModel("y", ymin, ymax, Spectrum.Elements.FirstOrDefault().MeasureUnit); } public void setSpectrum(SpectrumModel spectrum) { Spectrum = spectrum; createSummary(); } private void switchXAxisValues() { if (Spectrum != null) { Spectrum.switchToMeasureUnit(SelectedWavelengthMeasureUnit); XAxisBoundaries.switchToMeasureUnit(SelectedWavelengthMeasureUnit); setXAxisMajorStep(); } } } }
INAF.Apps.Uwp.SLabDataManager/Constants/Constants.cs +10 −0 Original line number Diff line number Diff line Loading @@ -10,5 +10,15 @@ public static readonly string RAW_SPECTRUM_FILE_TOKEN = "rawspectrumfiletoken"; public static readonly string REF_SPECTRUM_FILE = "refspectrumfile"; public static readonly string REF_SPECTRUM_FILE_TOKEN = "refspectrumfiletoken"; public static readonly string X_AXIS_MAJOR_STEP = "xaxismajorstep"; public static readonly string WAVELENGTH_MEASURE_UNITS = "wavelengthmeasureunits"; public static readonly string MAJOR_LINES_VISIBILITY = "majorlinesvisibility"; public static readonly string STRIP_LINES_VISIBILITY = "striplinesvisibility"; public static readonly string PAN_MODE = "panmode"; public static readonly string ZOOM_MODE = "zoommode"; public static readonly double X_AXIS_MAJOR_STEP_MICRONS = 0.1; public static readonly double X_AXIS_MAJOR_STEP_NANOMETERS = 100; } }
INAF.Apps.Uwp.SLabDataManager/Converters/Converters.cs +83 −61 Original line number Diff line number Diff line Loading @@ -61,67 +61,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters } } public sealed class XAxisTitleConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { WorkingItemsModel workingItemsModel = Ioc.Default.GetService<WorkingItemsModel>(); return "SpectrumXAxisTitle".GetText().Replace("r_v", workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit.GetDescription()); } catch (Exception) { return string.Empty; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class XScaleLabelFormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { string format = string.Empty; WorkingItemsModel workingItemsModel = Ioc.Default.GetService<WorkingItemsModel>(); var selectedUnitMeasure = workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit; switch (selectedUnitMeasure) { //case Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Nanometers: // format = "N"; // break; case Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Microns: format = "{0:0.###E+0}"; break; default: format = "{0:G}"; break; } return format; } catch (Exception) { return "{0:G}"; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class StatusToImageConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) Loading Loading @@ -207,4 +146,87 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters throw new NotImplementedException(); } } public sealed class ThemeBrushConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { return AppThemeHelper.GetThemeValue<SolidColorBrush>((string)parameter); } catch (Exception) { return string.Empty; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class XAxisTitleConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { WorkingItemsModel workingItemsModel = Ioc.Default.GetService<WorkingItemsModel>(); return "SpectrumXAxisTitle".GetText().Replace("r_v", workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit.GetDescription()); } catch (Exception) { return string.Empty; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class XScaleLabelFormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { //try //{ // string format = string.Empty; // WorkingItemsModel workingItemsModel = Ioc.Default.GetService<WorkingItemsModel>(); // var selectedUnitMeasure = workingItemsModel.SpectrumChartOptions.SelectedWavelengthMeasureUnit; // switch (selectedUnitMeasure) // { // //case Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Nanometers: // // format = "N"; // // break; // case Libraries.NetStandard.ScienceModels.Enums.Enums.WavelengthMeasureUnit.Microns: // format = "{0:0.###E-0}"; // break; // default: // format = "{0:G}"; // break; // } // return format; //} //catch (Exception) //{ // return "{0:G}"; //} return "{0:G}"; ; } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } }