Beispiel #1
0
        /// <summary>
        /// UT only!
        /// </summary>
        internal PathSeriesDescriptorViewModel(PathSeriesDescriptor descriptor, IHtmlMarkupBehavior <HtmlTableMarker> markupBehavior)
            : base(descriptor, markupBehavior)
        {
            Value = "";

            // initialize with invalid values first so that marker gets updated when we set
            // some valid data from descriptor below
            myValuesPosition = -1;
            myTimesPosition  = -1;

            SelectedFigure = Figures.FirstOrDefault(d => d.Name == descriptor.Figure);
            Path           = descriptor.Path;

            if (descriptor.ValueFormat == null)
            {
                descriptor.ValueFormat = new FormatColumn("value", typeof(double));
            }
            ValueFormat = descriptor.ValueFormat;
            PropertyChangedEventManager.AddHandler(ValueFormat, OnValueFormatChanged, string.Empty);

            if (descriptor.TimeFormat == null)
            {
                descriptor.TimeFormat = new FormatColumn("year", typeof(int));
            }
            TimeFormat = descriptor.TimeFormat;

            IsValid = false;
            if (descriptor.ValuesLocator != null)
            {
                ValuesPattern  = ((StringContainsLocator)Descriptor.ValuesLocator).Pattern;
                ValuesPosition = Descriptor.ValuesLocator.HeaderSeriesPosition;
            }
            else
            {
                descriptor.ValuesLocator = new StringContainsLocator();
                ValuesPosition           = -1;
                ValuesPattern            = null;
            }

            if (descriptor.TimesLocator != null)
            {
                TimesPosition = ((AbsolutePositionLocator)Descriptor.TimesLocator).SeriesPosition;
            }
            else
            {
                Descriptor.TimesLocator = new AbsolutePositionLocator {
                    HeaderSeriesPosition = 0
                };
                TimesPosition = -1;
            }

            SelectedOrientation = Descriptor.Orientation;

            SkipValues = string.Join(",", descriptor.Excludes);

            ValidateValuesLocator();
            ValidateTimesLocator();
        }
        protected FigureDescriptorViewModelBase(TFigureDescriptor descriptor, IHtmlMarkupBehavior <TMarker> markupBehavior)
        {
            Contract.RequiresNotNull(descriptor, "descriptor");
            Contract.RequiresNotNull(markupBehavior, "markupBehavior");

            Descriptor = descriptor;

            Figures = Dynamics.AllFigures
                      .OrderBy(d => d.Name)
                      .ToList();

            MarkupBehavior = markupBehavior;
            MarkupBehavior.SelectionChanged += OnSelectionChanged;
        }
        /// <summary>
        /// UT only!
        /// </summary>
        internal PathCellDescriptorViewModel(ILutService lutService, PathCellDescriptor descriptor, IHtmlMarkupBehavior <HtmlTableMarker> markupBehavior)
            : base(descriptor, markupBehavior)
        {
            myLutService = lutService;

            Value = "";

            // initialize with invalid values first so that marker gets updated when we set
            // some valid data from descriptor below
            myColumnPosition = -1;
            myRowPosition    = -1;

            SelectedFigure = Figures.FirstOrDefault(d => d.Name == Descriptor.Figure);
            Path           = Descriptor.Path;

            if (Descriptor.ValueFormat == null)
            {
                Descriptor.ValueFormat = new ValueFormat(typeof(double));
            }
            ValueFormat = Descriptor.ValueFormat;
            PropertyChangedEventManager.AddHandler(ValueFormat, OnValueFormatChanged, string.Empty);

            SelectedCurrency = myLutService.CurrenciesLut.Currencies.SingleOrDefault(c => c.Symbol == descriptor.Currency);

            IsColumnValid = false;
            if (descriptor.Column != null)
            {
                ColumnPattern  = (( StringContainsLocator )Descriptor.Column).Pattern;
                ColumnPosition = Descriptor.Column.HeaderSeriesPosition;
            }
            else
            {
                Descriptor.Column = new StringContainsLocator();
                ColumnPosition    = -1;
                ColumnPattern     = null;
            }

            IsRowValid = false;
            if (descriptor.Row != null)
            {
                RowPattern  = (( StringContainsLocator )Descriptor.Row).Pattern;
                RowPosition = Descriptor.Row.HeaderSeriesPosition;
            }
            else
            {
                Descriptor.Row = new StringContainsLocator();
                RowPosition    = -1;
                RowPattern     = null;
            }

            ValidateRow();
            ValidateColumn();
        }