Example #1
0
        /// <summary>
        /// Draw the <see c_ref="Symbol"/> to the specified <see c_ref="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 c_ref="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 c_ref="PaneBase.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see c_ref="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 c_ref="FillType.GradientByX"/>,
        /// <see c_ref="FillType.GradientByY"/> or <see c_ref="FillType.GradientByZ"/>.</param>
        /// <param name="isSelected">Indicates that the <see c_ref="Symbol" /> should be drawn
        /// with attributes from the <see c_ref="Selection" /> class.
        /// </param>
        public void DrawSymbol(Graphics g, GraphPane pane, int x, int y,
                               float scaleFactor, bool isSelected, PointPair dataValue)
        {
            Symbol source = this;

            if (isSelected)
            {
                source = Selection.Symbol;
            }

            // 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.GetPen(pane, scaleFactor, dataValue))
                    using (GraphicsPath path = MakePath(g, scaleFactor))
                        using (Brush brush = Fill.MakeBrush(path.GetBounds(), dataValue))
                        {
                            DrawSymbol(g, x, y, path, pen, brush);
                        }

                g.SmoothingMode = sModeSave;
            }
        }
Example #2
0
        /// <summary>
        /// Render the label for this <see c_ref="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 c_ref="PieItem"/>.</param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see c_ref="ZedGraph.GraphPane"/> object using the
        /// <see c_ref="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.GetPen(pane, 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);
        }
Example #3
0
        /// <summary>
        /// Do all rendering associated with this <see c_ref="GasGaugeRegion"/> item to the specified
        /// <see c_ref="Graphics"/> device. This method is normally only
        /// called by the Draw method of the parent <see c_ref="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 c_ref="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="pos">Not used for rendering GasGaugeNeedle</param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects. This is calculated and
        /// passed down by the parent <see c_ref="ZedGraph.GraphPane"/> object using the
        /// <see c_ref="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)
            {
                _slicePath = null;
            }
            else
            {
                CalcRectangle(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;

                    _slicePath.AddPie(tRect.X, tRect.Y, tRect.Width, tRect.Height,
                                      -0.0f, -180.0f);

                    g.FillPie(Fill.MakeBrush(_boundingRectangle), tRect.X, tRect.Y, tRect.Width, tRect.Height, -StartAngle, -SweepAngle);

                    if (Border.IsVisible)
                    {
                        Pen borderPen = _border.GetPen(pane, scaleFactor);
                        g.DrawPie(borderPen, tRect.X, tRect.Y, tRect.Width, tRect.Height,
                                  -0.0f, -180.0f);
                        borderPen.Dispose();
                    }

                    g.SmoothingMode = sMode;
                }
            }
        }
Example #4
0
        /// <summary>
        /// Do all rendering associated with this <see c_ref="PieItem"/> item to the specified
        /// <see c_ref="Graphics"/> device.  This method is normally only
        /// called by the Draw method of the parent <see c_ref="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 c_ref="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 c_ref="ZedGraph.GraphPane"/> object using the
        /// <see c_ref="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, 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;

                    Fill   tFill   = _fill;
                    Border tBorder = _border;
                    if (IsSelected)
                    {
                        tFill   = Selection.Fill;
                        tBorder = Selection.Border;
                    }

                    using (Brush brush = tFill.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 = tBorder.GetPen(pane, 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;
                }
            }
        }