/// <summary>
        /// Renders the axis as an oriented axis.
        /// </summary>
        /// <param name="availableSize">The available size.</param>
        private void RenderOriented(Size availableSize)
        {
            _minorTickMarkPool.Reset();
            _majorTickMarkPool.Reset();
            _labelPool.Reset();

            double length = GetLength(availableSize);

            try
            {
                OrientedPanel.Children.Clear();
                if (ActualRange.HasData && !Object.Equals(ActualRange.Minimum, ActualRange.Maximum))
                {
                    foreach (IComparable axisValue in GetMajorTickMarkValues(availableSize))
                    {
                        UnitValue coordinate = GetPlotAreaCoordinate(axisValue, length);
                        if (ValueHelper.CanGraph(coordinate.Value))
                        {
                            Line line = _majorTickMarkPool.Next();
                            OrientedPanel.SetCenterCoordinate(line, coordinate.Value);
                            OrientedPanel.SetPriority(line, 0);
                            OrientedPanel.Children.Add(line);
                        }
                    }

                    foreach (IComparable axisValue in GetMinorTickMarkValues(availableSize))
                    {
                        UnitValue coordinate = GetPlotAreaCoordinate(axisValue, length);
                        if (ValueHelper.CanGraph(coordinate.Value))
                        {
                            Line line = _minorTickMarkPool.Next();
                            OrientedPanel.SetCenterCoordinate(line, coordinate.Value);
                            OrientedPanel.SetPriority(line, 0);
                            OrientedPanel.Children.Add(line);
                        }
                    }

                    int count = 0;
                    foreach (IComparable axisValue in GetLabelValues(availableSize))
                    {
                        UnitValue coordinate = GetPlotAreaCoordinate(axisValue, length);
                        if (ValueHelper.CanGraph(coordinate.Value))
                        {
                            Control axisLabel = _labelPool.Next();
                            PrepareAxisLabel(axisLabel, axisValue);
                            OrientedPanel.SetCenterCoordinate(axisLabel, coordinate.Value);
                            OrientedPanel.SetPriority(axisLabel, count + 1);
                            OrientedPanel.Children.Add(axisLabel);
                            count = (count + 1) % 2;
                        }
                    }
                }
            }
            finally
            {
                _minorTickMarkPool.Done();
                _majorTickMarkPool.Done();
                _labelPool.Done();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Renders the axis labels, tick marks, and other visual elements.
        /// </summary>
        protected override void Render()
        {
            OrientedPanel.Children.Clear();
            this.GridLineCoordinatesToDisplay.Clear();

            if (this.Categories.Count > 0)
            {
                double maximumLength = Math.Max(ActualLength - 1, 0);

                Action <double> placeTickMarkAt =
                    (pos) =>
                {
                    Line tickMark = CreateMajorTickMark();
                    OrientedPanel.SetCenterCoordinate(tickMark, pos);
                    OrientedPanel.SetPriority(tickMark, 0);
                    this.GridLineCoordinatesToDisplay.Add(pos);
                    OrientedPanel.Children.Add(tickMark);
                };



                int index    = 0;
                int priority = 0;
                foreach (object category in Categories)
                {
                    ContentControl axisLabel = CreateAndPrepareAxisLabel(category);
                    if (DisplayShortDate)
                    {
                        DateTime dt = DateTime.Now;
                        if (DateTime.TryParse(category.ToString(), out dt))
                        {
                            axisLabel = CreateAndPrepareAxisLabel((object)dt.ToShortDateString());
                        }
                    }

                    double lower = ((index * maximumLength) / Categories.Count) + 0.5;
                    double upper = (((index + 1) * maximumLength) / Categories.Count) + 0.5;
                    placeTickMarkAt(lower);
                    OrientedPanel.SetCenterCoordinate(axisLabel, (lower + upper) / 2);
                    OrientedPanel.SetPriority(axisLabel, priority + 1);

                    if (index % Interval == 0)
                    {
                        OrientedPanel.Children.Add(axisLabel);
                    }

                    index++;
                    priority = (priority + 1) % 2;
                }

                placeTickMarkAt(maximumLength + 0.5);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Instantiates a new instance of the DisplayAxis class.
        /// </summary>
        protected DisplayAxis()
        {
            OrientedPanel = new OrientedPanel();
#if SILVERLIGHT
            this.DefaultStyleKey = typeof(DisplayAxis);
            this.OrientedPanel.UseLayoutRounding = true;
#endif

            TitleLayoutTransformControl = new LayoutTransformControl();
            TitleLayoutTransformControl.HorizontalAlignment = HorizontalAlignment.Center;
            TitleLayoutTransformControl.VerticalAlignment   = VerticalAlignment.Center;

            SizeChanged += DisplayAxisSizeChanged;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Renders as an oriented axis.
        /// </summary>
        /// <param name="availableSize">The available size.</param>
        private void RenderOriented(Size availableSize)
        {
            _labelPool.Reset();
            _majorTickMarkPool.Reset();

            try
            {
                OrientedPanel.Children.Clear();
                this.GridLineCoordinatesToDisplay.Clear();

                if (this.Categories.Count > 0)
                {
                    double maximumLength = Math.Max(GetLength(availableSize) - 1, 0);

                    Action <double> placeTickMarkAt =
                        (pos) =>
                    {
                        Line tickMark = _majorTickMarkPool.Next();
                        OrientedPanel.SetCenterCoordinate(tickMark, pos);
                        OrientedPanel.SetPriority(tickMark, 0);
                        this.GridLineCoordinatesToDisplay.Add(new UnitValue(pos, Unit.Pixels));
                        OrientedPanel.Children.Add(tickMark);
                    };

                    int index    = 0;
                    int priority = 0;

                    foreach (object category in Categories)
                    {
                        Control axisLabel = CreateAndPrepareAxisLabel(category);
                        double  lower     = ((index * maximumLength) / Categories.Count) + 0.5;
                        double  upper     = (((index + 1) * maximumLength) / Categories.Count) + 0.5;
                        placeTickMarkAt(lower);
                        OrientedPanel.SetCenterCoordinate(axisLabel, (lower + upper) / 2);
                        OrientedPanel.SetPriority(axisLabel, priority + 1);
                        OrientedPanel.Children.Add(axisLabel);
                        index++;
                        priority = (priority + 1) % 2;
                    }
                    placeTickMarkAt(maximumLength + 0.5);
                }
            }
            finally
            {
                _labelPool.Done();
                _majorTickMarkPool.Done();
            }
        }
        /// <summary>
        /// Renders the axis labels, tick marks, and other visual elements.
        /// </summary>
        protected override void Render()
        {
            OrientedPanel.Children.Clear();

            if (ActualRange.HasData && !Object.Equals(ActualRange.Minimum, ActualRange.Maximum))
            {
                foreach (IComparable axisValue in GetMajorTickMarkValues())
                {
                    Line   line       = CreateMajorTickMark();
                    double coordinate = GetPlotAreaCoordinate(axisValue);
                    OrientedPanel.SetCenterCoordinate(line, coordinate);
                    OrientedPanel.SetPriority(line, 0);
                    OrientedPanel.Children.Add(line);
                }

                foreach (IComparable axisValue in GetMinorTickMarkValues())
                {
                    Line   line       = CreateMinorTickMark();
                    double coordinate = GetPlotAreaCoordinate(axisValue);
                    OrientedPanel.SetCenterCoordinate(line, coordinate);
                    OrientedPanel.SetPriority(line, 0);
                    OrientedPanel.Children.Add(line);
                }

                int count = 0;
                foreach (IComparable axisValue in GetLabelValues())
                {
                    ContentControl axisLabel  = CreateAndPrepareAxisLabel(axisValue);
                    double         coordinate = GetPlotAreaCoordinate(axisValue);
                    OrientedPanel.SetCenterCoordinate(axisLabel, coordinate);
                    OrientedPanel.SetPriority(axisLabel, count + 1);
                    OrientedPanel.Children.Add(axisLabel);
                    count = (count + 1) % 2;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Instantiates a new instance of the DisplayAxis class.
        /// </summary>
        internal DisplayAxis()
        {
            OrientedPanel = new OrientedPanel();
            #if SILVERLIGHT
            DefaultStyleKey = typeof (DisplayAxis);
            OrientedPanel.UseLayoutRounding = true;
            #endif

            DependentAxisGrid = new Grid();

            TitleLayoutTransformControl = new LayoutTransformControl();
            TitleLayoutTransformControl.HorizontalAlignment = ((FrameworkElement) this).HorizontalAlignment.Center;
            TitleLayoutTransformControl.VerticalAlignment = ((FrameworkElement) this).VerticalAlignment.Center;

            SizeChanged += new SizeChangedEventHandler(DisplayAxisSizeChanged);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Renders the axis as an oriented axis.
        /// </summary>
        /// <param name="availableSize">The available size.</param>
        private void RenderOriented(Size availableSize)
        {
            _minorTickMarkPool.Reset();
            _majorTickMarkPool.Reset();
            _labelPool.Reset();

            double length = GetLength(availableSize);

            try
            {
                OrientedPanel.Children.Clear();
                if (ActualRange.HasData && !Object.Equals(ActualRange.Minimum, ActualRange.Maximum))
                {
                    foreach (IComparable axisValue in GetMajorTickMarkValues(availableSize))
                    {
                        UnitValue?coordinate = GetPlotAreaCoordinate(axisValue, ActualRange, length);
                        if (coordinate.HasValue)
                        {
                            Line line = _majorTickMarkPool.Next();
                            OrientedPanel.SetCenterCoordinate(line, coordinate.Value.Value);
                            OrientedPanel.SetPriority(line, 0);
                            OrientedPanel.Children.Add(line);
                        }
                    }

                    foreach (IComparable axisValue in GetMinorTickMarkValues(availableSize))
                    {
                        UnitValue?coordinate = GetPlotAreaCoordinate(axisValue, ActualRange, length);
                        if (coordinate.HasValue)
                        {
                            Line line = _minorTickMarkPool.Next();
                            OrientedPanel.SetCenterCoordinate(line, coordinate.Value.Value);
                            OrientedPanel.SetPriority(line, 0);
                            OrientedPanel.Children.Add(line);
                        }
                    }

                    int count = 0;
                    foreach (IComparable axisValue in GetLabelValues(availableSize))
                    {
                        UnitValue?coordinate = GetPlotAreaCoordinate(axisValue, ActualRange, length);
                        if (coordinate.HasValue)
                        {
                            Control axisLabel = CreateAxisLabel();
                            ////Control axisLabel = _labelPool.Next();
                            ////if (OrientedPanel.Children.Contains(axisLabel))
                            ////{
                            ////    System.Diagnostics.Debug.WriteLine("removed.");
                            ////    OrientedPanel.Children.Remove(axisLabel);
                            ////}
                            PrepareAxisLabel(axisLabel, axisValue);
                            OrientedPanel.SetCenterCoordinate(axisLabel, coordinate.Value.Value);
                            OrientedPanel.SetPriority(axisLabel, count + 1);
                            OrientedPanel.Children.Add(axisLabel);
                            count = (count + 1) % 2;
                        }
                    }
                }
            }
            finally
            {
                _minorTickMarkPool.Done();
                _majorTickMarkPool.Done();
                _labelPool.Done();
            }
        }