Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Do all rendering associated with this <see c_ref="GasGaugeNeedle"/> 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">Not used for rendering GasGaugeNeedle</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;

                    Matrix matrix = new Matrix();

                    matrix.Translate(tRect.X + (tRect.Width / 2), tRect.Y + (tRect.Height / 2), MatrixOrder.Prepend);

                    PointF[] pts = new PointF[2];
                    pts[0] = new PointF(((tRect.Height * .10f) / 2.0f) * (float)Math.Cos(-SweepAngle * Math.PI / 180.0f),
                                        ((tRect.Height * .10f) / 2.0f) * (float)Math.Sin(-SweepAngle * Math.PI / 180.0f));
                    pts[1] = new PointF((tRect.Width / 2.0f) * (float)Math.Cos(-SweepAngle * Math.PI / 180.0f),
                                        (tRect.Width / 2.0f) * (float)Math.Sin(-SweepAngle * Math.PI / 180.0f));

                    matrix.TransformPoints(pts);

                    Pen p = new Pen(NeedleColor, ((tRect.Height * .10f) / 2.0f));
                    p.EndCap = LineCap.ArrowAnchor;
                    g.DrawLine(p, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y);

                    //Fill center 10% with Black dot;
                    Fill       f = new Fill(Color.Black);
                    RectangleF r = new RectangleF((tRect.X + (tRect.Width / 2)) - 1.0f, (tRect.Y + (tRect.Height / 2)) - 1.0f, 1.0f, 1.0f);
                    r.Inflate((tRect.Height * .10f), (tRect.Height * .10f));
                    Brush b = f.MakeBrush(r);
                    g.FillPie(b, r.X, r.Y, r.Width, r.Height, 0.0f, -180.0f);

                    Pen borderPen = new Pen(Color.White, 2.0f);
                    g.DrawPie(borderPen, r.X, r.Y, r.Width, r.Height, 0.0f, -180.0f);

                    g.SmoothingMode = sMode;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a fill brush using current properties.  This method will construct a brush based on the
        /// settings of <see c_ref="ZedGraph.Fill.Type"/>, <see c_ref="ZedGraph.Fill.Color"/>
        /// and <see c_ref="ZedGraph.Fill.Brush"/>.  If
        /// <see c_ref="ZedGraph.Fill.Type"/> is set to <see c_ref="ZedGraph.FillType.Brush"/> and
        /// <see c_ref="ZedGraph.Fill.Brush"/>
        /// is null, then a <see c_ref="LinearGradientBrush"/> will be created between the colors of
        /// <see c_ref="System.Drawing.Color.White"/> and <see c_ref="ZedGraph.Fill.Color"/>.
        /// </summary>
        /// <param name="rect">A rectangle that bounds the object to be filled.  This determines
        /// the start and end of the gradient fill.</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>
        /// <returns>A <see c_ref="System.Drawing.Brush"/> class representing the fill brush</returns>
        public Brush MakeBrush(RectangleF rect, PointPair dataValue)
        {
            // get a brush
            if (IsVisible && (!_color.IsEmpty || _brush != null))
            {
                if (rect.Height < 1.0F)
                {
                    rect.Height = 1.0F;
                }
                if (rect.Width < 1.0F)
                {
                    rect.Width = 1.0F;
                }

                //Brush	brush;
                if (_type == FillType.Brush)
                {
                    return(ScaleBrush(rect, _brush, _isScaled));
                }
                if (IsGradientValueType)
                {
                    if (dataValue != null)
                    {
                        if (!_secondaryValueGradientColor.IsEmpty)
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            Fill tmpFill = new Fill(_secondaryValueGradientColor,
                                                    GetGradientColor(dataValue), _angle);
                            return(tmpFill.MakeBrush(rect));
                        }
                        return(new SolidBrush(GetGradientColor(dataValue)));
                    }
                    if (_rangeDefault != double.MaxValue)
                    {
                        if (!_secondaryValueGradientColor.IsEmpty)
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            Fill tmpFill = new Fill(_secondaryValueGradientColor,
                                                    GetGradientColor(_rangeDefault), _angle);
                            return(tmpFill.MakeBrush(rect));
                        }
                        return(new SolidBrush(GetGradientColor(_rangeDefault)));
                    }
                    return(ScaleBrush(rect, _brush, true));
                }
                return(new SolidBrush(_color));
            }

            // Always return a suitable default
            return(new SolidBrush(Color.White));
        }
Ejemplo n.º 4
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;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Render this object to the specified <see c_ref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see c_ref="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 c_ref="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 c_ref="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, PaneBase pane, float scaleFactor)
        {
            if (_points != null && _points.Length > 1)
            {
                using (GraphicsPath path = MakePath(pane))
                {
                    // Fill or draw the symbol as required
                    if (_fill.IsVisible)
                    {
                        using (Brush brush = Fill.MakeBrush(path.GetBounds()))
                            g.FillPath(brush, path);
                    }

                    if (_border.IsVisible)
                    {
                        using (Pen pen = _border.GetPen(pane, scaleFactor))
                            g.DrawPath(pen, path);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draw a legend key entry for this <see c_ref="PieItem"/> 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 c_ref="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="rect">The <see c_ref="RectangleF"/> struct that specifies the
        /// location for the legend key</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 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);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Draw this <see c_ref="CurveItem"/> to the specified <see c_ref="Graphics"/>
        /// device as a symbol at each defined point.  The routine
        /// only draws the symbols; the lines are draw by the
        /// <see c_ref="Line.DrawCurve"/> method.  This method
        /// is normally only called by the Draw method of the
        /// <see c_ref="CurveItem"/> 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="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see c_ref="LineItem"/> representing this
        /// curve.</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="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>
        /// <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 Draw(Graphics g, GraphPane pane, LineItem curve, float scaleFactor,
                         bool isSelected)
        {
            Symbol source = this;

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

            int tmpX, tmpY;

            int minX = (int)pane.Chart.Rect.Left;
            int maxX = (int)pane.Chart.Rect.Right;
            int minY = (int)pane.Chart.Rect.Top;
            int maxY = (int)pane.Chart.Rect.Bottom;

            // (Dale-a-b) we'll set an element to true when it has been drawn
            bool[,] isPixelDrawn = new bool[maxX + 1, maxY + 1];

            double     curX, curY, lowVal;
            IPointList points = curve.Points;

            if (points != null && (_border.IsVisible || _fill.IsVisible))
            {
                SmoothingMode sModeSave = g.SmoothingMode;
                if (_isAntiAlias)
                {
                    g.SmoothingMode = SmoothingMode.HighQuality;
                }

                // For the sake of speed, go ahead and create a solid brush and a pen
                // If it's a gradient fill, it will be created on the fly for each symbol
                //SolidBrush	brush = new SolidBrush( this.fill.Color );

                using (Pen pen = source._border.GetPen(pane, scaleFactor))
                    using (GraphicsPath path = MakePath(g, scaleFactor))
                    {
                        RectangleF rect = path.GetBounds();

                        using (Brush brush = source.Fill.MakeBrush(rect))
                        {
                            ValueHandler valueHandler = new ValueHandler(pane, false);
                            Scale        xScale       = curve.GetXAxis(pane).Scale;
                            Scale        yScale       = curve.GetYAxis(pane).Scale;

                            bool xIsLog     = xScale.IsLog;
                            bool yIsLog     = yScale.IsLog;
                            bool xIsOrdinal = xScale.IsAnyOrdinal;

                            double xMin = xScale.Min;
                            double xMax = xScale.Max;

                            // Loop over each defined point
                            for (int i = 0; i < points.Count; i++)
                            {
                                // Get the user scale values for the current point
                                // use the valueHandler only for stacked types
                                if (pane.LineType == LineType.Stack)
                                {
                                    valueHandler.GetValues(curve, i, out curX, out lowVal, out curY);
                                }
                                // otherwise, just access the values directly.  Avoiding the valueHandler for
                                // non-stacked types is an optimization to minimize overhead in case there are
                                // a large number of points.
                                else
                                {
                                    curX = points[i].X;
                                    if (curve is StickItem)
                                    {
                                        curY = points[i].Z;
                                    }
                                    else
                                    {
                                        curY = points[i].Y;
                                    }
                                }

                                // Any value set to double max is invalid and should be skipped
                                // This is used for calculated values that are out of range, divide
                                //   by zero, etc.
                                // Also, any value <= zero on a log scale is invalid

                                if (curX != PointPair.Missing &&
                                    curY != PointPair.Missing &&
                                    !Double.IsNaN(curX) &&
                                    !Double.IsNaN(curY) &&
                                    !Double.IsInfinity(curX) &&
                                    !Double.IsInfinity(curY) &&
                                    (curX > 0 || !xIsLog) &&
                                    (!yIsLog || curY > 0.0) &&
                                    (xIsOrdinal || (curX >= xMin && curX <= xMax)))
                                {
                                    // Transform the user scale values to pixel locations
                                    tmpX = (int)xScale.Transform(curve.IsOverrideOrdinal, i, curX);
                                    tmpY = (int)yScale.Transform(curve.IsOverrideOrdinal, i, curY);

                                    // Maintain an array of "used" pixel locations to avoid duplicate drawing operations
                                    if (tmpX >= minX && tmpX <= maxX && tmpY >= minY && tmpY <= maxY)                               // guard against the zoom-in case
                                    {
                                        if (isPixelDrawn[tmpX, tmpY])
                                        {
                                            continue;
                                        }
                                        isPixelDrawn[tmpX, tmpY] = true;
                                    }

                                    // If the fill type for this symbol is a Gradient by value type,
                                    // the make a brush corresponding to the appropriate current value
                                    if (_fill.IsGradientValueType || _border._gradientFill.IsGradientValueType)
                                    {
                                        using (Brush tBrush = _fill.MakeBrush(rect, points[i]))
                                            using (Pen tPen = _border.GetPen(pane, scaleFactor, points[i]))
                                                DrawSymbol(g, tmpX, tmpY, path, tPen, tBrush);
                                    }
                                    else
                                    {
                                        // Otherwise, the brush is already defined
                                        // Draw the symbol at the specified pixel location
                                        DrawSymbol(g, tmpX, tmpY, path, pen, brush);
                                    }
                                }
                            }
                        }
                    }

                g.SmoothingMode = sModeSave;
            }
        }
Ejemplo n.º 8
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;
                }
            }
        }
Ejemplo n.º 9
0
		/// <summary>
		/// Do all rendering associated with this <see c_ref="GasGaugeNeedle"/> 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">Not used for rendering GasGaugeNeedle</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;

					Matrix matrix = new Matrix();

					matrix.Translate( tRect.X + ( tRect.Width / 2 ), tRect.Y + ( tRect.Height / 2 ), MatrixOrder.Prepend );

					PointF[] pts = new PointF[2];
					pts[0] = new PointF( ( ( tRect.Height * .10f ) / 2.0f ) * (float)Math.Cos( -SweepAngle * Math.PI / 180.0f ),
					( ( tRect.Height * .10f ) / 2.0f ) * (float)Math.Sin( -SweepAngle * Math.PI / 180.0f ) );
					pts[1] = new PointF( ( tRect.Width / 2.0f ) * (float)Math.Cos( -SweepAngle * Math.PI / 180.0f ),
					( tRect.Width / 2.0f ) * (float)Math.Sin( -SweepAngle * Math.PI / 180.0f ) );

					matrix.TransformPoints( pts );

					Pen p = new Pen( NeedleColor, ( ( tRect.Height * .10f ) / 2.0f ) );
					p.EndCap = LineCap.ArrowAnchor;
					g.DrawLine( p, pts[0].X, pts[0].Y, pts[1].X, pts[1].Y );

					//Fill center 10% with Black dot;
					Fill f = new Fill( Color.Black );
					RectangleF r = new RectangleF( ( tRect.X + ( tRect.Width / 2 ) ) - 1.0f, ( tRect.Y + ( tRect.Height / 2 ) ) - 1.0f, 1.0f, 1.0f );
					r.Inflate( ( tRect.Height * .10f ), ( tRect.Height * .10f ) );
					Brush b = f.MakeBrush( r );
					g.FillPie( b, r.X, r.Y, r.Width, r.Height, 0.0f, -180.0f );

					Pen borderPen = new Pen( Color.White, 2.0f );
					g.DrawPie( borderPen, r.X, r.Y, r.Width, r.Height, 0.0f, -180.0f );

					g.SmoothingMode = sMode;
				}
			}
		}
Ejemplo n.º 10
0
Archivo: Fill.cs Proyecto: CareyGit/jx
		/// <summary>
		/// Create a fill brush using current properties.  This method will construct a brush based on the
		/// settings of <see c_ref="ZedGraph.Fill.Type"/>, <see c_ref="ZedGraph.Fill.Color"/>
		/// and <see c_ref="ZedGraph.Fill.Brush"/>.  If
		/// <see c_ref="ZedGraph.Fill.Type"/> is set to <see c_ref="ZedGraph.FillType.Brush"/> and
		/// <see c_ref="ZedGraph.Fill.Brush"/>
		/// is null, then a <see c_ref="LinearGradientBrush"/> will be created between the colors of
		/// <see c_ref="System.Drawing.Color.White"/> and <see c_ref="ZedGraph.Fill.Color"/>.
		/// </summary>
		/// <param name="rect">A rectangle that bounds the object to be filled.  This determines
		/// the start and end of the gradient fill.</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>
		/// <returns>A <see c_ref="System.Drawing.Brush"/> class representing the fill brush</returns>
		public Brush MakeBrush( RectangleF rect, PointPair dataValue )
		{
			// get a brush
			if ( IsVisible && ( !_color.IsEmpty || _brush != null ) )
			{
				if ( rect.Height < 1.0F )
					rect.Height = 1.0F;
				if ( rect.Width < 1.0F )
					rect.Width = 1.0F;
					
				//Brush	brush;
				if ( _type == FillType.Brush )
				{
					return ScaleBrush( rect, _brush, _isScaled );
				}
			    if ( IsGradientValueType )
			    {
			        if ( dataValue != null )
			        {
			            if ( !_secondaryValueGradientColor.IsEmpty )
			            {
			                // Go ahead and create a new Fill so we can do all the scaling, etc.,
			                // that is associated with a gradient
			                Fill tmpFill = new Fill( _secondaryValueGradientColor,
			                    GetGradientColor( dataValue ), _angle );
			                return tmpFill.MakeBrush( rect );
			            }
			            return new SolidBrush( GetGradientColor( dataValue ) );
			        }
			        if ( _rangeDefault != double.MaxValue )
			        {
			            if ( !_secondaryValueGradientColor.IsEmpty )
			            {
			                // Go ahead and create a new Fill so we can do all the scaling, etc.,
			                // that is associated with a gradient
			                Fill tmpFill = new Fill( _secondaryValueGradientColor,
			                    GetGradientColor( _rangeDefault ), _angle );
			                return tmpFill.MakeBrush( rect );
			            }
			            return new SolidBrush( GetGradientColor( _rangeDefault ) );
			        }
			        return ScaleBrush( rect, _brush, true );
			    }
			    return new SolidBrush( _color );
			}

			// Always return a suitable default
			return new SolidBrush( Color.White );
		}