Commit 2e43c03c authored by Francesco Carraro's avatar Francesco Carraro
Browse files

added retrieval of smoothing settings by cloud; moved smoothing by segments...

added retrieval of smoothing settings by cloud; moved smoothing by segments procedure into smoothingViewModel/smoothingHelper to be coherent with alignement way of doing processings
parent 6af7a2c3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ using INAF.Apps.Uwp.SLabDataManager.ViewModels;
using INAF.Apps.Uwp.SLabDataManager.ViewModels.ContentDialogsViewModel;
using INAF.Apps.Uwp.SLabDataManager.ViewModels.Other;
using INAF.Apps.Uwp.SLabDataManager.ViewModels.UserControlViewModels;
using INAF.Libraries.NetStandard.Math.Alignment;
using INAF.Libraries.NetStandard.Math.Fit.Linear;
using INAF.Libraries.NetStandard.Math.Fit.Spline;
using INAF.Libraries.NetStandard.Math.Models;
@@ -151,6 +150,7 @@ namespace INAF.Apps.Uwp.SLabDataManager
                .AddScoped<MultipleSelectionViewModel>()
                .AddScoped<ProcessedSpectraContainer>()
                .AddScoped<ResultingSpectrumInfo>()
                .AddScoped<SmoothingHelper>()
                .AddScoped<StorageItemsHelper>()
                /* transient */
                .AddTransient<AnimationsHelper>()
@@ -171,8 +171,8 @@ namespace INAF.Apps.Uwp.SLabDataManager
                .AddTransient<SplineProcessingHelper>()
                .AddTransient<ZoomHelper>()
                .AddTransient<XmlAssetConfigReader>()
                .AddTransient<XmlAssetSmoothingDefaultBoundariesReader>()
                .AddTransient<XmlHelper>()
                .AddTransient<XmlSerializationHelper>()
                .AddTransient<XmlSpectrumFileReader>()
                /* usercontrols viewmodels */
                .AddScoped<AlignmentViewModel>()
+0 −7
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8" ?>
<defaults>
	<boundary>350</boundary>
	<boundary>700</boundary>
	<boundary>1500</boundary>
	<boundary>2500</boundary>
</defaults>
 No newline at end of file
+0 −18
Original line number Diff line number Diff line
@@ -122,24 +122,6 @@ namespace INAF.Apps.Uwp.SLabDataManager.Extensions
            return string.Join(string.Empty, ".", fileExt.GetDescription());
        }

        public static SmoothingSegment ToSmoothingSegment(this SegmentSmoothingSettingsModel segmentSettings)
        {
            return new SmoothingSegment(segmentSettings.Id,
                                        (double)segmentSettings.XStart,
                                        (double)segmentSettings.XEnd,
                                        segmentSettings.WindowSize,
                                        segmentSettings.PolynomialOrder);
        }

        public static SegmentSmoothingSettingsModel ToSegmentSmoothingSettings(this SmoothingSegment segment)
        {
            return new SegmentSmoothingSettingsModel(segment.Id,
                                                     (double)segment.LowerBoundary,
                                                     (double)segment.HigherBoundary,
                                                     segment.WindowSize,
                                                     segment.PolynomialOrder);
        }

        public static SolidColorBrush ToSolidColorBrush(this string hexstring)
        {
            hexstring = hexstring.Replace("#", string.Empty);
+0 −63
Original line number Diff line number Diff line
using INAF.Apps.Uwp.SLabDataManager.Charts.Smoothing;
using INAF.Libraries.NetStandard.Extensions;
using INAF.Libraries.Uwp.Logging;
using INAF.Libraries.Uwp.Xml;
using System;
using System.Threading.Tasks;
using Windows.Data.Xml.Dom;
using Windows.Storage;

namespace INAF.Apps.Uwp.SLabDataManager.Helpers.FileReaders
{
    public sealed class XmlAssetSmoothingDefaultBoundariesReader
    {
        private readonly SmoothingSegmentsContainer smoothingBoundariesContainer;
        private readonly XmlHelper xmlHelper;
        private readonly Logger logger;

        public XmlAssetSmoothingDefaultBoundariesReader(SmoothingSegmentsContainer smoothingBoundariesContainer,
                                                        XmlHelper xmlHelper,
                                                        Logger logger)
        {
            this.smoothingBoundariesContainer = smoothingBoundariesContainer;
            this.xmlHelper = xmlHelper;
            this.logger = logger;

            smoothingBoundariesContainer.init();
        }

        public async Task readFileAsync()
        {
            StorageFile file = await xmlHelper.getAssetXmlFileAsync("smoothingdefaults.xml");
            if (file == null)
            {
                logger.Write<XmlAssetSmoothingDefaultBoundariesReader>($"config.xml NOT FOUND!", Serilog.Events.LogEventLevel.Error);
                return;
            }

            XmlDocument dom = await xmlHelper.getXmlDocumentAsync(file);
            if (dom == null)
            {
                logger.Write<XmlAssetSmoothingDefaultBoundariesReader>($"Error while parsing smoothingdefaults.xml!", Serilog.Events.LogEventLevel.Error);
                return;
            }

            try
            {
                XmlNodeList boundaryNodes = dom.SelectNodes("descendant::boundary");
                foreach (var node in boundaryNodes)
                {
                    string _currentValue = node.InnerText;
                    double currentValue = _currentValue.ToDoubleInvariant();

                    smoothingBoundariesContainer.add(currentValue);
                }
            }
            catch (Exception ex)
            {
                logger.Write<XmlAssetSmoothingDefaultBoundariesReader>($"Error while parsing smoothingdefaults.xml - ex: {ex.Message}", Serilog.Events.LogEventLevel.Error);
                return;
            }
        }
    }
}
+2 −5
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
    <WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
    <PackageCertificateKeyFile>
    </PackageCertificateKeyFile>
    <PackageCertificateThumbprint>722552882744F15508C43E22D2BCA8CA5D65112F</PackageCertificateThumbprint>
    <PackageCertificateThumbprint>FC090018872EA8683813EDCA0FEAD5D0F7B3E266</PackageCertificateThumbprint>
    <AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
    <GenerateAppInstallerFile>True</GenerateAppInstallerFile>
    <AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
@@ -191,7 +191,6 @@
    <Compile Include="Models\Chart\Processing\AppProcessingResult.cs" />
    <Compile Include="Models\Chart\SelectedRefBand.cs" />
    <Compile Include="Models\Containers\SpectraContainer.cs" />
    <Compile Include="Models\Chart\Smoothing\SmoothingSegment.cs" />
    <Compile Include="Models\Chart\Smoothing\SmoothingSegmentsContainer.cs" />
    <Compile Include="Models\Chart\SpectrumChartOptionsModel.cs" />
    <Compile Include="Constants\Constants.cs" />
@@ -257,7 +256,6 @@
    <Compile Include="ViewModels\Other\MultipleSelectionViewModel.cs" />
    <Compile Include="ViewModels\UserControlViewModels\ChartPanels\AlignmentViewModel.cs" />
    <Compile Include="Helpers\VisualTreeHelpers.cs" />
    <Compile Include="Helpers\FileReaders\AssetFiles\XmlAssetSmoothingDefaultBoundariesReader.cs" />
    <Compile Include="Models\Containers\RecentStorageItemsContainer.cs" />
    <Compile Include="Models\SpectrumSummaryModel.cs" />
    <Compile Include="Models\WorkingFoldersContainer.cs" />
@@ -579,7 +577,6 @@
    <Content Include="Assets\Wide310x150Logo.scale-150.png" />
    <Content Include="Assets\Wide310x150Logo.scale-400.png" />
    <Content Include="Assets\xml\config.xml" />
    <Content Include="Assets\xml\smoothingdefaults.xml" />
    <Content Include="Assets\logbook\logbook.xml" />
    <Content Include="appsettings.development.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -597,7 +594,7 @@
    <Content Include="appsettings.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
    <None Include="inaf-iaps.pfx" />
    <None Include="inaf-iaps-2.pfx" />
    <None Include="INAF.Apps.Uwp.SLabDataManager_TemporaryKey.pfx" />
  </ItemGroup>
  <ItemGroup>
Loading