/// <summary>
 /// Initializes a new instance of the OrientedAxisGridLines class.
 /// </summary>
 /// <param name="displayAxis">The axis to draw grid lines for.</param>
 public OrientedAxisGridLines(DisplayAxis displayAxis)
     : base(displayAxis)
 {
     _gridLinePool = new ObjectPool <Line>(() => new Line {
         Style = Axis.GridLineStyle
     });
 }
示例#2
0
 /// <summary>
 /// Acquire a horizontal linear axis and a vertical linear axis.
 /// </summary>
 /// <param name="firstDataPoint">The first data point.</param>
 protected override void GetAxes(DataPoint firstDataPoint)
 {
     GetAxes(
         firstDataPoint,
         (axis) => axis.Orientation == AxisOrientation.X,
         () =>
     {
         IAxis axis = CreateRangeAxisFromData(firstDataPoint.IndependentValue);
         if (axis == null)
         {
             axis = new CategoryAxis();
         }
         axis.Orientation = AxisOrientation.X;
         return(axis);
     },
         (axis) => axis.Orientation == AxisOrientation.Y && axis is IRangeAxis,
         () =>
     {
         DisplayAxis axis = (DisplayAxis)CreateRangeAxisFromData(firstDataPoint.DependentValue);
         if (axis == null)
         {
             throw new InvalidOperationException(Properties.Resources.DataPointSeriesWithAxes_NoSuitableAxisAvailableForPlottingDependentValue);
         }
         axis.ShowGridLines = true;
         axis.Orientation   = AxisOrientation.Y;
         return(axis);
     });
 }
示例#3
0
 /// <summary>
 /// Acquire a horizontal category axis and a vertical linear axis.
 /// </summary>
 /// <param name="firstDataPoint">The first data point.</param>
 protected override void GetAxes(DataPoint firstDataPoint)
 {
     GetAxes(
         firstDataPoint,
         (axis) => axis.Orientation == AxisOrientation.X,
         () => new CategoryAxis {
         Orientation = AxisOrientation.X
     },
         (axis) =>
     {
         IRangeAxis rangeAxis = axis as IRangeAxis;
         return(rangeAxis != null && rangeAxis.Origin != null && axis.Orientation == AxisOrientation.Y);
     },
         () =>
     {
         IRangeAxis rangeAxis  = CreateRangeAxisFromData(firstDataPoint.DependentValue);
         rangeAxis.Orientation = AxisOrientation.Y;
         if (rangeAxis == null || rangeAxis.Origin == null)
         {
             throw new InvalidOperationException(Properties.Resources.DataPointSeriesWithAxes_NoSuitableAxisAvailableForPlottingDependentValue);
         }
         DisplayAxis axis = rangeAxis as DisplayAxis;
         if (axis != null)
         {
             axis.ShowGridLines = true;
         }
         return(rangeAxis);
     });
 }
示例#4
0
        /// <summary>
        /// AxisLabelStyleProperty property changed handler.
        /// </summary>
        /// <param name="d">DisplayAxis that changed its AxisLabelStyle.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnAxisLabelStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DisplayAxis source   = (DisplayAxis)d;
            Style       oldValue = (Style)e.OldValue;
            Style       newValue = (Style)e.NewValue;

            source.OnAxisLabelStylePropertyChanged(oldValue, newValue);
        }
示例#5
0
        /// <summary>
        /// ShowGridLinesProperty property changed handler.
        /// </summary>
        /// <param name="d">Axis that changed its ShowGridLines.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnShowGridLinesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DisplayAxis source   = (DisplayAxis)d;
            bool        oldValue = (bool)e.OldValue;
            bool        newValue = (bool)e.NewValue;

            source.OnShowGridLinesPropertyChanged(oldValue, newValue);
        }
示例#6
0
        /// <summary>
        /// TitleProperty property changed handler.
        /// </summary>
        /// <param name="d">DisplayAxis that changed its Title.</param>
        /// <param name="e">Event arguments.</param>
        private static void OnTitlePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DisplayAxis source   = (DisplayAxis)d;
            object      oldValue = (object)e.OldValue;
            object      newValue = (object)e.NewValue;

            source.OnTitlePropertyChanged(oldValue, newValue);
        }
        /// <summary>
        /// AxisProperty property changed handler.
        /// </summary>
        /// <param name="oldValue">Old value.</param>
        /// <param name="newValue">New value.</param>
        private void OnAxisPropertyChanged(DisplayAxis oldValue, DisplayAxis newValue)
        {
            Debug.Assert(newValue != null, "Don't set the axis property to null.");

            if (newValue != null)
            {
                newValue.RegisteredListeners.Add(this);
            }

            if (oldValue != null)
            {
                oldValue.RegisteredListeners.Remove(this);
            }
        }
示例#8
0
        /// <summary>
        ///     AxisProperty property changed handler.
        /// </summary>
        /// <param name="oldValue">Old value.</param>
        /// <param name="newValue">New value.</param>
        private void OnAxisPropertyChanged(DisplayAxis oldValue, DisplayAxis newValue)
        {
            Debug.Assert(newValue != null, "Don't set the axis property to null.");

            if (newValue != null)
            {
                newValue.RegisteredListeners.Add(this);
            }

            if (oldValue != null)
            {
                oldValue.RegisteredListeners.Remove(this);
            }
        }
示例#9
0
        /// <summary>
        ///     Draws the grid lines.
        /// </summary>
        protected override void Invalidate()
        {
            _gridLinePool.Reset();

            try
            {
                IList <UnitValue> intervals = Axis.InternalGetMajorGridLinePositions().ToList();

                Children.Clear();

                double maximumHeight = Math.Max(Math.Round(ActualHeight - 1), 0);
                double maximumWidth  = Math.Max(Math.Round(ActualWidth - 1), 0);
                for (int index = 0; index < intervals.Count; index++)
                {
                    double currentValue = intervals[index].Value;

                    double position = currentValue;
                    if (!double.IsNaN(position))
                    {
                        Line line = _gridLinePool.Next();
                        DisplayAxis.SetGridLineIndex(line, index);
                        if (Axis.Orientation == AxisOrientation.Y)
                        {
                            line.Y1 = line.Y2 = maximumHeight - Math.Round(position - (line.StrokeThickness / 2));
                            line.X1 = 0.0;
                            line.X2 = maximumWidth;
                        }
                        else if (Axis.Orientation == AxisOrientation.X)
                        {
                            line.X1 = line.X2 = Math.Round(position - (line.StrokeThickness / 2));
                            line.Y1 = 0.0;
                            line.Y2 = maximumHeight;
                        }
                        // workaround for '1px line thickness issue'
                        if (line.StrokeThickness % 2 > 0)
                        {
                            line.SetValue(LeftProperty, 0.5);
                            line.SetValue(TopProperty, 0.5);
                        }
                        Children.Add(line);
                    }
                }
            }
            finally
            {
                _gridLinePool.Done();
            }
        }
 /// <summary>
 /// Instantiates a new instance of the DisplayAxisGridLines class.
 /// </summary>
 /// <param name="axis">The axis used by the DisplayAxisGridLines.</param>
 public DisplayAxisGridLines(DisplayAxis axis)
 {
     this.Axis = axis;
     this.SizeChanged += new SizeChangedEventHandler(OnSizeChanged);
 }
示例#11
0
 /// <summary>
 ///     Instantiates a new instance of the DisplayAxisGridLines class.
 /// </summary>
 /// <param name="axis">The axis used by the DisplayAxisGridLines.</param>
 public DisplayAxisGridLines(DisplayAxis axis)
 {
     Axis         = axis;
     SizeChanged += OnSizeChanged;
 }
示例#12
0
 /// <summary>
 /// Instantiates a new instance of the DisplayAxisGridLines class.
 /// </summary>
 /// <param name="axis">The axis used by the DisplayAxisGridLines.</param>
 public DisplayAxisGridLines(DisplayAxis axis)
 {
     this.Axis         = axis;
     this.SizeChanged += new SizeChangedEventHandler(OnSizeChanged);
 }
 /// <summary>
 /// Instantiates a new instance of the DisplayAxisGridLines class.
 /// </summary>
 /// <param name="axis">The axis used by the DisplayAxisGridLines.</param>
 public ZeroLineCanvas(DisplayAxis axis)
 {
     this.Axis = axis;
     this.SizeChanged += new SizeChangedEventHandler(OnSizeChanged);
 }
            /// <summary>
            /// AxisProperty property changed handler.
            /// </summary>
            /// <param name="oldValue">Old value.</param>
            /// <param name="newValue">New value.</param>
            private void OnAxisPropertyChanged(DisplayAxis oldValue, DisplayAxis newValue)
            {
                if (newValue != null)
                {
                    newValue.RegisteredListeners.Add(this);
                }

                if (oldValue != null)
                {
                    oldValue.RegisteredListeners.Remove(this);
                }
            }
 /// <summary>
 /// Initializes a new instance of the OrientedAxisGridLines class.
 /// </summary>
 /// <param name="displayAxis">The axis to draw grid lines for.</param>
 public OrientedAxisGridLines(DisplayAxis displayAxis)
     : base(displayAxis)
 {
     _gridLinePool = new ObjectPool<Line>(() => new Line { Style = Axis.GridLineStyle });
 }