private IEnumerable <AxisTickModel> GenerateTicks()
        {
            if (this.tickPlacementCache == ScaleElementPlacement.None)
            {
                yield break;
            }

            decimal min  = Math.Round((decimal)this.minimumCache, 4);
            decimal max  = Math.Round((decimal)this.maximumCache, 4);
            decimal step = (decimal)this.tickFrequencyCache;

            decimal delta = max - min;

            if (delta > 0 && step > 0)
            {
                for (int i = 0;; i++)
                {
                    decimal value = min + i * Math.Round(step, 4);
                    if (max < value)
                    {
                        break;
                    }

                    AxisTickModel tick = new AxisTickModel();
                    tick.normalizedValue = (value - min) / delta;
                    yield return(tick);
                }
            }
        }
Exemplo n.º 2
0
        private FrameworkElement GetTickVisual(AxisTickModel tick, int index)
        {
            FrameworkElement visual;

            if (index >= this.tickVisuals.Count)
            {
                visual = this.CreateTickVisual(tick, this.owner.TickTemplate);
            }
            else
            {
                visual            = this.tickVisuals[index];
                visual.Visibility = Visibility.Visible;
            }

            return(visual);
        }
Exemplo n.º 3
0
        private FrameworkElement CreateTickVisual(AxisTickModel tick, DataTemplate template)
        {
            FrameworkElement visual;

            if (template == null)
            {
                visual = this.CreateTickRectangle();
            }
            else
            {
                visual = CreateContentPresenter(tick, template);
            }

            this.Children.Add(visual);
            this.tickVisuals.Add(visual);

            return(visual);
        }
Exemplo n.º 4
0
        private RadSize MeasureTick(AxisTickModel tick)
        {
            FrameworkElement visual = this.GetTickVisual(tick, tick.CollectionIndex);

            visual.Measure(InfinitySize);

            if (visual is ContentPresenter)
            {
                return(new RadSize(visual.DesiredSize.Width, visual.DesiredSize.Height));
            }

            if (this.model.Orientation == Orientation.Horizontal)
            {
                return(new RadSize(this.owner.TickThickness, this.owner.TickLength));
            }

            return(new RadSize(this.owner.TickLength, this.owner.TickThickness));
        }