예제 #1
0
        private NumericSequence CalculateElementSequence(ScaleElementDefinition element, NumericScaleUnit defaultUnit)
        {
            double?interval = Scale <double, double, NumericScaleUnit> .GetInterval(element);

            double?intervalOffset = Scale <double, double, NumericScaleUnit> .GetIntervalOffset(element);

            NumericScaleUnit?intervalUnit = Scale <double, double, NumericScaleUnit> .GetIntervalUnit(element);

            NumericScaleUnit numericScaleUnit = intervalUnit.HasValue ? intervalUnit.Value : defaultUnit;
            int?maxCount1 = Scale <double, double, NumericScaleUnit> .GetMaxCount(element);

            int             maxCount2       = maxCount1.HasValue ? maxCount1.Value : this.MaxCount;
            NumericSequence numericSequence = (NumericSequence)null;

            switch (numericScaleUnit)
            {
            case NumericScaleUnit.Number:
                numericSequence = NumericSequence.Calculate(new NumericRangeInfo((DoubleR10)this.ActualViewMinimum, (DoubleR10)this.ActualViewMaximum), interval, intervalOffset, maxCount2, int.MinValue, (DoubleR10[])null, true, 1.0);
                break;

            case NumericScaleUnit.MajorInterval:
                numericSequence = interval.HasValue || intervalOffset.HasValue ? (NumericSequence)RelativeSequence.Calculate(this._majorSequence, interval, intervalOffset, 1.0) : this._majorSequence;
                break;

            case NumericScaleUnit.MinorInterval:
                numericSequence = interval.HasValue || intervalOffset.HasValue ? (NumericSequence)RelativeSequence.Calculate(this._minorSequence, interval, intervalOffset, 1.0) : this._minorSequence;
                break;
            }
            return(numericSequence);
        }
예제 #2
0
        private IEnumerable <ScalePosition> Project(IList <Category> categories, ScaleElementDefinition element, CategoryScaleUnit defaultUnit)
        {
            this.RecalculateIfEmpty();
            double?interval1 = Scale <double, double, CategoryScaleUnit> .GetInterval(element);

            double?intervalOffset = Scale <double, double, CategoryScaleUnit> .GetIntervalOffset(element);

            CategoryScaleUnit?intervalUnit = Scale <double, double, CategoryScaleUnit> .GetIntervalUnit(element);

            double            interval2         = interval1.HasValue ? interval1.Value : 1.0;
            double            num1              = intervalOffset.HasValue ? intervalOffset.Value : 0.0;
            CategoryScaleUnit categoryScaleUnit = intervalUnit.HasValue ? intervalUnit.Value : defaultUnit;
            double            num2              = defaultUnit == CategoryScaleUnit.MinorInterval ? 0.5 : 0.0;
            NumericSequence   numericSequence   = defaultUnit == CategoryScaleUnit.MinorInterval ? this._minorSequence : this._majorSequence;
            NumericSequence   sequence          = (NumericSequence)null;
            NumericRangeInfo  range             = new NumericRangeInfo((DoubleR10)this.ActualMinimum, (DoubleR10)this.ActualMaximum);

            switch (categoryScaleUnit)
            {
            case CategoryScaleUnit.Index:
                sequence = interval2 != this.ActualMajorInterval || num1 != this.ActualMinorIntervalOffset ? NumericSequence.Calculate(range, new double?(interval2), new double?(num1 + num2), 100, int.MinValue, (DoubleR10[])null, true, 1.0) : numericSequence;
                break;

            case CategoryScaleUnit.MajorInterval:
                sequence = interval2 != this.ActualMajorInterval || num1 != this.ActualMajorIntervalOffset ? (NumericSequence)RelativeSequence.Calculate(this._majorSequence, new double?(interval2), new double?(num1), 1.0) : this._majorSequence;
                break;

            case CategoryScaleUnit.MinorInterval:
                sequence = interval2 != this.ActualMinorInterval || num1 != this.ActualMinorIntervalOffset ? (NumericSequence)RelativeSequence.Calculate(this._minorSequence, new double?(interval2), new double?(num1 + 0.5), 1.0) : this._minorSequence;
                break;
            }
            return(this.Project(categories, sequence, interval2));
        }
예제 #3
0
 private IEnumerable <ScalePosition> Project(ScaleElementDefinition element, DateTimeSequence sequence)
 {
     this.RecalculateIfEmpty();
     foreach (DateTime dateTime in sequence)
     {
         yield return(new ScalePosition((object)dateTime, this.Project(dateTime)));
     }
 }
예제 #4
0
 internal void SetScale(ScaleElementDefinition element)
 {
     if (element == null)
     {
         return;
     }
     element.Scale            = this;
     element.PropertyChanged += new PropertyChangedEventHandler(this.ScaleElement_PropertyChanged);
 }
예제 #5
0
        private static void OnIntervalUnitAttachedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ScaleElementDefinition element = d as ScaleElementDefinition;
            Scale <TPosition, TInterval, TScaleUnit> scale = element.Scale as Scale <TPosition, TInterval, TScaleUnit>;
            TScaleUnit?newValue = (TScaleUnit?)e.NewValue;
            TScaleUnit?oldValue = (TScaleUnit?)e.OldValue;

            scale.OnIntervalUnitAttachedPropertyChanged(element, newValue, oldValue);
        }
예제 #6
0
        protected virtual void OnElementChanged(ScaleElementDefinition element)
        {
            EventHandler eventHandler = this.ElementChanged;

            if (eventHandler == null)
            {
                return;
            }
            eventHandler((object)element, EventArgs.Empty);
        }
예제 #7
0
        private IEnumerable <ScalePosition> Project(ScaleElementDefinition element, NumericScaleUnit defaultUnit)
        {
            this.RecalculateIfEmpty();
            NumericSequence sequence  = this.CalculateElementSequence(element, defaultUnit);
            Range <double>  fromRange = new Range <double>(this.ActualViewMinimum, this.ActualViewMaximum);

            foreach (DoubleR10 doubleR10 in sequence)
            {
                double x = (double)doubleR10;
                yield return(new ScalePosition((object)x, RangeHelper.Project(fromRange, x, Scale.PercentRange)));
            }
        }
예제 #8
0
        public override IEnumerable <ScaleElementDefinition> ProjectElements()
        {
            this.MinorTickmarkDefinition.Positions = this.Project((ScaleElementDefinition)this.MinorTickmarkDefinition, this._minorSequence);
            this.MajorTickmarkDefinition.Positions = this.Project((ScaleElementDefinition)this.MajorTickmarkDefinition, this._majorSequence);
            yield return((ScaleElementDefinition)this.MinorTickmarkDefinition);

            yield return((ScaleElementDefinition)this.MajorTickmarkDefinition);

            ScaleElementDefinition majorLabel = (ScaleElementDefinition)this.GetLabel(this._majorSequence.Unit);

            majorLabel.Positions = this.Project(majorLabel, this._majorSequence);
            yield return(majorLabel);
        }
예제 #9
0
 public static int?GetMaxCount(ScaleElementDefinition element)
 {
     return((int?)element.GetValue(Scale <TPosition, TInterval, TScaleUnit> .MaxCountAttachedProperty));
 }
예제 #10
0
 public static void SetMaxCount(ScaleElementDefinition element, int?value)
 {
     element.SetValue(Scale <TPosition, TInterval, TScaleUnit> .MaxCountAttachedProperty, (object)value);
 }
예제 #11
0
 protected virtual void OnIntervalUnitAttachedPropertyChanged(ScaleElementDefinition element, TScaleUnit?newValue, TScaleUnit?oldValue)
 {
     this.OnElementChanged(element);
 }
예제 #12
0
 public static TScaleUnit?GetIntervalUnit(ScaleElementDefinition element)
 {
     return((TScaleUnit?)element.GetValue(Scale <TPosition, TInterval, TScaleUnit> .IntervalUnitAttachedProperty));
 }
예제 #13
0
 public static void SetIntervalUnit(ScaleElementDefinition element, TPosition?value)
 {
     element.SetValue(Scale <TPosition, TInterval, TScaleUnit> .IntervalUnitAttachedProperty, (object)value);
 }
예제 #14
0
        private IEnumerable <ScalePosition> ProjectMajor(IList <Category> categories, ScaleElementDefinition definition)
        {
            this.RecalculateIfEmpty();
            int maxCount = this.MaxCount * 2;

            if (categories.Count <= maxCount || categories.Count <= 50)
            {
                Range <double> fromRange    = new Range <double>(this.ActualViewMinimum, this.ActualViewMaximum);
                Category       lastCategory = (Category)null;
                foreach (Category category in (IEnumerable <Category>)categories)
                {
                    double bucketMinX = (double)(this._minLeafIndex + category.LeafIndexRange.Minimum);
                    double bucketMaxX = (double)(this._minLeafIndex + category.LeafIndexRange.Maximum);
                    double x          = bucketMinX;
                    yield return(new ScalePosition(category.Content, RangeHelper.Project(fromRange, x, Scale.PercentRange), RangeHelper.Project(fromRange, bucketMinX, Scale.PercentRange), RangeHelper.Project(fromRange, bucketMaxX, Scale.PercentRange)));

                    lastCategory = category;
                }
                if (lastCategory != null)
                {
                    double x          = (double)(this._minLeafIndex + lastCategory.LeafIndexRange.Maximum);
                    double projectedX = RangeHelper.Project(fromRange, x, Scale.PercentRange);
                    yield return(new ScalePosition((object)string.Empty, projectedX, projectedX, projectedX));
                }
            }
        }
예제 #15
0
        private IEnumerable <ScalePosition> ProjectMinor(IList <Category> categories, ScaleElementDefinition definition, int level)
        {
            this.RecalculateIfEmpty();
            int step     = 1;
            int maxCount = this.MaxCount;

            if (categories.Count > maxCount && categories.Count > 50)
            {
                if (level != this._realizedCategoryLevels.Count - 1)
                {
                    yield break;
                }
                else
                {
                    switch (maxCount)
                    {
                    case 0:
                        yield break;

                    case 1:
                        yield break;

                    case 2:
                        step = categories.Count - 1;
                        break;

                    default:
                        step = categories.Count / (maxCount - 1);
                        if (categories.Count % maxCount != 0)
                        {
                            step = (int)Math.Ceiling((double)categories.Count / ((double)maxCount - 2.0));
                            break;
                        }
                        break;
                    }
                }
            }
            Range <double> fromRange = new Range <double>(this.ActualViewMinimum, this.ActualViewMaximum);
            int            i         = 0;

            while (i < categories.Count)
            {
                Category category   = categories[i];
                double   bucketMinX = (double)(this._minLeafIndex + category.LeafIndexRange.Minimum);
                double   bucketMaxX = (double)(this._minLeafIndex + category.LeafIndexRange.Maximum);
                double   x          = (bucketMaxX + bucketMinX) / 2.0;
                yield return(new ScalePosition(category.Content, RangeHelper.Project(fromRange, x, Scale.PercentRange), RangeHelper.Project(fromRange, bucketMinX, Scale.PercentRange), RangeHelper.Project(fromRange, bucketMaxX, Scale.PercentRange)));

                i += step;
            }
        }