Commit a438b702 authored by Francesco Carraro's avatar Francesco Carraro
Browse files

added SampleDataUserControl management to other right-sided usercontrols

parent 82271bdc
Loading
Loading
Loading
Loading
+56 −15
Original line number Diff line number Diff line
@@ -24,11 +24,13 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts

            WavelengthSeparators = new ObservableCollection<WavelengthModel>();

            tryReadAreSeparatorsVisible();
            if (!tryReadAreSeparatorsVisible())
                AreSeparatorsVisible = true;

            tryReadNumOfPointsForAlignment(3);

            tryReadIsPinned();
            if (!tryReadIsPinnedPending())
                IsPinnedPending = false;

            tryReadWavelengthModels();

@@ -42,12 +44,28 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
        public bool AreSeparatorsVisible
        {
            get { return areSeparatorsVisible; }
            set { areSeparatorsVisible = value; saveAreSeparatorsVisible(value); RaisePropertyChanged(nameof(AreSeparatorsVisible)); }
            set
            {
                areSeparatorsVisible = value;
                saveAreSeparatorsVisible();
                RaisePropertyChanged(nameof(AreSeparatorsVisible));
            }
        }

        /* contains value read from settings, when user navigate to the chart page, if value is true, then apply the value to 
         * the IsPinRequested and IsPinned variables, to enable the pinned version of flyout */
        public bool IsPinnedPending { get; private set; }
        private bool isPinnedPending;

        public bool IsPinnedPending
        {
            get { return isPinnedPending; }
            set
            {
                isPinnedPending = value;
                saveIsPinnedPending();
            }
        }


        //private bool isPinned;
        //public bool IsPinned
@@ -75,7 +93,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
        public int NumOfPointsForAlignment
        {
            get { return numOfPointsForAlignment; }
            set { numOfPointsForAlignment = value; System.Diagnostics.Debug.WriteLine($"numOfPointsForAlignment: {numOfPointsForAlignment}"); saveNumOfPointsForAlignment(value); RaisePropertyChanged(nameof(AreSeparatorsVisible)); }
            set
            {
                numOfPointsForAlignment = value;
                saveNumOfPointsForAlignment(value);
                RaisePropertyChanged(nameof(NumOfPointsForAlignment));
            }
        }

        public ObservableCollection<WavelengthModel> WavelengthSeparators { get; private set; }
@@ -96,19 +119,19 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
        #endregion

        #region save/read settings
        private void saveAreSeparatorsVisible(bool areVisible)
        private void saveAreSeparatorsVisible()
        {
            settingsHelper.save(Constants.Constants.ARE_SEPARATORS_VISIBLE, areVisible.ToString());
            settingsHelper.save(nameof(AreSeparatorsVisible), AreSeparatorsVisible.ToString());
        }

        private void saveIsPinned(bool isPinned)
        private void saveIsPinnedPending()
        {
            settingsHelper.save(Constants.Constants.IS_ALIGNMENT_FLYOUT_PINNED, isPinned.ToString());
            settingsHelper.save(nameof(IsPinnedPending), IsPinnedPending.ToString());
        }

        private void saveNumOfPointsForAlignment(int numOfPoints)
        {
            settingsHelper.save(Constants.Constants.NUM_OF_POINTS_FOR_ALIGNMENT, numOfPoints.ToString());
            settingsHelper.save(nameof(NumOfPointsForAlignment), numOfPoints);
        }

        private void saveWavelengthModel(int index, double value, double semiRange, double step, WavelengthMeasureUnit wavelengthMeasureUnit)
@@ -116,19 +139,37 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts
            settingsHelper.save<WavelengthSerializableModel>($"index{index}", new WavelengthSerializableModel(index, value, semiRange, step, (int)wavelengthMeasureUnit));
        }

        public void tryReadAreSeparatorsVisible()
        public bool tryReadAreSeparatorsVisible()
        {
            bool isFound = false;

            string value = settingsHelper.get(nameof(AreSeparatorsVisible));
            if (!string.IsNullOrEmpty(value))
            {
            AreSeparatorsVisible = settingsHelper.getValue<bool>(Constants.Constants.ARE_SEPARATORS_VISIBLE);
                AreSeparatorsVisible = value.ToBool();
                isFound = true;
            }

            return isFound;
        }

        public void tryReadIsPinned()
        public bool tryReadIsPinnedPending()
        {
            bool isFound = false;

            string value = settingsHelper.get(nameof(IsPinnedPending));
            if (!string.IsNullOrEmpty(value))
            {
            IsPinnedPending = settingsHelper.getValue<bool>(Constants.Constants.IS_ALIGNMENT_FLYOUT_PINNED);
                IsPinnedPending = value.ToBool();
                isFound = true;
            }

            return isFound;
        }

        public void tryReadNumOfPointsForAlignment(int defaultValue)
        {
            NumOfPointsForAlignment = settingsHelper.getValueWithDefault<int>(Constants.Constants.NUM_OF_POINTS_FOR_ALIGNMENT, defaultValue);
            NumOfPointsForAlignment = settingsHelper.getValueWithDefault<int>(nameof(NumOfPointsForAlignment), defaultValue);
        }

        private bool tryReadWavelengthModel(int index)
+0 −4
Original line number Diff line number Diff line
@@ -13,10 +13,6 @@
        public static readonly string PAN_MODE = "panmode";
        public static readonly string ZOOM_MODE = "zoommode";

        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";

+21 −2
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI
            return storyboard;
        }

        public static Storyboard GetTranslateXAnimation(FrameworkElement frameworkElement,
        public static Storyboard GetTranslateXDirectionInAnimation(FrameworkElement frameworkElement,
                                                                   double from)
        {
            DoubleAnimation translateAnimation = new DoubleAnimation()
@@ -62,5 +62,24 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI
            storyboard.Children.Add(translateAnimation);
            return storyboard;
        }

        public static Storyboard GetTranslateXDirectionOutAnimation(FrameworkElement frameworkElement,
                                                                    double to)
        {
            DoubleAnimation translateAnimation = new DoubleAnimation()
            {
                From = 0,
                To = to,
                Duration = TimeSpan.FromMilliseconds(300),
                EnableDependentAnimation = true,
                EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }
            };
            Storyboard.SetTarget(translateAnimation, frameworkElement);
            Storyboard.SetTargetProperty(translateAnimation, "(UIElement.RenderTransform).(TranslateTransform.X)");

            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(translateAnimation);
            return storyboard;
        }
    }
}
+32 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ using INAF.Apps.Uwp.SLabDataManager.ViewModels;
using INAF.Libraries.NetStandard.Math.Fit.Linear.Models;
using INAF.Libraries.NetStandard.Math.Models;
using INAF.Libraries.NetStandard.ScienceModels.Spectra;
using INAF.Libraries.Uwp.Converters;
using INAF.Libraries.Uwp.Logging;
using Microsoft.Extensions.DependencyInjection;
using System;
@@ -12,7 +13,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Telerik.UI.Xaml.Controls.Chart;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
using static INAF.Libraries.NetStandard.SLabCommonModels.Enums.Enums;
using SpectrumModel = INAF.Apps.Uwp.SLabDataManager.Models.Spectrum.SpectrumModel;

@@ -152,6 +156,34 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI.Chart
            }
        }

        #region separators
        public void createCartesianGridLineAnnotations(RadCartesianChart chart,
                                                       bool areSeparatorsVisible)
        {
            foreach (var separator in workingItems.SpectraContainer.SpectrumAlignmentConfig.WavelengthSeparators)
                chart.Annotations.Add(getAnnotation(chart, separator, areSeparatorsVisible));

            chart.UpdateLayout();
        }

        private CartesianGridLineAnnotation getAnnotation(RadCartesianChart chart,
                                                          WavelengthModel separator,
                                                          bool areSeparatorsVisible)
        {
            var annotation = new CartesianGridLineAnnotation()
            {
                Axis = chart.HorizontalAxis,
                Stroke = new SolidColorBrush(Colors.LightGreen),
                StrokeThickness = 2,
                Visibility = (areSeparatorsVisible ? Visibility.Visible : Visibility.Collapsed)
            };
            annotation.SetBinding(CartesianGridLineAnnotation.ValueProperty, new Binding() { Path = new PropertyPath("CurrentValue"), Source = separator, Mode = BindingMode.OneWay });
            annotation.SetBinding(CartesianGridLineAnnotation.LabelProperty, new Binding() { Path = new PropertyPath("CurrentValue"), Source = separator, Mode = BindingMode.OneWay });
            annotation.SetBinding(CartesianGridLineAnnotation.VisibilityProperty, new Binding() { Path = new PropertyPath("AreSeparatorsVisible"), Source = workingItems.SpectraContainer.SpectrumAlignmentConfig, Converter = new BoolToVisibilityConverter(), Mode = BindingMode.OneWay });
            return annotation;
        }
        #endregion

        #region highlight/lowlight
        public void setSegmentHighlight(RadCartesianChart chart,
                                        SegmentFitModel segmentFit,
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI.Chart
        #region settings
        private void saveIsAddingPointsForContinuumRemovalAllowed()
        {
            settingsHelper.save(nameof(IsAddingPointsForContinuumRemovalAllowed), IsAddingPointsForContinuumRemovalAllowed.ToString());
            settingsHelper.save(nameof(IsAddingPointsForContinuumRemovalAllowed), IsAddingPointsForContinuumRemovalAllowed);
        }

        public void tryReadIsAddingPointsForContinuumRemovalAllowed()
Loading