/// <summary>
        /// Render the label for this <see cref="GasGaugeRegion"/>.
        /// </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="GasGaugeRegion"/>.</param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects. This is calculated and
        /// passed down by the parent <see cref="ZedGraph.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 (!_isVisible)
            {
                return;
            }

            // Fill the slice
            if (_fill.IsVisible)
            {
                // just avoid height/width being less than 0.1 so GDI+ doesn't cry
                using (Brush brush = _fill.MakeBrush(rect))
                {
                    g.FillRectangle(brush, rect);

                    //brush.Dispose();
                }
            }

            // Border the bar
            if (!_border.Color.IsEmpty)
            {
                _border.Draw(g, pane, scaleFactor, rect);
            }
        }
        /// <summary>
        /// Draw the border _border around the <see cref="Rect"/> area.
        /// </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="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.
        /// </param>
        public void DrawPaneFrame(Graphics g, float scaleFactor)
        {
            // Erase the pane background, filling it with the specified brush
            _fill.Draw(g, _rect);

            // Reduce the rect width and height by 1 pixel so that for a rect of
            // new RectangleF( 0, 0, 100, 100 ), which should be 100 pixels wide, we cover
            // from 0 through 99.  The draw routines normally cover from 0 through 100, which is
            // actually 101 pixels wide.
            RectangleF rect = new RectangleF(_rect.X, _rect.Y, _rect.Width - 1, _rect.Height - 1);

            _border.Draw(g, IsPenWidthScaled, scaleFactor, rect);
        }
Beispiel #3
0
 /// <summary>
 /// Draw the <see cref="Bar"/> to the specified <see cref="Graphics"/> device
 /// at the specified location.  This routine draws a single bar.
 /// </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="ZedGraph.GraphPane"/> object that is the parent or
 /// owner of this object.
 /// </param>
 /// <param name="rect">The rectangle (pixels) to contain the bar</param>
 /// <param name="scaleFactor">
 /// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
 /// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
 /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.
 /// </param>
 /// <param name="fullFrame">true to draw the bottom portion of the border around the
 /// bar (this is for legend entries)</param>
 /// <param name="dataValue">The data value to be used for a value-based
 /// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
 /// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
 /// <param name="isSelected">Indicates that the <see cref="Bar" /> should be drawn
 /// with attributes from the <see cref="Selection" /> class.
 /// </param>
 public void Draw(Graphics g, GraphPane pane, RectangleF rect, float scaleFactor,
                  bool fullFrame, bool isSelected, PointPair dataValue)
 {
     if (isSelected)
     {
         Selection.Fill.Draw(g, rect, dataValue);
         Selection.Border.Draw(g, pane, scaleFactor, rect);
     }
     else
     {
         _fill.Draw(g, rect, dataValue);
         _border.Draw(g, pane, scaleFactor, rect);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Draw the <see cref="JapaneseCandleStick"/> to the specified <see cref="Graphics"/>
        /// device at the specified location.
        /// </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="isXBase">boolean value that indicates if the "base" axis for this
        /// <see cref="JapaneseCandleStick"/> is the X axis.  True for an <see cref="XAxis"/> base,
        /// false for a <see cref="YAxis"/> or <see cref="Y2Axis"/> base.</param>
        /// <param name="pixBase">The independent axis position of the center of the candlestick in
        /// pixel units</param>
        /// <param name="pixHigh">The high value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixLow">The low value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixOpen">The opening value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixClose">The closing value position of the candlestick in
        /// pixel units</param>
        /// <param name="halfSize">The scaled width of one-half of a bar, in pixels</param>
        /// <param name="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.</param>
        /// <param name="pen">A pen with the <see cref="Color"/> attribute for this
        /// <see cref="JapaneseCandleStick"/></param>
        /// <param name="fill">
        /// The <see cref="Fill" /> instance to be used for filling this
        /// <see cref="JapaneseCandleStick" />
        /// </param>
        /// <param name="border">The <see cref="Border" /> instance to be used for drawing the
        /// border around the <see cref="JapaneseCandleStick" /> filled box</param>
        /// <param name="pt">The <see cref="PointPair" /> to be used for determining the
        /// <see cref="Fill" />, just in case it's a <see cref="FillType.GradientByX" />,
        /// <see cref="FillType.GradientByY" />, or
        /// <see cref="FillType.GradientByZ" /> <see cref="FillType" /></param>
        internal void Draw(Graphics g, GraphPane pane, bool isXBase,
                           float pixBase, float pixHigh, float pixLow,
                           float pixOpen, float pixClose, float halfSize,
                           float scaleFactor, Pen pen, Fill fill, Border border, IPointPair pt,
                           float dotHalfSize)
        {
            //float halfSize = (int) ( _size * scaleFactor / 2.0f + 0.5f );

            if (pixBase == PointPair.Missing || Math.Abs(pixLow) >= 1000000 ||
                Math.Abs(pixHigh) >= 1000000)
            {
                return;
            }
            RectangleF rect;

            if (isXBase)
            {
                rect = new RectangleF(pixBase - halfSize, Math.Min(pixOpen, pixClose),
                                      halfSize * 2.0f, Math.Abs(pixOpen - pixClose));

                g.DrawLine(pen, pixBase, pixHigh, pixBase, pixLow);
            }
            else
            {
                rect = new RectangleF(Math.Min(pixOpen, pixClose), pixBase - halfSize,
                                      Math.Abs(pixOpen - pixClose), halfSize * 2.0f);

                g.DrawLine(pen, pixHigh, pixBase, pixLow, pixBase);
            }

            if (!IsOpenCloseVisible || Math.Abs(pixOpen) >= 1000000 ||
                Math.Abs(pixClose) >= 1000000)
            {
                return;
            }

            if (rect.Width == 0)
            {
                rect.Width = 1;
            }
            if (rect.Height == 0)
            {
                rect.Height = 1;
            }

            fill.Draw(g, rect, pt);
            border.Draw(g, pane, scaleFactor, rect);

            DrawHighLowDots(g, isXBase, pixBase, pixHigh, pixLow, dotHalfSize);
        }
        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <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="PaneBase"/> 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>
        override public void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            RectangleF pixRect = this.Location.TransformRect(pane);

            if (Math.Abs(pixRect.Left) < 100000 &&
                Math.Abs(pixRect.Top) < 100000 &&
                Math.Abs(pixRect.Right) < 100000 &&
                Math.Abs(pixRect.Bottom) < 100000)
            {
                // If the box is to be filled, fill it
                _fill.Draw(g, pixRect);

                // Draw the border around the box if required
                _border.Draw(g, pane.IsPenWidthScaled, scaleFactor, pixRect);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Draw the <see cref="Bar"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single bar.
        /// </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="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="rect">The rectangle (pixels) to contain the bar</param>
        /// <param name="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.
        /// </param>
        /// <param name="fullFrame">true to draw the bottom portion of the border around the
        /// bar (this is for legend entries)</param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
        public void Draw(Graphics g, GraphPane pane, RectangleF rect, float scaleFactor,
                         bool fullFrame, PointPair dataValue)
        {
            _fill.Draw(g, rect, dataValue);

            // Fill the Bar
            //if ( this.fill.IsVisible )
            //{
            //	// just avoid height/width being less than 0.1 so GDI+ doesn't cry
            //	Brush brush = this.fill.MakeBrush( _rect, dataValue );
            //	g.FillRectangle( brush, rect );
            //	brush.Dispose();
            //}

            // Border the Bar
            //if ( !this.border.Color.IsEmpty )
            _border.Draw(g, pane.IsPenWidthScaled, scaleFactor, rect);
        }
Beispiel #7
0
        /// <summary>
        /// Draw the <see cref="JapaneseCandleStick"/> to the specified <see cref="Graphics"/>
        /// device at the specified location.
        /// </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="isXBase">boolean value that indicates if the "base" axis for this
        /// <see cref="JapaneseCandleStick"/> is the X axis.  True for an <see cref="XAxis"/> base,
        /// false for a <see cref="YAxis"/> or <see cref="Y2Axis"/> base.</param>
        /// <param name="pixBase">The independent axis position of the center of the candlestick in
        /// pixel units</param>
        /// <param name="pixHigh">The high value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixLow">The low value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixOpen">The opening value position of the candlestick in
        /// pixel units</param>
        /// <param name="pixClose">The closing value position of the candlestick in
        /// pixel units</param>
        /// <param name="halfSize">The scaled width of one-half of a bar, in pixels</param>
        /// <param name="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.</param>
        /// <param name="pen">A pen with the <see cref="Color"/> attribute for this
        /// <see cref="JapaneseCandleStick"/></param>
        /// <param name="fill">
        /// The <see cref="Fill" /> instance to be used for filling this
        /// <see cref="JapaneseCandleStick" />
        /// </param>
        /// <param name="border">The <see cref="Border" /> instance to be used for drawing the
        /// border around the <see cref="JapaneseCandleStick" /> filled box</param>
        /// <param name="pt">The <see cref="PointPair" /> to be used for determining the
        /// <see cref="Fill" />, just in case it's a <see cref="FillType.GradientByX" />,
        /// <see cref="FillType.GradientByY" />, or
        /// <see cref="FillType.GradientByZ" /> <see cref="FillType" /></param>
        public void Draw(Graphics g, GraphPane pane, bool isXBase,
                         float pixBase, float pixHigh, float pixLow,
                         float pixOpen, float pixClose, float halfSize,
                         float scaleFactor, Pen pen, Fill fill, Border border, PointPair pt)
        {
            //float halfSize = (int) ( _size * scaleFactor / 2.0f + 0.5f );

            if (pixBase != PointPair.Missing && Math.Abs(pixLow) < 1000000 &&
                Math.Abs(pixHigh) < 1000000)
            {
                RectangleF rect;
                if (isXBase)
                {
                    rect = new RectangleF(pixBase - halfSize, Math.Min(pixOpen, pixClose),
                                          halfSize * 2.0f, Math.Abs(pixOpen - pixClose));

                    g.DrawLine(pen, pixBase, pixHigh, pixBase, pixLow);
                }
                else
                {
                    rect = new RectangleF(Math.Min(pixOpen, pixClose), pixBase - halfSize,
                                          Math.Abs(pixOpen - pixClose), halfSize * 2.0f);

                    g.DrawLine(pen, pixHigh, pixBase, pixLow, pixBase);
                }

                if (_isOpenCloseVisible && Math.Abs(pixOpen) < 1000000 &&
                    Math.Abs(pixClose) < 1000000)
                {
                    if (rect.Width == 0)
                    {
                        rect.Width = 1;
                    }
                    if (rect.Height == 0)
                    {
                        rect.Height = 1;
                    }

                    fill.Draw(g, rect, pt);
                    border.Draw(g, pane, scaleFactor, rect);
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <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="PaneBase"/> 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>
        public override void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            var pixRect = Location.TransformRect(pane);

            // Clip the rect to just outside the PaneRect so we don't end up with wild coordinates.
            var tmpRect = pane.Rect;

            tmpRect.Inflate(20, 20);
            pixRect.Intersect(tmpRect);

            if (Math.Abs(pixRect.Left) >= 100000 || Math.Abs(pixRect.Top) >= 100000 || Math.Abs(pixRect.Right) >= 100000 ||
                Math.Abs(pixRect.Bottom) >= 100000)
            {
                return;
            }
            // If the box is to be filled, fill it
            _fill.Draw(g, pixRect);

            // Draw the border around the box if required
            _border.Draw(g, pane, scaleFactor, pixRect);
        }
        /// <summary>
        /// Draw the <see cref="Bar"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single bar.
        /// </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="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="rect">The rectangle (pixels) to contain the bar</param>
        /// <param name="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.
        /// </param>
        /// <param name="fullFrame">true to draw the bottom portion of the border around the
        /// bar (this is for legend entries)</param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
        /// <param name="barIndex">index of bar which will be drawn.</param>
        public void Draw(Graphics g, GraphPane pane, RectangleF rect, float scaleFactor,
                         bool fullFrame, IPointPair dataValue,
                         // BioRad addition 7.9.2007
                         int barIndex
                         // end BioRad
                         )
        {
            _fill.Draw(g, rect, dataValue);

            // Fill the Bar
            //if ( this.fill.IsVisible )
            //{
            //	// just avoid height/width being less than 0.1 so GDI+ doesn't cry
            //	Brush brush = this.fill.MakeBrush( _rect, dataValue );
            //	g.FillRectangle( brush, rect );
            //	brush.Dispose();
            //}

            // Border the Bar
            //if ( !this.border.Color.IsEmpty )

            // BioRad Change from
            // _border.Draw(g, pane.IsPenWidthScaled, scaleFactor, rect);
            // BioRad Change to
            bool isHighlighted = _highlightedBarIndexes.Contains(barIndex);

            _border.Draw(g, pane.IsPenWidthScaled, scaleFactor, rect, isHighlighted);
            // end BioRad

            // BioRad addition 7.9.2007
            if (barIndex >= 0)
            {
                _barRectangles[barIndex] = rect;
            }
            // end BioRad
        }
Beispiel #10
0
        /// <summary>
        /// Render the <see cref="Legend"/> to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphPane"/> object.
        /// </remarks>
        /// <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="PaneBase"/> 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>
        public void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // if the legend is not visible, do nothing
            if (!_isVisible)
            {
                return;
            }

            // Fill the background with the specified color if required
            _fill.Draw(g, Rect);

            var paneList = GetPaneList(pane);

            var halfGap = _tmpSize / 2.0F;

            // Check for bad data values
            if (_hStack <= 0)
            {
                _hStack = 1;
            }
            if (_legendItemWidth <= 0)
            {
                _legendItemWidth = 100;
            }
            if (_legendItemHeight <= 0)
            {
                _legendItemHeight = _tmpSize;
            }

            //float gap = pane.ScaledGap( scaleFactor );

            var iEntry = 0;

            // Get a brush for the legend label text
            using (new SolidBrush(Color.Black)) {
                foreach (var tmpPane in paneList)
                {
                    // Loop for each curve in the CurveList collection
                    //foreach ( CurveItem curve in tmpPane.CurveList )
                    var count = tmpPane.CurveList.Count;
                    for (var i = 0; i < count; i++)
                    {
                        var curve = tmpPane.CurveList[_isReverse ? count - i - 1 : i];

                        if (curve._label._text == "" || !curve._label._isVisible)
                        {
                            continue;
                        }
                        // Calculate the x,y (TopLeft) location of the current
                        // curve legend label
                        // assuming:
                        //  charHeight/2 for the left margin, plus legendWidth for each
                        //    horizontal column
                        //  legendHeight is the line spacing, with no extra margin above

                        var x   = Rect.Left + halfGap / 2.0F + (iEntry % _hStack) * _legendItemWidth;
                        var foo = iEntry / _hStack;
                        var y   = Rect.Top + foo * _legendItemHeight;

                        // Draw the legend label for the current curve
                        var tmpFont = curve._label._fontSpec ?? FontSpec;

                        // This is required because, for long labels, the centering can affect the
                        // position in GDI+.
                        tmpFont.StringAlignment = StringAlignment.Near;

                        if (_isShowLegendSymbols)
                        {
                            tmpFont.Draw(
                                g,
                                pane,
                                curve._label._text,
                                x + 2.5F * _tmpSize,
                                y + _legendItemHeight / 2.0F,
                                AlignH.Left,
                                AlignV.Center,
                                scaleFactor);

                            var rect = new RectangleF(
                                x,
                                y + _legendItemHeight / 4.0F,
                                2 * _tmpSize,
                                _legendItemHeight / 2.0F);
                            curve.DrawLegendKey(g, tmpPane, rect, scaleFactor);
                        }
                        else
                        {
                            if (curve._label._fontSpec == null)
                            {
                                tmpFont.FontColor = curve.Color;
                            }

                            tmpFont.Draw(
                                g,
                                pane,
                                curve._label._text,
                                x + 0.0F * _tmpSize,
                                y + _legendItemHeight / 2.0F,
                                AlignH.Left,
                                AlignV.Center,
                                scaleFactor);
                        }

                        // maintain a curve count for positioning
                        iEntry++;
                    }
                    if (pane is MasterPane && ((MasterPane)pane).IsUniformLegendEntries)
                    {
                        break;
                    }
                }

                // Draw a border around the legend if required
                if (iEntry > 0)
                {
                    Border.Draw(g, pane, scaleFactor, Rect);
                }
            }
        }
		/// <summary>
		/// Draw the <see cref="JapaneseCandleStick"/> to the specified <see cref="Graphics"/>
		/// device at the specified location.
		/// </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="isXBase">boolean value that indicates if the "base" axis for this
		/// <see cref="JapaneseCandleStick"/> is the X axis.  True for an <see cref="XAxis"/> base,
		/// false for a <see cref="YAxis"/> or <see cref="Y2Axis"/> base.</param>
		/// <param name="pixBase">The independent axis position of the center of the candlestick in
		/// pixel units</param>
		/// <param name="pixHigh">The high value position of the candlestick in
		/// pixel units</param>
		/// <param name="pixLow">The low value position of the candlestick in
		/// pixel units</param>
		/// <param name="pixOpen">The opening value position of the candlestick in
		/// pixel units</param>
		/// <param name="pixClose">The closing value position of the candlestick in
		/// pixel units</param>
		/// <param name="halfSize">The scaled width of one-half of a bar, in pixels</param>
		/// <param name="scaleFactor">
		/// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
		/// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
		/// represents a linear multiple to be applied to font sizes, symbol sizes, etc.</param>
		/// <param name="pen">A pen with the <see cref="Color"/> attribute for this
		/// <see cref="JapaneseCandleStick"/></param>
		/// <param name="fill">
		/// The <see cref="Fill" /> instance to be used for filling this
		/// <see cref="JapaneseCandleStick" />
		/// </param>
		/// <param name="border">The <see cref="Border" /> instance to be used for drawing the
		/// border around the <see cref="JapaneseCandleStick" /> filled box</param>
		/// <param name="pt">The <see cref="PointPair" /> to be used for determining the
		/// <see cref="Fill" />, just in case it's a <see cref="FillType.GradientByX" />,
		/// <see cref="FillType.GradientByY" />, or
		/// <see cref="FillType.GradientByZ" /> <see cref="FillType" /></param>
		public void Draw( Graphics g, GraphPane pane, bool isXBase,
								float pixBase, float pixHigh, float pixLow,
								float pixOpen, float pixClose, float halfSize,
								float scaleFactor, Pen pen, Fill fill, Border border, PointPair pt )
		{
			//float halfSize = (int) ( _size * scaleFactor / 2.0f + 0.5f );

			if ( pixBase != PointPair.Missing && Math.Abs( pixLow ) < 1000000 &&
						Math.Abs( pixHigh ) < 1000000)
			{
				RectangleF rect;
				if ( isXBase )
				{
					rect = new RectangleF( pixBase - halfSize, Math.Min( pixOpen, pixClose ),
								halfSize * 2.0f, Math.Abs( pixOpen - pixClose ) );

					g.DrawLine( pen, pixBase, pixHigh, pixBase, pixLow );
				}
				else
				{
					rect = new RectangleF( Math.Min( pixOpen, pixClose ), pixBase - halfSize,
								Math.Abs( pixOpen - pixClose ), halfSize * 2.0f );

					g.DrawLine( pen, pixHigh, pixBase, pixLow, pixBase );
				}

				if ( _isOpenCloseVisible && Math.Abs( pixOpen ) < 1000000 &&
							Math.Abs( pixClose ) < 1000000 )
				{
					if ( rect.Width == 0 )
						rect.Width = 1;
					if ( rect.Height == 0 )
						rect.Height = 1;

					fill.Draw( g, rect, pt );
					border.Draw( g, pane, scaleFactor, rect );
				}
			}
		}
Beispiel #12
0
        /// <summary>
        /// Render the <see cref="Legend"/> to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphPane"/> object.
        /// </remarks>
        /// <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="PaneBase"/> 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>
        public void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // if the legend is not visible, do nothing
            if (!_isVisible)
            {
                return;
            }

            // Fill the background with the specified color if required
            _fill.Draw(g, _rect);

            PaneList paneList = GetPaneList(pane);

            float halfGap = _tmpSize / 2.0F;

            // Check for bad data values
            if (_hStack <= 0)
            {
                _hStack = 1;
            }
            if (_legendItemWidth <= 0)
            {
                _legendItemWidth = 100;
            }
            if (_legendItemHeight <= 0)
            {
                _legendItemHeight = _tmpSize;
            }

            //float gap = pane.ScaledGap( scaleFactor );

            int   iEntry = 0;
            float x, y;

            // Get a brush for the legend label text
            using (var brushB = new SolidBrush(Color.Black))
            {
                foreach (GraphPane tmpPane in paneList)
                {
                    // Loop for each curve in the CurveList collection
                    foreach (CurveItem curve in tmpPane.CurveList)
                    {
                        if (curve._label._text != "" && curve._label._isVisible)
                        {
                            // Calculate the x,y (TopLeft) location of the current
                            // curve legend label
                            // assuming:
                            //  charHeight/2 for the left margin, plus legendWidth for each
                            //    horizontal column
                            //  legendHeight is the line spacing, with no extra margin above

                            x = _rect.Left + halfGap / 2.0F +
                                (iEntry % _hStack) * _legendItemWidth;
                            y = _rect.Top + (iEntry / _hStack) * _legendItemHeight;

                            // Draw the legend label for the current curve
                            FontSpec tmpFont = (curve._label._fontSpec != null)
                                                   ? curve._label._fontSpec
                                                   : FontSpec;

                            // This is required because, for long labels, the centering can affect the
                            // position in GDI+.
                            tmpFont.StringAlignment = StringAlignment.Near;

                            tmpFont.Draw(g, pane.IsPenWidthScaled, curve._label._text,
                                         x + 2.5F * _tmpSize, y + _legendItemHeight / 2.0F,
                                         AlignH.Left, AlignV.Center, scaleFactor);

                            var rect = new RectangleF(x, y + _legendItemHeight / 4.0F,
                                                      2 * _tmpSize, _legendItemHeight / 2.0F);
                            curve.DrawLegendKey(g, tmpPane, rect, scaleFactor);

                            // maintain a curve count for positioning
                            iEntry++;
                        }
                    }
                    if (pane is MasterPane && ((MasterPane)pane).IsUniformLegendEntries)
                    {
                        break;
                    }
                }

                // Draw a border around the legend if required
                if (iEntry > 0)
                {
                    Border.Draw(g, pane.IsPenWidthScaled, scaleFactor, _rect);
                }
            }
        }