Ejemplo n.º 1
0
        /// <summary>
        /// Draw the <see cref="Symbol"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single symbol.
        /// </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="x">The x position of the center of the symbol in
        /// pixel units</param>
        /// <param name="y">The y position of the center of the symbol in
        /// pixel units</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="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 DrawSymbol(Graphics g, GraphPane pane, float x, float y,
                               float scaleFactor, PointPair dataValue)
        {
            // Only draw if the symbol is visible
            if (_isVisible &&
                Type != SymbolType.None &&
                x < 100000 && x > -100000 &&
                y < 100000 && y > -100000)
            {
                SmoothingMode sModeSave = g.SmoothingMode;
                if (_isAntiAlias)
                {
                    g.SmoothingMode = SmoothingMode.HighQuality;
                }

                using (Pen pen = _border.MakePen(pane.IsPenWidthScaled, scaleFactor))
                    using (GraphicsPath path = MakePath(g, scaleFactor))
                        using (Brush brush = Fill.MakeBrush(path.GetBounds(), dataValue))
                        {
                            DrawSymbol(g, x, y, path, pen, brush);
                        }

                g.SmoothingMode = sModeSave;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Do all rendering associated with this <see cref="PieItem"/> item to the specified
        /// <see cref="Graphics"/> device.  This method is normally only
        /// called by the Draw method of the parent <see cref="ZedGraph.CurveList"/>
        /// collection object.
        /// </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="pos">Not used for rendering Pies</param>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 Draw(Graphics g, GraphPane pane, int pos, float scaleFactor)
        {
            if (pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0)
            {
                //pane.PieRect = RectangleF.Empty;
                _slicePath = null;
            }
            else
            {
                //pane.PieRect = CalcPieRect( g, pane, scaleFactor, pane.ChartRect );
                CalcPieRect(g, pane, scaleFactor, pane.Chart._rect);

                _slicePath = new GraphicsPath();

                if (!_isVisible)
                {
                    return;
                }

                RectangleF tRect = _boundingRectangle;

                if (tRect.Width >= 1 && tRect.Height >= 1)
                {
                    SmoothingMode sMode = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.AntiAlias;

                    using (Brush brush = _fill.MakeBrush(_boundingRectangle))
                    {
                        g.FillPie(brush, tRect.X, tRect.Y, tRect.Width, tRect.Height, StartAngle, SweepAngle);

                        //add GraphicsPath for hit testing
                        _slicePath.AddPie(tRect.X, tRect.Y, tRect.Width, tRect.Height,
                                          StartAngle, SweepAngle);

                        if (Border.IsVisible)
                        {
                            using (Pen borderPen = _border.MakePen(pane.IsPenWidthScaled, scaleFactor))
                            {
                                g.DrawPie(borderPen, tRect.X, tRect.Y, tRect.Width, tRect.Height,
                                          StartAngle, SweepAngle);
                            }
                        }

                        if (_labelType != PieLabelType.None)
                        {
                            DrawLabel(g, pane, tRect, scaleFactor);
                        }

                        //brush.Dispose();
                    }

                    g.SmoothingMode = sMode;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Draw the <see cref="Symbol"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single symbol.
        /// </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="x">The x position of the center of the symbol in
        /// pixel units</param>
        /// <param name="y">The y position of the center of the symbol in
        /// pixel units</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="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 DrawSymbol(Graphics g, GraphPane pane, float x, float y,
                               float scaleFactor, PointPair dataValue)
        {
            // Only draw if the symbol is visible
            if (this.isVisible &&
                this.Type != SymbolType.None &&
                x < 100000 && x > -100000 &&
                y < 100000 && y > -100000)
            {
                //SolidBrush	brush = new SolidBrush( this.fill.Color );
                Pen          pen   = border.MakePen(pane.IsPenWidthScaled, scaleFactor);
                GraphicsPath path  = this.MakePath(g, scaleFactor);
                Brush        brush = this.Fill.MakeBrush(path.GetBounds(), dataValue);

                DrawSymbol(g, x, y, path, pen, brush);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Render the label for this <see cref="PieItem"/>.
        /// </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="PieItem"/>.</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 void DrawLabel(Graphics g, GraphPane pane, RectangleF rect, float scaleFactor)
        {
            if (!_labelDetail.IsVisible)
            {
                return;
            }

            using (Pen labelPen = Border.MakePen(pane.IsPenWidthScaled, scaleFactor))
            {
                //draw line from intersection point to pivot point -
                g.DrawLine(labelPen, _intersectionPoint, _pivotPoint);

                //draw horizontal line to move label away from pie...
                g.DrawLine(labelPen, _pivotPoint, _endPoint);
            }

            //draw the label (TextObj)
            _labelDetail.Draw(g, pane, scaleFactor);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Draw the <see cref="Symbol"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single symbol.
        /// </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="x">The x position of the center of the symbol in
        /// pixel units</param>
        /// <param name="y">The y position of the center of the symbol in
        /// pixel units</param>
        /// <param name="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="GraphPane.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="GraphPane.CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.
        /// </param>
        public void DrawSymbol(Graphics g, GraphPane pane, float x, float y, double scaleFactor)
        {
            // Only draw if the symbol is visible
            if (this.isVisible &&
                this.Type != SymbolType.None &&
                x < 100000 && x > -100000 &&
                y < 100000 && y > -100000)
            {
                SolidBrush brush = new SolidBrush(this.fill.Color);
                Pen        pen   = border.MakePen(pane, scaleFactor);
                //Pen pen = new Pen(this.border.Color, pane.ScaledPenWidth(border.PenWidth * scaleFactor));

                // Fill or draw the symbol as required
                if (this.fill.IsVisible)
                {
                    FillPoint(g, x, y, scaleFactor, pen, brush);
                }

                if (this.border.IsVisible)
                {
                    DrawPoint(g, x, y, scaleFactor, pen);
                }
            }
        }