コード例 #1
0
        private void RenderFill(Graphics g, Rectangle r, GraphicsPath path,
            GradientFillColor fillColor, GradientFillType fillType, int angle, bool offset)
        {
            if (fillColor.Color2.IsEmpty)
                fillType = GradientFillType.None;

            switch (fillType)
            {
                case GradientFillType.Auto:
                case GradientFillType.Angle:
                    if (offset == false)
                        angle += fillColor.GradientAngle;

                    using (Brush br = fillColor.GetBrush(r, angle))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.StartToEnd:
                    using (Brush br = fillColor.GetBrush(r, 90 + angle))
                    {
                        if (br is LinearGradientBrush)
                            ((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.HorizontalCenter:
                    if (r.Height >= 2)
                        r.Height /= 2;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 90 + angle))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.VerticalCenter:
                    if (r.Width >= 2)
                        r.Width /= 2;

                    using (LinearGradientBrush br = new
                        LinearGradientBrush(r, fillColor.Start, fillColor.End, 0f + angle))
                    {
                        br.WrapMode = WrapMode.TileFlipXY;

                        g.FillPath(br, path);
                    }
                    break;

                case GradientFillType.Center:
                    using (PathGradientBrush br = new PathGradientBrush(path))
                    {
                        if (offset == true && Scale is GaugeCircularScale)
                            br.CenterPoint = ((GaugeCircularScale)Scale).GetPoint((int) (r.Width * .45f), 180 + 45 + angle);

                        br.CenterColor = fillColor.Start;
                        br.SurroundColors = new Color[] { fillColor.End };

                        g.FillPath(br, path);
                    }
                    break;

                default:
                    using (Brush br = new SolidBrush(fillColor.Start))
                        g.FillPath(br, path);

                    break;
            }
        }
コード例 #2
0
        private void RenderCapPathSytle1(Graphics g,
            Rectangle r, GradientFillColor fillColor, GradientFillType fillType)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddEllipse(r);

                RenderFill(g, r, path, fillColor, fillType, 0, true);
                RenderBorder(g, path, fillColor);
            }
        }
コード例 #3
0
        private void RenderCapPathSytle2(Graphics g,
            Rectangle r, GradientFillColor fillColor, GradientFillType fillType)
        {
            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddEllipse(r);

                RenderFill(g, r, path, fillColor, fillType, 0, true);
                RenderBorder(g, path, fillColor);

                path.Reset();

                int angle = 180;
                int outer = (int)(r.Width * GaugePointer.CapOuterBevel);

                if (outer > 0)
                {
                    r.Inflate(-outer, -outer);

                    if (r.Width >= 2)
                    {
                        path.AddEllipse(r);
                        RenderFill(g, r, path, fillColor, fillType, 180, true);

                        path.Reset();

                        angle = 0;
                    }
                }

                int inner = (int) (r.Width*GaugePointer.CapInnerBevel);

                if (inner > 0)
                {
                    r.Inflate(-inner, -inner);

                    if (r.Width >= 2)
                    {
                        path.AddEllipse(r);
                        RenderFill(g, r, path, fillColor, fillType, angle, true);
                    }
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Determines if the fillcolor is equal to the given one
 /// </summary>
 /// <param name="begin"></param>
 /// <param name="end"></param>
 /// <param name="angle"></param>
 /// <param name="gradientFill"></param>
 /// <param name="borderColor"></param>
 /// <param name="borderWidth"></param>
 /// <returns></returns>
 public bool IsEqualTo(Color begin, Color end, float angle,
     GradientFillType gradientFill, Color borderColor, int borderWidth)
 {
     return (Color1 == begin && End == end &&
         GradientAngle == angle && GradientFillType == gradientFill &&
         borderColor == BorderColor && borderWidth == BorderWidth);
 }