Exemplo n.º 1
0
 /// <summary>
 /// The get pen.
 /// </summary>
 /// <param name="pane">
 /// The pane.
 /// </param>
 /// <param name="scaleFactor">
 /// The scale factor.
 /// </param>
 /// <returns>
 /// The <see cref="Pen"/>.
 /// </returns>
 internal Pen GetPen(GraphPane pane, float scaleFactor)
 {
     return new Pen(this._color, pane.ScaledPenWidth(this._penWidth, scaleFactor));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Draw the minor tic marks as required for this <see cref="Axis"/>.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or owner of this object.
        /// </param>
        /// <param name="baseVal">
        /// The scale value for the first major tic position.  This is the reference point for all other tic marks.
        /// </param>
        /// <param name="shift">
        /// The number of pixels to shift this axis, based on the value of <see cref="Cross"/>.  A positive value is into the ChartRect relative to the default
        /// axis position.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="topPix">
        /// The pixel location of the far side of the ChartRect from this axis. This value is the ChartRect.Height for the XAxis, or the ChartRect.Width for the
        /// YAxis and Y2Axis.
        /// </param>
        public void DrawMinorTics(Graphics g, GraphPane pane, double baseVal, float shift, float scaleFactor, float topPix)
        {
            if ((this.MinorTic.IsOutside || this.MinorTic.IsOpposite || this.MinorTic.IsInside || this.MinorTic._isCrossOutside
                 || this.MinorTic._isCrossInside || this._minorGrid._isVisible) && this._isVisible)
            {
                double tMajor = this._scale._majorStep * this._scale.MajorUnitMultiplier,
                       tMinor = this._scale._minorStep * this._scale.MinorUnitMultiplier;

                if (this._scale.IsLog || tMinor < tMajor)
                {
                    float minorScaledTic = this.MinorTic.ScaledTic(scaleFactor);

                    // Minor tics start at the minimum value and step all the way thru
                    // the full scale.  This means that if the minor step size is not
                    // an even division of the major step size, the minor tics won't
                    // line up with all of the scale labels and major tics.
                    double first = this._scale._minLinTemp, last = this._scale._maxLinTemp;

                    double dVal = first;
                    float pixVal;

                    int iTic = this._scale.CalcMinorStart(baseVal);
                    int MajorTic = 0;
                    double majorVal = this._scale.CalcMajorTicValue(baseVal, MajorTic);

                    using (Pen pen = new Pen(this._minorTic._color, pane.ScaledPenWidth(this.MinorTic._penWidth, scaleFactor)))
                    using (Pen minorGridPen = this._minorGrid.GetPen(pane, scaleFactor))
                    {
                        // Draw the minor tic marks
                        while (dVal < last && iTic < 5000)
                        {
                            // Calculate the scale value for the current tic
                            dVal = this._scale.CalcMinorTicValue(baseVal, iTic);

                            // Maintain a value for the current major tic
                            if (dVal > majorVal)
                            {
                                majorVal = this._scale.CalcMajorTicValue(baseVal, ++MajorTic);
                            }

                            // Make sure that the current value does not match up with a major tic
                            if (((Math.Abs(dVal) < 1e-20 && Math.Abs(dVal - majorVal) > 1e-20)
                                 || (Math.Abs(dVal) > 1e-20 && Math.Abs((dVal - majorVal) / dVal) > 1e-10)) && (dVal >= first && dVal <= last))
                            {
                                pixVal = this._scale.LocalTransform(dVal);

                                this._minorGrid.Draw(g, minorGridPen, pixVal, topPix);

                                this._minorTic.Draw(g, pane, pen, pixVal, topPix, shift, minorScaledTic);
                            }

                            iTic++;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// The fix zero line.
        /// </summary>
        /// <param name="g">
        /// The g.
        /// </param>
        /// <param name="pane">
        /// The pane.
        /// </param>
        /// <param name="scaleFactor">
        /// The scale factor.
        /// </param>
        /// <param name="left">
        /// The left.
        /// </param>
        /// <param name="right">
        /// The right.
        /// </param>
        internal void FixZeroLine(Graphics g, GraphPane pane, float scaleFactor, float left, float right)
        {
            // restore the zero line if needed (since the fill tends to cover it up)
            if (this._isVisible && this._majorGrid._isZeroLine && this._scale._min < 0.0 && this._scale._max > 0.0)
            {
                float zeroPix = this._scale.Transform(0.0);

                using (Pen zeroPen = new Pen(this._color, pane.ScaledPenWidth(this._majorGrid._penWidth, scaleFactor)))
                {
                    g.DrawLine(zeroPen, left, zeroPix, right, zeroPix);

                    // zeroPen.Dispose();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draw the scale, including the tic marks, value labels, and grid lines as required for this <see cref="Axis"/>.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="shiftPos">
        /// The number of pixels to shift to account for non-primary axis position (e.g., the second, third, fourth, etc. <see cref="YAxis"/> or
        /// <see cref="Y2Axis"/>.
        /// </param>
        internal void Draw(Graphics g, GraphPane pane, float scaleFactor, float shiftPos)
        {
            MajorGrid majorGrid = this._ownerAxis._majorGrid;
            MajorTic majorTic = this._ownerAxis._majorTic;
            MinorTic minorTic = this._ownerAxis._minorTic;

            float rightPix, topPix;

            this.GetTopRightPix(pane, out topPix, out rightPix);

            // calculate the total number of major tics required
            int nTics = this.CalcNumTics();

            // get the first major tic value
            double baseVal = this.CalcBaseTic();

            using (Pen pen = new Pen(this._ownerAxis.Color, pane.ScaledPenWidth(majorTic._penWidth, scaleFactor)))
            {
                // redraw the axis border
                if (this._ownerAxis.IsAxisSegmentVisible)
                {
                    g.DrawLine(pen, 0.0F, shiftPos, rightPix, shiftPos);
                }

                // Draw a zero-value line if needed
                if (majorGrid._isZeroLine && this._min < 0.0 && this._max > 0.0)
                {
                    float zeroPix = this.LocalTransform(0.0);
                    g.DrawLine(pen, zeroPix, 0.0F, zeroPix, topPix);
                }
            }

            // draw the major tics and labels
            this.DrawLabels(g, pane, baseVal, nTics, topPix, shiftPos, scaleFactor);

            // 			_ownerAxis.DrawMinorTics( g, pane, baseVal, shiftPos, scaleFactor, topPix );
            this._ownerAxis.DrawTitle(g, pane, shiftPos, scaleFactor);
        }
Exemplo n.º 5
0
        /// <summary>
        /// The get pen.
        /// </summary>
        /// <param name="pane">
        /// The pane.
        /// </param>
        /// <param name="scaleFactor">
        /// The scale factor.
        /// </param>
        /// <returns>
        /// The <see cref="Pen"/>.
        /// </returns>
        internal Pen GetPen(GraphPane pane, float scaleFactor)
        {
            Pen pen = new Pen(this._color, pane.ScaledPenWidth(this._penWidth, scaleFactor));

            if (this._dashOff > 1e-10 && this._dashOn > 1e-10)
            {
                pen.DashStyle = DashStyle.Custom;
                float[] pattern = new float[2];
                pattern[0] = this._dashOn;
                pattern[1] = this._dashOff;
                pen.DashPattern = pattern;
            }

            return pen;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Render the label for this <see cref="GasGaugeNeedle"/>.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A graphic device object to be drawn into. This is normally e.Graphics from the PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="rect">
        /// Bounding rectangle for this <see cref="GasGaugeNeedle"/>.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects. This is calculated and passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void DrawLegendKey(Graphics g, GraphPane pane, RectangleF rect, float scaleFactor)
        {
            if (!this._isVisible)
            {
                return;
            }

            float yMid = rect.Top + rect.Height / 2.0F;

            Pen pen = new Pen(this.NeedleColor, pane.ScaledPenWidth(this.NeedleWidth / 2, scaleFactor));
            pen.StartCap = LineCap.Round;
            pen.EndCap = LineCap.ArrowAnchor;
            pen.DashStyle = DashStyle.Solid;
            g.DrawLine(pen, rect.Left, yMid, rect.Right, yMid);
        }