예제 #1
0
 /// <summary>
 /// Draws the glow for the button when the
 /// mouse is inside the client area using
 /// the GlowColor property.
 /// </summary>
 /// <param name="g">The graphics object used in the paint event.</param>
 private void DrawGlow(Graphics g)
 {
     if (this.mButtonState == State.Pressed) { return; }
     SetClip(g);
     using (GraphicsPath glow = new GraphicsPath())
         {
         glow.AddEllipse(-5, this.Height / 2 - 10, this.Width + 11, this.Height + 11);
         using (PathGradientBrush gl = new PathGradientBrush(glow))
             {
             gl.CenterColor = Color.FromArgb(mGlowAlpha, this.GlowColor);
             gl.SurroundColors = new Color[] { Color.FromArgb(0, this.GlowColor) };
             g.FillPath(gl, glow);
             }
         }
     g.ResetClip();
 }
예제 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            base.OnPaintBackground(e);
            Graphics  g = e.Graphics;
            Rectangle radioButtonrect;
            Rectangle textRect;

            CalculateRect(out radioButtonrect, out textRect);

            g.SmoothingMode = SmoothingMode.AntiAlias;

            Color borderColor;
            Color innerBorderColor;
            Color checkColor;
            bool  hover = false;

            if (Enabled)
            {
                switch (ControlState)
                {
                case ControlState.Hover:
                    borderColor      = _baseColor;
                    innerBorderColor = _baseColor;
                    checkColor       = GetColor(_baseColor, 0, 35, 24, 9);
                    hover            = true;
                    break;

                case ControlState.Pressed:
                    borderColor      = _baseColor;
                    innerBorderColor = GetColor(_baseColor, 0, -13, -8, -3);
                    checkColor       = GetColor(_baseColor, 0, -35, -24, -9);
                    hover            = true;
                    break;

                default:
                    borderColor      = _baseColor;
                    innerBorderColor = Color.Empty;
                    checkColor       = _baseColor;
                    break;
                }
            }
            else
            {
                borderColor      = SystemColors.ControlDark;
                innerBorderColor = SystemColors.ControlDark;
                checkColor       = SystemColors.ControlDark;
            }

            using (SolidBrush brush = new SolidBrush(Color.White))
            {
                g.FillEllipse(brush, radioButtonrect);
            }

            if (hover)
            {
                using (Pen pen = new Pen(innerBorderColor, 2F))
                {
                    g.DrawEllipse(pen, radioButtonrect);
                }
            }

            if (Checked)
            {
                radioButtonrect.Inflate(-2, -2);
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(radioButtonrect);
                    using (PathGradientBrush brush = new PathGradientBrush(path))
                    {
                        brush.CenterColor    = checkColor;
                        brush.SurroundColors = new Color[] { Color.White };
                        Blend blend = new Blend();
                        blend.Positions = new float[] { 0f, 0.4f, 1f };
                        blend.Factors   = new float[] { 0f, 0.4f, 1f };
                        brush.Blend     = blend;
                        g.FillEllipse(brush, radioButtonrect);
                    }
                }
                radioButtonrect.Inflate(2, 2);
            }

            using (Pen pen = new Pen(borderColor))
            {
                g.DrawEllipse(pen, radioButtonrect);
            }

            Color textColor = Enabled ? ForeColor : SystemColors.GrayText;

            TextRenderer.DrawText(
                g,
                Text,
                Font,
                textRect,
                textColor,
                GetTextFormatFlags(TextAlign, RightToLeft == RightToLeft.Yes));
        }
예제 #3
0
 public void SurroundColors_Empty()
 {
     using (PathGradientBrush pgb = new PathGradientBrush(pts_2f, WrapMode.TileFlipXY)) {
         Assert.Throws <ArgumentException> (() => pgb.SurroundColors = new Color[0]);
     }
 }
예제 #4
0
            public AeroTemplate()
            {
                _backgroundRect = new RectangleF(0.5f, 0.5f, 23, 23);

                _normalBackgrounBrush  = new SolidBrush(Color.FromArgb(0, 35, 130));
                _hoverBackgrounBrush   = new SolidBrush(Color.FromArgb(0, 55, 150));
                _pressedBackgrounBrush = new SolidBrush(Color.FromArgb(0, 10, 50));

                _upperBackgroundPath = new GraphicsPath();
                _upperBackgroundPath.AddArc(_backgroundRect, 180, 180);
                _upperBackgroundPath.CloseFigure();

                _lowerBackgroundPath = new GraphicsPath();
                _lowerBackgroundPath.AddArc(_backgroundRect, 0, 180);
                _lowerBackgroundPath.CloseFigure();

                var path1 = new GraphicsPath();

                path1.AddEllipse(new RectangleF(_backgroundRect.X - 2, _backgroundRect.Y, _backgroundRect.Width + 4,
                                                _backgroundRect.Height + 10));
                _normalUpperBackgroundBrush = new PathGradientBrush(path1);
                var blend1 = new ColorBlend();

                blend1.Colors = new[]
                { Color.FromArgb(240, Color.White), Color.FromArgb(50, 110, 180), Color.FromArgb(50, 110, 180) };
                blend1.Positions = new[] { 0f, 0.3f, 1f };
                _normalUpperBackgroundBrush.InterpolationColors = blend1;
                _hoverUpperBackgroundBrush = new PathGradientBrush(path1);
                var blend9 = new ColorBlend();

                blend9.Colors                = new[] { Color.White, Color.FromArgb(65, 150, 240), Color.FromArgb(65, 150, 240) };
                blend9.Positions             = new[] { 0f, 0.3f, 1f };
                _pressedUpperBackgroundBrush = new PathGradientBrush(path1);
                _hoverUpperBackgroundBrush.InterpolationColors = blend9;
                var blend8 = new ColorBlend();

                blend8.Colors = new[]
                { Color.FromArgb(200, Color.White), Color.FromArgb(35, 70, 120), Color.FromArgb(35, 70, 120) };
                blend8.Positions = new[] { 0f, 0.4f, 1f };
                _pressedUpperBackgroundBrush.InterpolationColors = blend8;
                path1.Dispose();

                var path2 = new GraphicsPath();

                path2.AddEllipse(new RectangleF(-16, 13, 56, 20));
                _normalLowerBackgroundBrush = new PathGradientBrush(path2);
                var blend2 = new ColorBlend();

                blend2.Colors = new[]
                { Color.FromArgb(0, 35, 130), Color.FromArgb(60, 195, 235), Color.FromArgb(200, 250, 255) };
                blend2.Positions = new[] { 0f, 0.7f, 1f };
                _normalLowerBackgroundBrush.InterpolationColors = blend2;
                _hoverLowerBackgroundBrush = new PathGradientBrush(path2);
                var blend10 = new ColorBlend();

                blend10.Colors = new[]
                { Color.FromArgb(0, 55, 150), Color.FromArgb(60, 195, 235), Color.FromArgb(200, 250, 255) };
                blend10.Positions = new[] { 0f, 0.7f, 1f };
                _hoverLowerBackgroundBrush.InterpolationColors = blend10;
                _pressedLowerBackgroundBrush = new PathGradientBrush(path2);
                var blend7 = new ColorBlend();

                blend7.Colors = new[]
                { Color.FromArgb(0, 10, 50), Color.FromArgb(60, 195, 235), Color.FromArgb(200, 250, 255) };
                blend7.Positions = new[] { 0f, 0.7f, 1f };
                _pressedLowerBackgroundBrush.InterpolationColors = blend7;
                path2.Dispose();

                _arrowPath = new GraphicsPath();
                var arrowTop = new PointF(7f, 12f);

                _arrowPath.AddLine(new PointF(11.5f, 17f), arrowTop);
                _arrowPath.AddLine(arrowTop, new PointF(11.5f, 7f));
                _arrowPath.StartFigure();
                _arrowPath.AddLine(arrowTop, new PointF(17, 12f));

                var arrowBrush = new LinearGradientBrush(_backgroundRect, Color.Transparent, Color.Transparent,
                                                         LinearGradientMode.Vertical);
                var blend3 = new ColorBlend();

                blend3.Colors    = new[] { Color.White, Color.White, Color.FromArgb(130, 130, 130) };
                blend3.Positions = new[] { 0, 0.5f, 1 };
                arrowBrush.InterpolationColors = blend3;

                _normalArrowPen          = new Pen(arrowBrush, 3.5f);
                _normalArrowPen.StartCap = LineCap.Round;
                _normalArrowPen.EndCap   = LineCap.Round;
                arrowBrush.Dispose();

                _disabledUpperBackgroundBrush = new SolidBrush(Color.FromArgb(193, 215, 245));
                _disabledLowerBackgroundBrush = new SolidBrush(Color.FromArgb(160, 195, 225));

                var disabledArrowBrush = new LinearGradientBrush(_backgroundRect, Color.Transparent, Color.Transparent,
                                                                 LinearGradientMode.Vertical);
                var blend4 = new ColorBlend();

                blend4.Colors = new[]
                { Color.FromArgb(215, 230, 250), Color.FromArgb(215, 230, 250), Color.FromArgb(165, 190, 230) };
                blend4.Positions = new[] { 0, 0.5f, 1 };
                disabledArrowBrush.InterpolationColors = blend4;

                _disabledArrowPen          = new Pen(disabledArrowBrush, 3.5f);
                _disabledArrowPen.StartCap = LineCap.Round;
                _disabledArrowPen.EndCap   = LineCap.Round;
                disabledArrowBrush.Dispose();

                var path3 = new GraphicsPath();

                path3.AddEllipse(new RectangleF(_backgroundRect.X - 6, _backgroundRect.Y, _backgroundRect.Width + 12,
                                                _backgroundRect.Height + 12));
                _disabledUpperBrush = new PathGradientBrush(path3);
                var blend5 = new ColorBlend();

                blend5.Colors    = new[] { Color.FromArgb(200, Color.White), Color.Transparent, Color.Transparent };
                blend5.Positions = new[] { 0f, 0.3f, 1f };
                _disabledUpperBrush.InterpolationColors = blend5;
                path3.Dispose();

                var path4 = new GraphicsPath();

                path4.AddEllipse(new RectangleF(_backgroundRect.X - 2, _backgroundRect.Y, _backgroundRect.Width + 4,
                                                _backgroundRect.Height));
                _disabledLowerBrush = new PathGradientBrush(path4);
                var blend6 = new ColorBlend();

                blend6.Colors    = new[] { Color.FromArgb(150, Color.White), Color.Transparent, Color.Transparent };
                blend6.Positions = new[] { 0f, 0.3f, 1f };
                _disabledLowerBrush.InterpolationColors = blend6;
                path4.Dispose();
            }
예제 #5
0
        public override Brush GetBrush(SvgVisualElement renderingElement, ISvgRenderer renderer, float opacity, bool forStroke = false)
        {
            LoadStops(renderingElement);

            // TODO: figure out how to do the brush transform in the presence of FocalRadius
            try
            {
                if (this.GradientUnits == SvgCoordinateUnits.ObjectBoundingBox)
                {
                    renderer.SetBoundable(renderingElement);
                }

                // Calculate the path and transform it appropriately
                var center = new PointF(NormalizeUnit(CenterX).ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
                                        NormalizeUnit(CenterY).ToDeviceValue(renderer, UnitRenderingType.Vertical, this));
                var focals = new PointF[] { new PointF(NormalizeUnit(FocalX).ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
                                                       NormalizeUnit(FocalY).ToDeviceValue(renderer, UnitRenderingType.Vertical, this)) };
                var specifiedRadius = NormalizeUnit(Radius).ToDeviceValue(renderer, UnitRenderingType.Other, this);
                var path            = new GraphicsPath();
                path.AddEllipse(
                    center.X - specifiedRadius, center.Y - specifiedRadius,
                    specifiedRadius * 2, specifiedRadius * 2
                    );

                using (var transform = EffectiveGradientTransform)
                {
                    var bounds = renderer.GetBoundable().Bounds;
                    transform.Translate(bounds.X, bounds.Y, MatrixOrder.Prepend);
                    if (this.GradientUnits == SvgCoordinateUnits.ObjectBoundingBox)
                    {
                        transform.Scale(bounds.Width, bounds.Height, MatrixOrder.Prepend);
                    }
                    path.Transform(transform);
                    transform.TransformPoints(focals);
                }


                // Calculate any required scaling
                var scaleBounds = RectangleF.Inflate(renderingElement.Bounds, renderingElement.StrokeWidth, renderingElement.StrokeWidth);
                var scale       = CalcScale(scaleBounds, path);

                // Not ideal, but this makes sure that the rest of the shape gets properly filled or drawn
                if (scale > 1.0f && SpreadMethod == SvgGradientSpreadMethod.Pad)
                {
                    var stop        = Stops.Last();
                    var origColor   = stop.GetColor(renderingElement);
                    var renderColor = System.Drawing.Color.FromArgb((int)Math.Round(opacity * stop.StopOpacity * 255), origColor);

                    var origClip = renderer.GetClip();
                    try
                    {
                        using (var solidBrush = new SolidBrush(renderColor))
                        {
                            var newClip = origClip.Clone();
                            newClip.Exclude(path);
                            renderer.SetClip(newClip);

                            var renderPath = (GraphicsPath)renderingElement.Path(renderer);
                            if (forStroke)
                            {
                                using (var pen = new Pen(solidBrush, renderingElement.StrokeWidth.ToDeviceValue(renderer, UnitRenderingType.Other, renderingElement)))
                                {
                                    renderer.DrawPath(pen, renderPath);
                                }
                            }
                            else
                            {
                                renderer.FillPath(solidBrush, renderPath);
                            }
                        }
                    }
                    finally
                    {
                        renderer.SetClip(origClip);
                    }
                }

                // Get the color blend and any tweak to the scaling
                var blend = CalculateColorBlend(renderer, opacity, scale, out scale);

                // Transform the path based on the scaling
                var gradBounds  = path.GetBounds();
                var transCenter = new PointF(gradBounds.Left + gradBounds.Width / 2, gradBounds.Top + gradBounds.Height / 2);
                using (var scaleMat = new Matrix())
                {
                    scaleMat.Translate(-1 * transCenter.X, -1 * transCenter.Y, MatrixOrder.Append);
                    scaleMat.Scale(scale, scale, MatrixOrder.Append);
                    scaleMat.Translate(transCenter.X, transCenter.Y, MatrixOrder.Append);
                    path.Transform(scaleMat);
                }

                // calculate the brush
                var brush = new PathGradientBrush(path);
                brush.CenterPoint         = focals[0];
                brush.InterpolationColors = blend;

                return(brush);
            }
            finally
            {
                if (this.GradientUnits == SvgCoordinateUnits.ObjectBoundingBox)
                {
                    renderer.PopBoundable();
                }
            }
        }
예제 #6
0
        private static void DrawButtonBackground(Graphics g, Rectangle rectangle,
                                                 bool pressed, bool hovered, bool animating, bool enabled,
                                                 Color outerBorderColor, Color backColor, Color glowColor, Color shineColor,
                                                 Color innerBorderColor, float glowOpacity)
        {
            SmoothingMode sm = g.SmoothingMode;

            g.SmoothingMode = SmoothingMode.AntiAlias;

            #region " white border "
            Rectangle rect = rectangle;
            rect.Width--;
            rect.Height--;
            using (GraphicsPath bw = CreateRoundRectangle(rect, 4))
            {
                using (Pen p = new Pen(outerBorderColor))
                {
                    g.DrawPath(p, bw);
                }
            }
            #endregion

            rect.X++;
            rect.Y++;
            rect.Width  -= 2;
            rect.Height -= 2;
            Rectangle rect2 = rect;
            rect2.Height >>= 1;

            #region " content "
            using (GraphicsPath bb = CreateRoundRectangle(rect, 2))
            {
                int opacity = pressed ? 0xcc : 0x7f;
                using (Brush br = new SolidBrush(Color.FromArgb(opacity, backColor)))
                {
                    g.FillPath(br, bb);
                }
            }
            #endregion

            #region " glow "
            if ((hovered || animating) && !pressed)
            {
                using (GraphicsPath clip = CreateRoundRectangle(rect, 2))
                {
                    g.SetClip(clip, CombineMode.Intersect);
                    using (GraphicsPath brad = CreateBottomRadialPath(rect))
                    {
                        using (PathGradientBrush pgr = new PathGradientBrush(brad))
                        {
                            int        opacity = (int)(0xB2 * glowOpacity + .5f);
                            RectangleF bounds  = brad.GetBounds();
                            pgr.CenterPoint    = new PointF((bounds.Left + bounds.Right) / 2f, (bounds.Top + bounds.Bottom) / 2f);
                            pgr.CenterColor    = Color.FromArgb(opacity, glowColor);
                            pgr.SurroundColors = new Color[] { Color.FromArgb(0, glowColor) };
                            g.FillPath(pgr, brad);
                        }
                    }
                    g.ResetClip();
                }
            }
            #endregion

            #region " shine "
            if (rect2.Width > 0 && rect2.Height > 0)
            {
                rect2.Height++;
                using (GraphicsPath bh = CreateTopRoundRectangle(rect2, 2))
                {
                    rect2.Height++;
                    int opacity = 0x99;
                    if (pressed | !enabled)
                    {
                        opacity = (int)(.4f * opacity + .5f);
                    }
                    using (LinearGradientBrush br = new LinearGradientBrush(rect2, Color.FromArgb(opacity, shineColor), Color.FromArgb(opacity / 3, shineColor), LinearGradientMode.Vertical))
                    {
                        g.FillPath(br, bh);
                    }
                }
                rect2.Height -= 2;
            }
            #endregion

            #region " black border "
            using (GraphicsPath bb = CreateRoundRectangle(rect, 3))
            {
                using (Pen p = new Pen(innerBorderColor))
                {
                    g.DrawPath(p, bb);
                }
            }
            #endregion

            g.SmoothingMode = sm;
        }
예제 #7
0
        /// <summary>
        /// Draws a polygon gradient that uses an array of points in the specified region passed to the function.  The number of points used
        /// to draw the polygon gradient will be determined by the Points parameter.  A distribution of colors will be calculated based on the
        /// number of points and the starting and ending colors specified in the function's parameters to produce the appropriate gradient
        /// effect.
        /// NOTE: As of now, only 4 and 10 point polygon gradients are supported.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="gradColor1"></param>
        /// <param name="gradColor2"></param>
        /// <param name="oOutputData"></param>
        /// <param name="iPoints">Indicates how many points will be used for drawing the polygon gradient.  The following values are
        /// allowed: 4 and 10.</param>
        public static void DrawPolyGradient(Graphics graphics, Color gradColor1, Color gradColor2, object oOutputData, int iPoints)
        {
            PathGradientBrush pathGradBrush = null;

            try
            {
                RectangleF   rectBounds;
                GraphicsPath pathOutput = null;

                GetOutputDataObjects(oOutputData, out rectBounds, out pathOutput);


                Color gradColorLightest;
                Color gradColorLighter;
                Color gradColorDarker;
                Color gradColorDarkest;

                //Indicates if the colors are going from lighter to dark or from darker to light in the gradient path.
                bool blColorAscending = false;

                //Determines whether the starting or ending color is darker and calculates a range of lighter and darker colors based
                //on whether the polygon gradient will have colors that go from lighter to darker or darker to lighter starting from the
                //center point of the gradient.
                int iColor1Sum = gradColor1.R + gradColor1.G + gradColor1.B;
                int iColor2Sum = gradColor2.R + gradColor2.G + gradColor2.B;

                if (iColor1Sum < iColor2Sum)
                {
                    gradColorLighter = gradColor2;
                    gradColorDarker  = gradColor1;
                    blColorAscending = false;
                }
                else
                {
                    gradColorLighter = gradColor1;
                    gradColorDarker  = gradColor2;
                    blColorAscending = true;
                }//end if

                int iLightR = 255, iLightG = 255, iLightB = 255;
                int iDarkR = 0, iDarkG = 0, iDarkB = 0;

                if (gradColorLighter.R + 30 <= 255)
                {
                    iLightR = gradColorLighter.R + 30;
                }

                if (gradColorLighter.G + 30 <= 255)
                {
                    iLightG = gradColorLighter.G + 30;
                }

                if (gradColorLighter.B + 30 <= 255)
                {
                    iLightB = gradColorLighter.B + 30;
                }

                //Another lighter shade of the lighter of the two gradient colors will be calculated, that will be lighter by a factor 30 on the RGB scale.
                gradColorLightest = Color.FromArgb(iLightR, iLightG, iLightB);


                if (gradColorDarker.R - 30 > 0)
                {
                    iDarkR = gradColorDarker.R - 30;
                }

                if (gradColorDarker.G - 30 > 0)
                {
                    iDarkG = gradColorDarker.G - 30;
                }

                if (gradColorDarker.B - 30 > 0)
                {
                    iDarkB = gradColorDarker.B - 30;
                }

                //Another darker shade of the darker of the two gradient colors will be calculated, that will be darker by a factor 30 on the RGB scale.
                gradColorDarkest = Color.FromArgb(iDarkR, iDarkG, iDarkB);

                PointF[] ptsF = null;

                // Construct a path gradient brush based on an array of points.
                if (iPoints == 4)
                {
                    ptsF = new PointF[] {
                        new PointF(0, 0),
                        new PointF(rectBounds.Width, 0),
                        new PointF(rectBounds.Width, rectBounds.Height),
                        new PointF(0, rectBounds.Height)
                    };
                }
                else if (iPoints == 10)
                {
                    ptsF = new PointF[] {
                        new PointF(0, 0),
                        new PointF(rectBounds.Width / 4f, 0),
                        new PointF(rectBounds.Width / 2f, 0),
                        new PointF(rectBounds.Width * .75f, 0),
                        new PointF(rectBounds.Width, 0),

                        new PointF(rectBounds.Width, rectBounds.Height),
                        new PointF(rectBounds.Width * .75f, rectBounds.Height),
                        new PointF(rectBounds.Width / 2f, rectBounds.Height),
                        new PointF(rectBounds.Width / 4f, rectBounds.Height),
                        new PointF(0, rectBounds.Height)
                    };
                }//end if

                pathGradBrush = new PathGradientBrush(ptsF);

                // An array of five points was used to construct the path gradient
                // brush. Set the color of each point in that array.
                Color[] colors = null;

                if (blColorAscending)
                {
                    if (iPoints == 4)
                    {
                        colors = new Color[]
                        {
                            gradColorDarkest, // (0, 0)
                            gradColorDarkest, // (rectBounds.Width, 0)
                            gradColorDarkest, // (rectBounds.Width, rectBounds.Height)
                            gradColorDarkest, // (0, rectBounds.Height)
                        };
                    }
                    else if (iPoints == 10)
                    {
                        colors = new Color[]
                        {
                            gradColorDarkest, // (0, 0)
                            gradColorDarker,  // (rectBounds.Width / 4f, 0)
                            gradColorLighter, // (rectBounds.Width / 2f, 0)
                            gradColorDarker,  // (rectBounds.Width * .75f, 0)
                            gradColorDarkest, // (rectBounds.Width, 0)

                            gradColorDarkest, //  (rectBounds.Width, rectBounds.Height)
                            gradColorDarker,  // (rectBounds.Width * .75f, rectBounds.Height)
                            gradColorLighter, // (rectBounds.Width / 2f, rectBounds.Height)
                            gradColorDarker,  // (rectBounds.Width / 4f, rectBounds.Height)
                            gradColorDarkest, // (0, rectBounds.Height)
                        };
                    }//end if

                    pathGradBrush.CenterColor = gradColorLightest;
                }
                else
                {
                    if (iPoints == 4)
                    {
                        colors = new Color[]
                        {
                            gradColorLightest, // (0, 0)
                            gradColorLightest, // (rectBounds.Width, 0)
                            gradColorLightest, // (rectBounds.Width, rectBounds.Height)
                            gradColorLightest, // (0, rectBounds.Height)
                        };
                    }
                    else if (iPoints == 10)
                    {
                        colors = new Color[]
                        {
                            gradColorLightest, // (0, 0)
                            gradColorLighter,  // (rectBounds.Width / 4f, 0)
                            gradColorDarker,   // (rectBounds.Width / 2f, 0)
                            gradColorLighter,  // (rectBounds.Width * .75f, 0)
                            gradColorLightest, // (rectBounds.Width, 0)

                            gradColorLightest, //  (rectBounds.Width, rectBounds.Height)
                            gradColorLighter,  // (rectBounds.Width * .75f, rectBounds.Height)
                            gradColorDarker,   // (rectBounds.Width / 2f, rectBounds.Height)
                            gradColorLighter,  // (rectBounds.Width / 4f, rectBounds.Height)
                            gradColorLightest, // (0, rectBounds.Height)
                        };
                    }//end if

                    pathGradBrush.CenterColor = gradColorDarkest;
                }//end if

                pathGradBrush.SurroundColors = colors;

                if (pathOutput == null)
                {
                    // Use the path gradient brush to fill a rectangle.
                    graphics.FillRectangle(pathGradBrush, rectBounds);
                }
                else
                {
                    // Use the path gradient brush to fill region in graphics path.
                    graphics.FillPath(pathGradBrush, pathOutput);
                }
            }
            catch (Exception err)
            {
                ErrorHandler.ShowErrorMessage(err, "Error in DrawPolyGradient function of CoolGradient class.");
            }
            finally
            {
                if (pathGradBrush != null)
                {
                    pathGradBrush.Dispose();
                }
            }
        }
예제 #8
0
        Brush GetGradientBrush(RectangleF rectangle, Color firstColor, Color secondColor, GradientStyle type)
        {
            rectangle.Inflate(1f, 1f);
            Brush brush = null;
            float angle = 0f;

            if ((rectangle.Height == 0f) || (rectangle.Width == 0f))
            {
                return(new SolidBrush(Color.Black));
            }
            if ((type == GradientStyle.LeftRight) || (type == GradientStyle.VerticalCenter))
            {
                angle = 0f;
            }
            else if ((type == GradientStyle.TopBottom) || (type == GradientStyle.HorizontalCenter))
            {
                angle = 90f;
            }
            else if (type == GradientStyle.DiagonalLeft)
            {
                angle = (float)((Math.Atan((double)(rectangle.Width / rectangle.Height)) * 180.0) / 3.1415926535897931);
            }
            else if (type == GradientStyle.DiagonalRight)
            {
                angle = (float)(180.0 - ((Math.Atan((double)(rectangle.Width / rectangle.Height)) * 180.0) / 3.1415926535897931));
            }
            if ((((type == GradientStyle.TopBottom) || (type == GradientStyle.LeftRight)) || ((type == GradientStyle.DiagonalLeft) || (type == GradientStyle.DiagonalRight))) || ((type == GradientStyle.HorizontalCenter) || (type == GradientStyle.VerticalCenter)))
            {
                RectangleF rect = new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                if (type == GradientStyle.HorizontalCenter)
                {
                    rect.Height /= 2f;
                    LinearGradientBrush brush2 = new LinearGradientBrush(rect, firstColor, secondColor, angle);
                    brush           = brush2;
                    brush2.WrapMode = WrapMode.TileFlipX;
                    return(brush);
                }
                if (type == GradientStyle.VerticalCenter)
                {
                    rect.Width /= 2f;
                    LinearGradientBrush brush3 = new LinearGradientBrush(rect, firstColor, secondColor, angle);
                    brush           = brush3;
                    brush3.WrapMode = WrapMode.TileFlipX;
                    return(brush);
                }
                return(new LinearGradientBrush(rectangle, firstColor, secondColor, angle));
            }
            GraphicsPath path = new GraphicsPath();

            path.AddRectangle(rectangle);
            PathGradientBrush brush4 = new PathGradientBrush(path);

            brush = brush4;
            brush4.CenterColor = firstColor;
            Color[] colorArray = new Color[] { secondColor };
            brush4.SurroundColors = colorArray;
            if (path != null)
            {
                path.Dispose();
            }
            return(brush);
        }
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;

            ButtonRenderer.DrawParentBackground(g, ClientRectangle, this);
            float Angle = 90F;

            if (!isHotTracking)
            {
                paintGradientTop         = gradientTop;
                paintGradientBottom      = gradientBottom;
                paintGradientBorderColor = gradientBorderColor;
                paintForeColor           = ForeColor;
            }
            else
            {
                paintGradientTop         = _hotGradientTop;
                paintGradientBottom      = _hotGradientBottom;
                paintGradientBorderColor = _hotGradientBorderColor;
                paintForeColor           = _hotForeColor;
            }
            if (isPressed)
            {
                paintGradientTop         = _pressedGradientTop;
                paintGradientBottom      = _pressedGradientBottom;
                paintGradientBorderColor = _pressedGradientBorderColor;
                paintForeColor           = _pressedForeColor;
            }


            // Paint the outer rounded rectangle
            g.SmoothingMode = SmoothingMode.AntiAlias;
            using (GraphicsPath outerPath = RoundedRectangle(buttonRect, rectCornerRadius, 0))
            {
                using (LinearGradientBrush outerBrush = new LinearGradientBrush(buttonRect, Color.White, Color.White, LinearGradientMode.Vertical))
                {
                    g.FillPath(outerBrush, outerPath);
                }
                using (Pen outlinePen = new Pen(paintGradientBorderColor, rectOutlineWidth))
                {
                    outlinePen.Alignment = PenAlignment.Inset;
                    g.DrawPath(outlinePen, outerPath);
                }
            }
            // If this is the default button, paint an additional highlight
            if (IsDefault)
            {
                using (GraphicsPath defaultPath = new GraphicsPath())
                {
                    defaultPath.AddPath(RoundedRectangle(buttonRect, rectCornerRadius, 0), false);
                    defaultPath.AddPath(RoundedRectangle(buttonRect, rectCornerRadius, defaultHighlightOffset), false);
                    using (PathGradientBrush defaultBrush = new PathGradientBrush(defaultPath))
                    {
                        defaultBrush.CenterColor    = Color.FromArgb(50, Color.White);
                        defaultBrush.SurroundColors = new Color[] { Color.FromArgb(150, Color.White) };
                        g.FillPath(defaultBrush, defaultPath);
                    }
                }
            }
            // Paint the gel highlight
            using (GraphicsPath innerPath = RoundedRectangle(highlightRect, rectCornerRadius, highlightRectOffset))
            {
                //using (LinearGradientBrush innerBrush = new LinearGradientBrush(highlightRect, Color.FromArgb(highlightAlphaTop, Color.White), Color.FromArgb(highlightAlphaBottom, Color.White), LinearGradientMode.Vertical))
                //{
                g.FillPath(DrawingMethods.GetBrush(ClientRectangle, paintGradientTop, paintGradientBottom, DrawingMethods.PaletteColourStyle.Default, Angle, DrawingMethods.VisualOrientation.Top, false), innerPath);
                //g.FillPath(innerBrush, innerPath);
                //}
            }
            // Paint the text
            //TextRenderer.DrawText(g, Text, Font, buttonRect, paintForeColor, Color.Transparent, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);
            OnDrawTextAndImage(g);
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Graphics   G  = e.Graphics;
            Rectangle  R3 = new Rectangle();
            HatchBrush HB = default(HatchBrush);

            G.Clear(Color.White);
            G.SmoothingMode = SmoothingMode.HighQuality;

            GP1 = RoundRec(new Rectangle(0, 0, Width - 1, Height - 1), 4);
            GP2 = RoundRec(new Rectangle(1, 1, Width - 3, Height - 3), 4);

            R1  = new Rectangle(0, 2, Width - 1, Height - 1);
            GB1 = new LinearGradientBrush(R1, Color.FromArgb(255, 255, 255), Color.FromArgb(230, 230, 230), 90f);



            G.SetClip(GP1);
            //gloss
            PathGradientBrush PB = new PathGradientBrush(GP1);

            PB.CenterColor    = Color.FromArgb(230, 230, 230);
            PB.SurroundColors = new Color[] { Color.FromArgb(255, 255, 255) };
            PB.CenterPoint    = new Point(0, Height);
            PB.FocusScales    = new PointF(1, 0);

            G.FillRectangle(PB, R1);

            G.FillPath(new SolidBrush(Color.FromArgb(250, 250, 250)), RoundRec(new Rectangle(1, 1, Width - 3, Height / 2 - 2), 4));

            I1 = Convert.ToInt32((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3));


            if (I1 > 1)
            {
                GP3 = RoundRec(new Rectangle(1, 1, I1, Height - 3), 4);

                //grad
                HB = new HatchBrush(HatchStyle.Trellis, Color.FromArgb(50, Color.Black), Color.Transparent);



                //bar
                R2  = new Rectangle(1, 1, I1, Height - 3);
                GB2 = new LinearGradientBrush(R2, Color.FromArgb(20, 34, 45), Color.FromArgb(27, 84, 121), 90f);

                G.FillPath(GB2, GP3);
                G.DrawPath(new Pen(Color.FromArgb(120, 134, 145)), GP3);

                G.SetClip(GP3);
                G.SmoothingMode = SmoothingMode.None;



                G.FillRectangle(new SolidBrush(Color.FromArgb(32, 100, 144)), R2.X, R2.Y + 1, R2.Width, R2.Height / 2);

                R3 = new Rectangle(1, 1, I1, Height - 1);

                G.FillRectangle(HB, R3);

                G.SmoothingMode = SmoothingMode.AntiAlias;
                G.ResetClip();
            }



            G.DrawPath(new Pen(Color.FromArgb(125, 125, 125)), GP2);
            G.DrawPath(new Pen(Color.FromArgb(80, Color.LightGray)), GP1);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (_isNewSize())
            {
                redrawBackground();
            }
            if (backgroundBuffer != null)
            {
                e.Graphics.DrawImageUnscaled(backgroundBuffer, 0, 0);
            }

            float DPIsf = 96 / e.Graphics.DpiX;

            System.Drawing.Pen myPen = new System.Drawing.Pen(Color.Black);
            Font       drawFont      = new Font("Arial", 12 * DPIsf);
            SolidBrush drawBrush     = new SolidBrush(Color.White);

            int size = this.Size.Width > this.Size.Height ? this.Size.Height : this.Size.Width;

            int   beginDeg   = 135;
            int   endDeg     = beginDeg + 270;
            int   numOfTicks = 46;
            float degSep     = ((float)endDeg - beginDeg) / (float)(numOfTicks - 1);

            double value = currentSpeed / maxSpeed;
            Tuple <double, double> speedPos = polarToLinear(size / 4, ((double)endDeg - beginDeg) * value + beginDeg, size / 2, size / 2);

            float fontSize = size / 13 * DPIsf;

            if (fontSize < 1)
            {
                fontSize = 1;
            }
            Font       bigSpeedFont     = new Font("Arial", fontSize);
            SolidBrush bigSpeedBrush    = new SolidBrush(Color.White);
            SizeF      bigSpeedTextSize = e.Graphics.MeasureString("km/h", bigSpeedFont);

            e.Graphics.DrawString("km/h", bigSpeedFont, bigSpeedBrush, (float)(size / 2 - bigSpeedTextSize.Width / 2), (float)(size * .57 - bigSpeedTextSize.Height / 2));

            bigSpeedTextSize = e.Graphics.MeasureString(currentSpeed.ToString(), bigSpeedFont);
            e.Graphics.DrawString(currentSpeed.ToString(), bigSpeedFont, bigSpeedBrush, (float)(size / 2 - bigSpeedTextSize.Width / 2), (float)(size * .43 - bigSpeedTextSize.Height / 2));

            int       gradientSize = (int)(size / 2.5);
            Rectangle bounds       = new Rectangle((int)speedPos.Item1 - gradientSize / 2, (int)speedPos.Item2 - gradientSize / 2, checkZero(gradientSize), checkZero(gradientSize));

            using (var ellipsePath = new GraphicsPath())
            {
                ellipsePath.AddEllipse(bounds);
                using (var brush = new PathGradientBrush(ellipsePath))
                {
                    brush.CenterPoint    = new PointF(bounds.Width / 2f + bounds.X, bounds.Height / 2f + bounds.Y);
                    brush.CenterColor    = Color.FromArgb(150, 0xf0, 0xa1, 0x0a);
                    brush.SurroundColors = new[] { Color.FromArgb(0, 0xf0, 0xa1, 0x0a) };
                    brush.FocusScales    = new PointF(0, 0);

                    e.Graphics.FillRectangle(brush, bounds);
                }
            }

            fillCircle(e.Graphics, new SolidBrush(Color.FromArgb(0xf0, 0xa1, 0x0a)), (float)speedPos.Item1, (float)speedPos.Item2, (float)5.0);
        }
예제 #12
0
        /// <summary>
        /// 角丸を描く
        /// </summary>
        /// <param name="g"></param>
        private void PaintCorner(Graphics g)
        {
            // 描画品質設定
            SetSmoothMode(g);

            // 変数初期化
            int offset = shadowSize + GetHarfPenWidth();
            int w      = this.Width - cornerR;
            int h      = this.Height - cornerR;

            // 影用のパス初期化
            GraphicsPath shadowPath = null;

            if (shadowSize > 0)
            {
                shadowPath = GetShadowPath();
            }

            // 影用のブラシ初期化
            PathGradientBrush shadowBrush = null;

            if (shadowSize > 0)
            {
                shadowBrush = GetShadowBrush(shadowPath);
            }

            // 角丸用のペンとブラシ初期化
            Pen   cornerPen = new Pen(cornerColor, penWidth);
            Brush fillBrush = new SolidBrush(innerColor);

            // 角丸用のパスの初期化
            GraphicsPath graphPath = new GraphicsPath();

            graphPath.AddArc(offset, offset, cornerR, cornerR, 180, 90);
            graphPath.AddArc(w - offset, offset, cornerR, cornerR, 270, 90);
            graphPath.AddArc(w - offset, h - offset, cornerR, cornerR, 0, 90);
            graphPath.AddArc(offset, h - offset, cornerR, cornerR, 90, 90);
            graphPath.CloseFigure();

            // 影塗り
            if (shadowSize > 0)
            {
                g.FillPath(shadowBrush, shadowPath);
            }

            // 角丸用のパス塗り
            g.FillPath(fillBrush, graphPath);

            // ペンの太さが 1 以上なら角丸描画
            if (penWidth > 0)
            {
                g.DrawPath(cornerPen, graphPath);
            }

            // 後処理
            if (shadowSize > 0)
            {
                shadowPath.Dispose();
                shadowBrush.Dispose();
            }
            fillBrush.Dispose();
            cornerPen.Dispose();
        }
예제 #13
0
        public static Bitmap BothAlpha(Bitmap p_Bitmap, bool p_CentralTransparent, bool p_Crossdirection)
        {
            Bitmap   bitmap1   = new Bitmap(p_Bitmap.Width, p_Bitmap.Height);
            Graphics graphics1 = Graphics.FromImage((Image)bitmap1);

            graphics1.DrawImage((Image)p_Bitmap, new Rectangle(0, 0, p_Bitmap.Width, p_Bitmap.Height));
            graphics1.Dispose();
            Bitmap   bitmap2   = new Bitmap(bitmap1.Width, bitmap1.Height);
            Graphics graphics2 = Graphics.FromImage((Image)bitmap2);

            System.Drawing.Point point1 = new System.Drawing.Point(0, 0);
            System.Drawing.Point point2 = new System.Drawing.Point(bitmap2.Width, 0);
            System.Drawing.Point point3 = new System.Drawing.Point(bitmap2.Width, bitmap2.Height / 2);
            System.Drawing.Point point4 = new System.Drawing.Point(0, bitmap2.Height / 2);
            if (p_Crossdirection)
            {
                point1 = new System.Drawing.Point(0, 0);
                point2 = new System.Drawing.Point(bitmap2.Width / 2, 0);
                point3 = new System.Drawing.Point(bitmap2.Width / 2, bitmap2.Height);
                point4 = new System.Drawing.Point(0, bitmap2.Height);
            }
            PathGradientBrush pathGradientBrush = new PathGradientBrush(new System.Drawing.Point[4]
            {
                point1,
                point2,
                point3,
                point4
            }, WrapMode.TileFlipY);

            pathGradientBrush.CenterPoint    = new PointF(0.0f, 0.0f);
            pathGradientBrush.FocusScales    = new PointF((float)(bitmap2.Width / 2), 0.0f);
            pathGradientBrush.CenterColor    = Color.FromArgb(0, (int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue);
            pathGradientBrush.SurroundColors = new Color[1]
            {
                Color.FromArgb((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue)
            };
            if (p_Crossdirection)
            {
                pathGradientBrush.FocusScales = new PointF(0.0f, (float)bitmap2.Height);
                pathGradientBrush.WrapMode    = WrapMode.TileFlipX;
            }
            if (p_CentralTransparent)
            {
                pathGradientBrush.CenterColor    = Color.FromArgb((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue);
                pathGradientBrush.SurroundColors = new Color[1]
                {
                    Color.FromArgb(0, (int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue)
                };
            }
            graphics2.FillRectangle((Brush)pathGradientBrush, new Rectangle(0, 0, bitmap2.Width, bitmap2.Height));
            graphics2.Dispose();
            BitmapData bitmapdata1 = bitmap2.LockBits(new Rectangle(0, 0, bitmap2.Width, bitmap2.Height), ImageLockMode.ReadOnly, bitmap2.PixelFormat);

            byte[] destination = new byte[bitmapdata1.Stride * bitmapdata1.Height];
            Marshal.Copy(bitmapdata1.Scan0, destination, 0, destination.Length);
            bitmap2.UnlockBits(bitmapdata1);
            BitmapData bitmapdata2 = bitmap1.LockBits(new Rectangle(0, 0, bitmap1.Width, bitmap1.Height), ImageLockMode.ReadWrite, bitmap1.PixelFormat);

            byte[] numArray = new byte[bitmapdata2.Stride * bitmapdata2.Height];
            Marshal.Copy(bitmapdata2.Scan0, numArray, 0, numArray.Length);
            for (int index1 = 0; index1 != bitmapdata2.Height; ++index1)
            {
                int index2 = index1 * bitmapdata2.Stride + 3;
                for (int index3 = 0; index3 != bitmapdata2.Width; ++index3)
                {
                    numArray[index2] = destination[index2];
                    index2          += 4;
                }
            }
            Marshal.Copy(numArray, 0, bitmapdata2.Scan0, numArray.Length);
            bitmap1.UnlockBits(bitmapdata2);
            return(bitmap1);
        }
예제 #14
0
        /// <summary>
        /// Draws a triangular style of gradient in the specified region passed to the function.  The triangular gradient will be drawn using the
        /// starting and ending colors specified in the function's parameters.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="gradColor1"></param>
        /// <param name="gradColor2"></param>
        /// <param name="oOutputData"></param>
        public static void DrawTriangleGradient(Graphics graphics, Color gradColor1, Color gradColor2, object oOutputData)
        {
            PathGradientBrush pathGradBrush = null;

            try
            {
                RectangleF   rectBounds;
                GraphicsPath pathOutput = null;

                GetOutputDataObjects(oOutputData, out rectBounds, out pathOutput);

                SizeF szBounds = new SizeF(rectBounds.Width * 3, rectBounds.Height * 3);

                // Vertices of the outer triangle.. The triangle is drawn in shape that will allow the center of the gradient and its distribution
                //of colors to be properly cropped and displayed in the UI of the control having the gradient drawn.
                Point[] points =
                {
                    new Point(Convert.ToInt32(szBounds.Width / 2),                                     0),
                    new Point(Convert.ToInt32(szBounds.Width),     Convert.ToInt32(szBounds.Height * .8)),
                    new Point(0,                                   Convert.ToInt32(szBounds.Height * .8))
                };

                // No GraphicsPath object is created. The PathGradientBrush object is constructed directly from the array of points.
                pathGradBrush = new PathGradientBrush(points);

                Color[] colors = { gradColor1, gradColor2 };

                float[] relativePositions = { 0f, 1.0f };

                ColorBlend colorBlend = new ColorBlend();
                colorBlend.Colors    = colors;
                colorBlend.Positions = relativePositions;
                pathGradBrush.InterpolationColors = colorBlend;

                if (pathOutput == null)
                {
                    Bitmap   bmpMemory = new Bitmap(Convert.ToInt32(szBounds.Width), Convert.ToInt32(szBounds.Height));
                    Graphics gMemory   = Graphics.FromImage(bmpMemory);

                    //Draws the triangle gradient in a expanded region in memory, so that the desired region of the triangle gradient can be
                    //rendered onto the device context (paintable surface/display) of the control's UI.  The portion of the rectangle outside the
                    //triangle will not be painted, although this will not matter, since we will be cropping a section within the region of the triangle.
                    gMemory.FillRectangle(pathGradBrush, 0, 0, bmpMemory.Width, bmpMemory.Height);
                    gMemory.Dispose();


                    RectangleF rectSrc, rectDest;

                    float fSrcX = (bmpMemory.Width - rectBounds.Width) / 2;
                    float fSrcY = (bmpMemory.Height - rectBounds.Height) / 2;

                    rectSrc  = new RectangleF(fSrcX, fSrcY, rectBounds.Width, rectBounds.Height);
                    rectDest = new RectangleF(rectBounds.Left, rectBounds.Top, rectBounds.Width, rectBounds.Height);

                    //Draws a cropped region of the center-most area of the triangle gradient in the memory-resident image which will be
                    //rendered on the control's UI display.  The triangle gradient and points were calculated in a way that the center of the
                    //gradient can be cropped and drawn into the UI control's display.  This will result in producing the desired gradient effect for the control.
                    graphics.DrawImage(bmpMemory, rectDest, rectSrc, GraphicsUnit.Pixel);

                    bmpMemory.Dispose();
                }
                else
                {
                    graphics.FillPath(pathGradBrush, pathOutput);
                }//end if
            }
            catch (Exception err)
            {
                ErrorHandler.ShowErrorMessage(err, "Error in DrawTriangleGradient function of CoolGradient class.");
            }
            finally
            {
                if (pathGradBrush != null)
                {
                    pathGradBrush.Dispose();
                }
            }
        }
예제 #15
0
파일: Themebase.cs 프로젝트: Aookii/DH_Rat
    public void DrawRadial(ColorBlend blend, Rectangle r, int cx, int cy)
    {
        DrawRadialPath.Reset();
        DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1);

        DrawRadialBrush1 = new PathGradientBrush(DrawRadialPath);
        DrawRadialBrush1.CenterPoint = new Point(r.X + cx, r.Y + cy);
        DrawRadialBrush1.InterpolationColors = blend;

        if (G.SmoothingMode == SmoothingMode.AntiAlias)
        {
            G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3);
        }
        else
        {
            G.FillEllipse(DrawRadialBrush1, r);
        }
    }
예제 #16
0
        private void DrawBackground(Graphics g, RectangleF rect, float radius, Color clrDark, Color clrMain, Color clrLight)
        {
            if (radius < 0)
            {
                radius = 0;
            }
            LinearGradientBrush brush;
            SolidBrush          brushS = new SolidBrush(clrMain);

            g.SmoothingMode = SmoothingMode.HighQuality;
            //sin(45)=.85. But experimentally, .7 works much better.
            //1/.85=1.18 But experimentally, 1.37 works better. What gives?
            //top
            brush = new LinearGradientBrush(new PointF(rect.Left + radius, rect.Top + radius),
                                            new PointF(rect.Left + radius, rect.Top),
                                            clrMain, clrLight);
            g.FillRectangle(brushS, rect.Left + radius, rect.Top, rect.Width - (radius * 2), radius);
            //UR
            //2 pies of 45 each.
            brush = new LinearGradientBrush(new PointF(rect.Right - radius, rect.Top),
                                            new PointF(rect.Right - (radius / 2f), rect.Top + (radius / 2f)),
                                            clrLight, clrMain);
            g.FillPie(brushS, rect.Right - (radius * 2), rect.Top, radius * 2, radius * 2, 270, 45);
            brush = new LinearGradientBrush(new PointF(rect.Right - (radius / 2f) - .5f, rect.Top + (radius / 2f) - .5f),
                                            new PointF(rect.Right, rect.Top + radius),
                                            clrMain, clrDark);
            g.FillPie(brush, rect.Right - (radius * 2), rect.Top, radius * 2, radius * 2, 315, 45);
            //right
            brush = new LinearGradientBrush(new PointF(rect.Right - radius, rect.Top + radius),
                                            new PointF(rect.Right, rect.Top + radius),
                                            clrMain, clrDark);
            g.FillRectangle(brush, rect.Right - radius, rect.Top + radius - .5f, radius, rect.Height - (radius * 2) + 1f);
            //LR
            g.FillPie(new SolidBrush(clrDark), rect.Right - (radius * 2), rect.Bottom - (radius * 2), radius * 2, radius * 2, 0, 90);
            brush = new LinearGradientBrush(new PointF(rect.Right - radius, rect.Bottom - radius),
                                            new PointF(rect.Right - (radius * .5f) + .5f, rect.Bottom - (radius * .5f) + .5f),
                                            clrMain, clrDark);
            g.FillPolygon(brush, new PointF[] {
                new PointF(rect.Right - radius, rect.Bottom - radius),
                new PointF(rect.Right, rect.Bottom - radius),
                new PointF(rect.Right - radius, rect.Bottom)
            });
            //bottom
            brush = new LinearGradientBrush(new PointF(rect.Left + radius, rect.Bottom - radius),
                                            new PointF(rect.Left + radius, rect.Bottom),
                                            clrMain, clrDark);
            g.FillRectangle(brush, rect.Left + radius - .5f, rect.Bottom - radius, rect.Width - (radius * 2) + 1f, radius);
            //LL
            //2 pies of 45 each.
            brush = new LinearGradientBrush(new PointF(rect.Left + (radius / 2f), rect.Bottom - (radius / 2f)),
                                            new PointF(rect.Left + radius, rect.Bottom),
                                            clrMain, clrDark);
            g.FillPie(brush, rect.Left, rect.Bottom - (radius * 2), radius * 2, radius * 2, 90, 45);
            brush = new LinearGradientBrush(new PointF(rect.Left + (radius / 2f), rect.Bottom - (radius / 2f)),
                                            new PointF(rect.Left, rect.Bottom - radius),
                                            clrMain, clrLight);
            g.FillPie(brushS, rect.Left, rect.Bottom - (radius * 2), radius * 2, radius * 2, 135, 45);
            //left
            brush = new LinearGradientBrush(new PointF(rect.Left + radius, rect.Top),
                                            new PointF(rect.Left, rect.Top),
                                            clrMain, clrLight);
            g.FillRectangle(brushS, rect.Left, rect.Top + radius, radius, rect.Height - (radius * 2));
            //UL
            g.FillPie(            //new SolidBrush(clrLight)
                brushS, rect.Left, rect.Top, radius * 2, radius * 2, 180, 90);
            brush = new LinearGradientBrush(new PointF(rect.Left + radius, rect.Top + radius),
                                            new PointF(rect.Left + (radius / 2f), rect.Top + (radius / 2f)),
                                            clrMain, clrLight);
            //center
            GraphicsPath path = new GraphicsPath();

            path.AddEllipse(rect.Left - rect.Width / 8f, rect.Top - rect.Height / 2f, rect.Width, rect.Height * 3f / 2f);
            PathGradientBrush pathBrush = new PathGradientBrush(path);

            pathBrush.CenterColor    = Color.FromArgb(255, 255, 255, 255);
            pathBrush.SurroundColors = new Color[] { Color.FromArgb(0, 255, 255, 255) };
            g.FillRectangle(new SolidBrush(clrMain),
                            rect.Left + radius - .5f, rect.Top + radius - .5f,
                            rect.Width - (radius * 2) + 1f, rect.Height - (radius * 2) + 1f);
            g.FillRectangle(
                pathBrush,
                rect.Left + radius - .5f, rect.Top + radius - .5f,
                rect.Width - (radius * 2) + 1f, rect.Height - (radius * 2) + 1f);
            //highlights
            brush = new LinearGradientBrush(new PointF(rect.Left + radius, rect.Top),
                                            new PointF(rect.Left + radius + rect.Width * 2f / 3f, rect.Top),
                                            clrLight, clrMain);
            g.FillRectangle(brush, rect.Left + radius, rect.Y + radius * 3f / 8f, rect.Width / 2f, radius / 4f);
            path = new GraphicsPath();
            path.AddLine(rect.Left + radius, rect.Top + radius * 3 / 8, rect.Left + radius, rect.Top + radius * 5 / 8);
            path.AddArc(new RectangleF(rect.Left + radius * 5 / 8, rect.Top + radius * 5 / 8, radius * 3 / 4, radius * 3 / 4), 270, -90);
            path.AddArc(new RectangleF(rect.Left + radius * 3 / 8, rect.Top + radius * 7 / 8, radius * 1 / 4, radius * 1 / 4), 0, 180);
            path.AddArc(new RectangleF(rect.Left + radius * 3 / 8, rect.Top + radius * 3 / 8, radius * 5 / 4, radius * 5 / 4), 180, 90);
            //g.DrawPath(Pens.Red,path);
            g.FillPath(new SolidBrush(clrLight), path);
        }
예제 #17
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Color[] colorArray = null;
            bool    flag       = false;

            base.OnPaint(e);
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            //INSTANT VB TODO TASK: There is no VB equivalent to 'checked' in this context:
            //ORIGINAL LINE: Rectangle rectangle = new Rectangle(0, 0, checked((int)Math.Round((double)((float)((float)this.Width - 1f)))), checked((int)Math.Round((double)((float)((float)this.Height - 1f)))));
            Rectangle rectangle = new Rectangle(0, 0, Convert.ToInt32(Math.Truncate(Math.Round((double)((float)this.Width - 1.0F)))), Convert.ToInt32(Math.Truncate(Math.Round((double)((float)this.Height - 1.0F)))));
            //INSTANT VB TODO TASK: There is no VB equivalent to 'checked' in this context:
            //ORIGINAL LINE: Rectangle rectangle1 = new Rectangle(2, 2, checked((int)Math.Round((double)((float)((float)this.Width - 5f)))), checked((int)Math.Round((double)((float)((float)this.Height - 5f)))));
            Rectangle rectangle1 = new Rectangle(2, 2, Convert.ToInt32(Math.Truncate(Math.Round((double)((float)this.Width - 5.0F)))), Convert.ToInt32(Math.Truncate(Math.Round((double)((float)this.Height - 5.0F)))));
            //INSTANT VB TODO TASK: There is no VB equivalent to 'checked' in this context:
            //ORIGINAL LINE: Rectangle rectangle2 = new Rectangle(3, 3, checked((int)Math.Round((double)((float)((float)this.Width - 7f)))), checked((int)Math.Round((double)((float)((float)this.Height - 7f)))));
            Rectangle rectangle2 = new Rectangle(3, 3, Convert.ToInt32(Math.Truncate(Math.Round((double)((float)this.Width - 7.0F)))), Convert.ToInt32(Math.Truncate(Math.Round((double)((float)this.Height - 7.0F)))));
            //INSTANT VB TODO TASK: There is no VB equivalent to 'checked' in this context:
            //ORIGINAL LINE: Rectangle rectangle3 = new Rectangle(5, 5, checked((int)Math.Round((double)((float)((float)this.Width - 11f)))), checked((int)Math.Round((double)((float)((float)this.Height - 11f)))));
            Rectangle rectangle3 = new Rectangle(5, 5, Convert.ToInt32(Math.Truncate(Math.Round((double)((float)this.Width - 11.0F)))), Convert.ToInt32(Math.Truncate(Math.Round((double)((float)this.Height - 11.0F)))));

            if (this._border)
            {
                e.Graphics.DrawEllipse(new Pen(this._borderColor, 1.5F), rectangle);
            }
            if (!this.BlinkTimer.Enabled)
            {
                if (!this.m_Value)
                {
                    this.LED_ON = false;
                }
                else
                {
                    this.LED_ON = true;
                }
            }
            GraphicsPath graphicsPath = new GraphicsPath();

            graphicsPath.AddEllipse(rectangle3);
            PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath);

            if (!this.LED_ON)
            {
                e.Graphics.FillEllipse(new SolidBrush(Color.Black), rectangle1);
                this.color1 = Color.FromArgb(255, ControlPaint.Dark(this._brushONColor[Convert.ToInt32(this._LEDColor)]));
                this.color2 = Color.FromArgb(100, this.color1);
                e.Graphics.DrawEllipse(new Pen(Color.FromArgb(45, this._brushONColor[Convert.ToInt32(this._LEDColor)]), 2.5F), rectangle2);
            }
            else
            {
                if (this._LEDColor != LED_Col.Green && this._LEDColor != LED_Col.Orange)
                {
                    if (this._LEDColor == LED_Col.Violet)
                    {
                        goto Label1;
                    }
                    flag = false;
                    goto Label0;
                }
Label1:
                flag = true;
Label0:
                if (!flag)
                {
                    e.Graphics.FillEllipse(new SolidBrush(ControlPaint.Dark(this._brushONColor[Convert.ToInt32(this._LEDColor)], 20.0F)), rectangle1);
                }
                else
                {
                    e.Graphics.FillEllipse(new SolidBrush(ControlPaint.Dark(this._brushONColor[Convert.ToInt32(this._LEDColor)])), rectangle1);
                }
                this.color1 = Color.FromArgb(255, this._brushONColor[Convert.ToInt32(this._LEDColor)]);
                this.color2 = Color.FromArgb(0, this.color1);
                e.Graphics.DrawEllipse(new Pen(Color.FromArgb(125, this._brushONColor[Convert.ToInt32(this._LEDColor)]), 2.5F), rectangle2);
                if (this._LEDBrightness == LED_Bri.Brighter)
                {
                    pathGradientBrush.CenterColor = ControlPaint.Light(this._brushONColor[Convert.ToInt32(this._LEDColor)]);
                    colorArray = new Color[] { Color.FromArgb(25, ControlPaint.Light(this._brushONColor[Convert.ToInt32(this._LEDColor)])) };
                    pathGradientBrush.SurroundColors = colorArray;
                    e.Graphics.FillEllipse(pathGradientBrush, rectangle3);
                }
            }
            pathGradientBrush.CenterColor = this.color1;
            colorArray = new Color[] { this.color2 };
            pathGradientBrush.SurroundColors = colorArray;
            e.Graphics.FillEllipse(pathGradientBrush, rectangle3);
            if (!string.IsNullOrEmpty(this.Text))
            {
                StringFormat stringFormat = new StringFormat()
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                };
                Graphics graphics = e.Graphics;
                //INSTANT VB NOTE: The variable text was renamed since Visual Basic does not handle local variables named the same as class members well:
                string text_Renamed = this.Text;
                //INSTANT VB NOTE: The variable font was renamed since Visual Basic does not handle local variables named the same as class members well:
                Font       font_Renamed = this.Font;
                SolidBrush solidBrush   = new SolidBrush(this.ForeColor);
                //INSTANT VB TODO TASK: There is no VB equivalent to 'checked' in this context:
                //ORIGINAL LINE: Point point = new Point(checked((int)Math.Round((double)this.Width / 2)), checked((int)Math.Round((double)this.Height / 2)));
                Point point = new Point(Convert.ToInt32(Math.Round((double)this.Width / 2)), Convert.ToInt32(Math.Round((double)this.Height / 2)));
                graphics.DrawString(text_Renamed, font_Renamed, solidBrush, point, stringFormat);
            }
        }
        /// <summary>
        /// Renders the button.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="buttonRectangle">The button rectangle.</param>
        public override void RenderButton(Graphics g, Rectangle buttonRectangle)
        {
            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            g.InterpolationMode = InterpolationMode.HighQualityBilinear;

            g.SetClip(buttonRectangle);

            //Draw button surface
            Color buttonSurfaceColor = ButtonNormalSurfaceColor;

            if (ToggleSwitch.IsButtonPressed)
            {
                buttonSurfaceColor = ButtonPressedSurfaceColor;
            }
            else if (ToggleSwitch.IsButtonHovered)
            {
                buttonSurfaceColor = ButtonHoverSurfaceColor;
            }

            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
            {
                buttonSurfaceColor = buttonSurfaceColor.ToGrayScale();
            }

            using (Brush buttonSurfaceBrush = new SolidBrush(buttonSurfaceColor))
            {
                g.FillEllipse(buttonSurfaceBrush, buttonRectangle);
            }

            //Draw "metal" surface
            PointF centerPoint1 = new PointF(buttonRectangle.X + (buttonRectangle.Width / 2f), buttonRectangle.Y + 1.2f * (buttonRectangle.Height / 2f));

            using (PathGradientBrush firstMetalBrush = GetBrush(new Color[]
            {
                Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent,
                Color.Transparent, Color.Transparent, Color.Transparent, Color.FromArgb(255, 110, 110, 110), Color.Transparent, Color.Transparent,
                Color.Transparent
            }, buttonRectangle, centerPoint1))
            {
                g.FillEllipse(firstMetalBrush, buttonRectangle);
            }

            PointF centerPoint2 = new PointF(buttonRectangle.X + 0.8f * (buttonRectangle.Width / 2f), buttonRectangle.Y + (buttonRectangle.Height / 2f));

            using (PathGradientBrush secondMetalBrush = GetBrush(new Color[]
            {
                Color.FromArgb(255, 110, 110, 110), Color.Transparent, Color.Transparent, Color.Transparent,
                Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent,
                Color.FromArgb(255, 110, 110, 110)
            }, buttonRectangle, centerPoint2))
            {
                g.FillEllipse(secondMetalBrush, buttonRectangle);
            }

            PointF centerPoint3 = new PointF(buttonRectangle.X + 1.2f * (buttonRectangle.Width / 2f), buttonRectangle.Y + (buttonRectangle.Height / 2f));

            using (PathGradientBrush thirdMetalBrush = GetBrush(new Color[]
            {
                Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent,
                Color.FromArgb(255, 98, 98, 98), Color.Transparent, Color.Transparent, Color.Transparent,
                Color.Transparent
            }, buttonRectangle, centerPoint3))
            {
                g.FillEllipse(thirdMetalBrush, buttonRectangle);
            }

            PointF centerPoint4 = new PointF(buttonRectangle.X + 0.9f * (buttonRectangle.Width / 2f), buttonRectangle.Y + 0.9f * (buttonRectangle.Height / 2f));

            using (PathGradientBrush fourthMetalBrush = GetBrush(new Color[]
            {
                Color.Transparent, Color.FromArgb(255, 188, 188, 188), Color.FromArgb(255, 110, 110, 110), Color.Transparent, Color.Transparent, Color.Transparent,
                Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent,
                Color.Transparent
            }, buttonRectangle, centerPoint4))
            {
                g.FillEllipse(fourthMetalBrush, buttonRectangle);
            }

            //Draw button border
            Color buttonBorderColor = ButtonNormalBorderColor;

            if (ToggleSwitch.IsButtonPressed)
            {
                buttonBorderColor = ButtonPressedBorderColor;
            }
            else if (ToggleSwitch.IsButtonHovered)
            {
                buttonBorderColor = ButtonHoverBorderColor;
            }

            if (!ToggleSwitch.Enabled && ToggleSwitch.GrayWhenDisabled)
            {
                buttonBorderColor = buttonBorderColor.ToGrayScale();
            }

            using (Pen buttonBorderPen = new Pen(buttonBorderColor))
            {
                g.DrawEllipse(buttonBorderPen, buttonRectangle);
            }

            g.ResetClip();
        }
        private void RenderItemBackgroundPressed(System.Windows.Forms.ToolStripItemRenderEventArgs e)
        {
            if (Theme.ThemeStyle == RibbonOrbStyle.Office_2013)
            {
                Rectangle rectBorder = new Rectangle(1, 1, e.Item.Width - 1, e.Item.Height - 1);
                Rectangle rect       = new Rectangle(2, 2, e.Item.Width - 2, e.Item.Height - 2);

                using (SolidBrush b = new SolidBrush(Theme.ColorTable.ButtonPressed_2013))
                {
                    using (SolidBrush sb = new SolidBrush(Theme.ColorTable.ButtonBorderOut))
                    {
                        e.Graphics.FillRectangle(sb, rectBorder);
                    }

                    e.Graphics.FillRectangle(b, rect);
                }
            }
            else
            {
                Rectangle rectBorder = new Rectangle(1, 1, e.Item.Width - 1, e.Item.Height - 1);
                Rectangle rect       = new Rectangle(2, 2, e.Item.Width - 2, e.Item.Height - 2);

                Rectangle innerR  = Rectangle.FromLTRB(1, 1, e.Item.Width - 2, e.Item.Height - 2);
                Rectangle glossyR = Rectangle.FromLTRB(1, 1, e.Item.Width - 2, 1 + Convert.ToInt32((double)e.Item.Bounds.Height * .36));

                using (SolidBrush brus = new SolidBrush(Theme.ColorTable.ButtonPressedBgOut))
                {
                    e.Graphics.FillRectangle(brus, rectBorder);
                }

                //Border
                using (Pen p = new Pen(Theme.ColorTable.ButtonPressedBorderOut))
                {
                    e.Graphics.DrawRectangle(p, rectBorder);
                }

                //Inner border
                Rectangle RoundedRect = Rectangle.Round(innerR);
                using (Pen p = new Pen(Theme.ColorTable.ButtonPressedBorderIn))
                {
                    e.Graphics.DrawRectangle(p, RoundedRect);
                }

                #region Main Bg
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddEllipse(new Rectangle(1, 1, e.Item.Width, e.Item.Height * 2));
                    path.CloseFigure();
                    using (PathGradientBrush gradient = new PathGradientBrush(path))
                    {
                        gradient.WrapMode       = WrapMode.Clamp;
                        gradient.CenterPoint    = new PointF(Convert.ToSingle(1 + e.Item.Width / 2), Convert.ToSingle(e.Item.Bounds.Height));
                        gradient.CenterColor    = Theme.ColorTable.ButtonPressedBgCenter;
                        gradient.SurroundColors = new Color[] { Theme.ColorTable.ButtonPressedBgOut };

                        Blend blend = new Blend(3);
                        blend.Factors   = new float[] { 0f, 0.8f, 0f };
                        blend.Positions = new float[] { 0f, 0.30f, 1f };


                        Region lastClip = e.Graphics.Clip;
                        Region newClip  = new Region(rectBorder);
                        newClip.Intersect(lastClip);
                        e.Graphics.SetClip(newClip.GetBounds(e.Graphics));
                        e.Graphics.FillPath(gradient, path);
                        e.Graphics.Clip = lastClip;
                    }
                }
                #endregion

                //Glossy effect
                using (GraphicsPath path = new GraphicsPath())
                {
                    path.AddRectangle(Rectangle.Round(glossyR));
                    using (LinearGradientBrush b = new LinearGradientBrush(glossyR, Theme.ColorTable.ButtonPressedGlossyNorth, Theme.ColorTable.ButtonPressedGlossySouth, 90))
                    {
                        b.WrapMode = WrapMode.TileFlipXY;
                        e.Graphics.FillPath(b, path);
                    }
                }
            }
        }
예제 #20
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            //获得Graphics对象
            Graphics g = e.Graphics;

            //图像呈现质量为消除锯齿
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //使用SolidBrush将窗体涂为白色
            g.FillRectangle(new SolidBrush(Color.White), this.ClientRectangle);

            //创建一个包含单个椭圆路径的path对象
            GraphicsPath path = new GraphicsPath();

            path.AddEllipse(250, 100, 200, 100);
            //path.AddEllipse(100, 100, 280, 140);

            // 使用这个Path对象创建一个渐变路径画笔.
            PathGradientBrush pBrush = new PathGradientBrush(path);

            // 将path对象的中心颜色设为蓝色
            pBrush.CenterColor = Color.Blue;

            // 将环绕在path对象边界上的颜色设为Aqua
            Color[] colors = { Color.Aqua };
            pBrush.SurroundColors = colors;

            //绘制椭圆
            g.FillEllipse(pBrush, 250, 100, 200, 100);

            GraphicsPath path1 = new GraphicsPath();

            //设置五角星的每点的坐标数组
            Point[] points =
            {
                new Point(125,  75),
                new Point(150, 125),
                new Point(200, 125),
                new Point(162, 150),
                new Point(200, 225),
                new Point(125, 175),
                new Point(50,  225),
                new Point(87,  150),
                new Point(50,  125),
                new Point(100, 125)
            };

            path1.AddLines(points);
            PathGradientBrush pBrush1 = new PathGradientBrush(path1);

            //构造ColorBlend对象,用于多色渐变
            ColorBlend colorBlend = new ColorBlend();

            //定义三种颜色的多色渐变
            colorBlend.Colors = new Color[]
            {
                Color.Blue, Color.Aqua, Color.Green
            };

            //定义每一种颜色的位置
            colorBlend.Positions = new float[]
            {
                0.0f, 0.4f, 1.0f
            };

            //把colorBlend对象赋给刷子的InterpolationColor属性
            pBrush1.InterpolationColors = colorBlend;

            //绘制五角星
            g.FillRectangle(pBrush1, new Rectangle(0, 0, 200, 225));
        }
예제 #21
0
        private void drawFancyRectangle(float x1, float y1, float width, float height, Pen boxpen, bool surpressShadow)
        {
            // based on code by
            // found on https://secure.codeproject.com/cs/media/FuzzyDropShadows.asp

            const float fudge           = 7F;
            float       _ShadowDistance = -7f;

            x1 += fudge;

            graphics.SmoothingMode = SmoothingMode.AntiAlias;             // clean lines - set the smoothingmode to Anti-Alias
            Rectangle _Rectangle = new Rectangle((int)x1, (int)y1, (int)width, (int)height);
            // float _Radius = (int)(_Rectangle.Height * .2);
            float _Radius = 5;              // set non proportional

            // create an x and y variable so that we can reduce the length of our code lines
            float X = _Rectangle.Left;
            float Y = _Rectangle.Top + fudge;            // fudge factor

            // make sure that we have a valid radius, too small and we have a problem
            if (_Radius < 1)
            {
                _Radius = 1;
            }

            try
            {
                // Create a graphicspath object with the using operator so the framework
                // can clean up the resources for us
                using (GraphicsPath _Path = new GraphicsPath())
                {
                    // build the rounded rectangle starting at the top line and going around
                    // until the line meets itself again
                    _Path.AddLine(X + _Radius, Y, X + _Rectangle.Width - (_Radius * 2), Y);
                    _Path.AddArc(X + _Rectangle.Width - (_Radius * 2), Y, _Radius * 2, _Radius * 2, 270, 90);
                    _Path.AddLine(X + _Rectangle.Width, Y + _Radius, X + _Rectangle.Width, Y + _Rectangle.Height - (_Radius * 2));
                    _Path.AddArc(X + _Rectangle.Width - (_Radius * 2), Y + _Rectangle.Height - (_Radius * 2), _Radius * 2, _Radius * 2, 0, 90);
                    _Path.AddLine(X + _Rectangle.Width - (_Radius * 2), Y + _Rectangle.Height, X + _Radius, Y + _Rectangle.Height);
                    _Path.AddArc(X, Y + _Rectangle.Height - (_Radius * 2), _Radius * 2, _Radius * 2, 90, 90);
                    _Path.AddLine(X, Y + _Rectangle.Height - (_Radius * 2), X, Y + _Radius);
                    _Path.AddArc(X, Y, _Radius * 2, _Radius * 2, 180, 90);

                    // this is where we create the shadow effect, so we will use a
                    // pathgradientbursh
                    using (PathGradientBrush _Brush = new PathGradientBrush(_Path))
                    {
                        // set the wrapmode so that the colours will layer themselves
                        // from the outer edge in
                        _Brush.WrapMode = WrapMode.Clamp;

                        // Create a color blend to manage our colors and positions and
                        // since we need 3 colors set the default length to 3
                        ColorBlend _ColorBlend = new ColorBlend(3);

                        // here is the important part of the shadow making process, remember
                        // the clamp mode on the colorblend object layers the colors from
                        // the outside to the center so we want our transparent color first
                        // followed by the actual shadow color. Set the shadow color to a
                        // slightly transparent DimGray, I find that it works best.
                        _ColorBlend.Colors = new Color[] { Color.Transparent,
                                                           Color.FromArgb(180, Color.DimGray),
                                                           Color.FromArgb(180, Color.DimGray) };

                        // our color blend will control the distance of each color layer
                        // we want to set our transparent color to 0 indicating that the
                        // transparent color should be the outer most color drawn, then
                        // our Dimgray color at about 10% of the distance from the edge
                        _ColorBlend.Positions = new float[] { 0f, .1f, 1f };

                        // assign the color blend to the pathgradientbrush
                        _Brush.InterpolationColors = _ColorBlend;

                        // fill the shadow with our pathgradientbrush
                        if (this.dropShadow & !surpressShadow)
                        {
                            graphics.FillPath(_Brush, _Path);
                        }
                    }

                    // since the shadow was drawm first we need to move the actual path
                    // up and back a little so that we can show the shadow underneath
                    // the object. To accomplish this we will create a Matrix Object
                    Matrix _Matrix = new Matrix();

                    // tell the matrix to move the path up and back the designated distance
                    _Matrix.Translate(_ShadowDistance, _ShadowDistance);

                    // assign the matrix to the graphics path of the rounded rectangle
                    _Path.Transform(_Matrix);

                    // get or calculate gradient colours
                    Color sc = boxpen.Color;
                    // Color sc = Color.Tomato;  // end colour was Color.MistyRose

                    // fill the graphics path first
                    using (LinearGradientBrush _Brush = new LinearGradientBrush(
                               new Rectangle((int)X, (int)(Y - fudge), (int)width, (int)(height + fudge)),
                               sc, Color.WhiteSmoke, LinearGradientMode.Vertical))
                    {
                        graphics.FillPath(_Brush, _Path);
                    }

                    // Draw the Graphicspath last so that we have cleaner borders
                    // using(Pen _Pen = new Pen(Color.DimGray, 1f))
                    {
                        graphics.DrawPath(boxpen, _Path);
                    }
                }
                graphics.SmoothingMode = SmoothingMode.None;                  // Does not affect the result adversly
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(GetType().Name + ".DrawRndRect() Error: " + ex.Message);
            }
        }
예제 #22
0
 //----------------------------------------------------------------------
 public static void Tracker(Graphics g, RectangleF aTrackerRect, Color innerColor, Color outerColor)
 {
     Color[] colorArray;
     using (GraphicsPath path = new GraphicsPath())
     {
         path.AddEllipse(aTrackerRect);
         using (PathGradientBrush brush = new PathGradientBrush(path))
         {
             brush.CenterColor    = innerColor;
             colorArray           = new Color[] { outerColor };
             brush.SurroundColors = colorArray;
             colorArray           = new Color[] { brush.CenterColor };
             brush.SurroundColors = colorArray;
             g.FillEllipse(new SolidBrush(brush.SurroundColors[0]), aTrackerRect);
             g.FillPath(brush, path);
         }
     }
     using (GraphicsPath path2 = new GraphicsPath())
     {
         RectangleF rect = new RectangleF(aTrackerRect.Width * 0.1f, aTrackerRect.Height * 0.05f, aTrackerRect.Width * 0.8f, aTrackerRect.Height * 0.9f);
         path2.AddEllipse(aTrackerRect);
         rect.Offset(aTrackerRect.Location);
         path2.AddEllipse(rect);
         using (PathGradientBrush brush2 = new PathGradientBrush(path2))
         {
             brush2.CenterColor    = Color.FromArgb(200, Color.White);
             colorArray            = new Color[] { Color.FromArgb(0, Color.White) };
             brush2.SurroundColors = colorArray;
             g.FillPath(brush2, path2);
         }
     }
     using (GraphicsPath path3 = new GraphicsPath())
     {
         RectangleF ef2 = new RectangleF(0f, aTrackerRect.Height * 0.33f, aTrackerRect.Width, aTrackerRect.Height);
         ef2.Offset(aTrackerRect.Location);
         path3.AddEllipse(ef2);
         using (Region region = new Region(path3))
         {
             using (GraphicsPath path4 = new GraphicsPath())
             {
                 path4.AddEllipse(aTrackerRect);
                 region.Complement(path4);
                 using (SolidBrush brush3 = new SolidBrush(Color.FromArgb(30, Color.White)))
                 {
                     g.FillRegion(brush3, region);
                 }
             }
         }
     }
     using (GraphicsPath path5 = new GraphicsPath())
     {
         RectangleF ef3 = new RectangleF(0f, 0f, aTrackerRect.Width * 0.56f, aTrackerRect.Height * 0.248f);
         ef3.Offset((aTrackerRect.Width / 2f) - (ef3.Width / 2f), aTrackerRect.Height * 0.04f);
         ef3.Offset(aTrackerRect.Location);
         path5.AddEllipse(ef3);
         using (LinearGradientBrush brush4 = new LinearGradientBrush(path5.GetBounds(), Color.FromArgb(200, Color.White), Color.FromArgb(0, Color.White), LinearGradientMode.Vertical))
         {
             g.FillPath(brush4, path5);
         }
     }
     using (GraphicsPath path6 = new GraphicsPath())
     {
         RectangleF ef4 = new RectangleF(0f, 0f, aTrackerRect.Width * 0.3f, aTrackerRect.Height * 0.15f);
         ef4.Offset((aTrackerRect.Width / 2f) - (ef4.Width / 2f), (aTrackerRect.Height - ef4.Height) - (aTrackerRect.Height * 0.03f));
         ef4.Offset(aTrackerRect.Location);
         path6.AddEllipse(ef4);
         using (LinearGradientBrush brush5 = new LinearGradientBrush(path6.GetBounds(), Color.FromArgb(0, Color.White), Color.FromArgb(100, Color.White), LinearGradientMode.Vertical))
         {
             g.FillPath(brush5, path6);
         }
     }
 }
예제 #23
0
        private void Form9_Paint(object sender, PaintEventArgs e)
        {
            //1
            Graphics     g            = e.Graphics;
            Rectangle    rectangle    = new Rectangle(20, 20, 240, 240);
            GraphicsPath graphicsPath = new GraphicsPath();

            graphicsPath.AddEllipse(rectangle);
            g.FillEllipse(Brushes.White, rectangle);

            PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath);

            pathGradientBrush.CenterColor    = Color.White;
            pathGradientBrush.SurroundColors = new Color[]
            {
                Color.Red
            };
            g.FillPath(pathGradientBrush, graphicsPath);

            graphicsPath.Dispose();
            pathGradientBrush.Dispose();


            //2

            Rectangle    rectangle1    = new Rectangle(300, 20, 240, 240);
            GraphicsPath graphicsPath1 = new GraphicsPath();

            graphicsPath1.AddEllipse(rectangle1);

            PathGradientBrush pathGradientBrush1 = new PathGradientBrush(graphicsPath1);
            //pathGradientBrush1.CenterColor = Color.White;
            float x = pathGradientBrush1.CenterPoint.X;
            float y = pathGradientBrush1.CenterPoint.Y;

            pathGradientBrush1.SurroundColors = new Color[]
            {
                // Color.Red,
                Color.Green,

                //Color.Gray,Color.Azure
            };

            g.FillPath(pathGradientBrush1, graphicsPath1);

            graphicsPath1.Dispose();
            pathGradientBrush1.Dispose();


            Rectangle rectangle2 = new Rectangle(Convert.ToInt32(x) - 80 - 8, Convert.ToInt32(y) - 80, 160, 160);

            g.FillEllipse(Brushes.White, rectangle2);



            Rectangle    rectangle3    = new Rectangle(Convert.ToInt32(x) - 40 - 8, Convert.ToInt32(y) - 40, 80, 80);
            GraphicsPath graphicsPath3 = new GraphicsPath();

            graphicsPath3.AddEllipse(rectangle3);

            PathGradientBrush pathGradientBrush3 = new PathGradientBrush(graphicsPath3);


            pathGradientBrush3.SurroundColors = new Color[]
            {
                Color.Red,
                //Color.Green,

                //Color.Gray,Color.Azure
            };

            g.FillPath(pathGradientBrush3, graphicsPath3);

            graphicsPath3.Dispose();
            pathGradientBrush3.Dispose();
        }
        /// <summary>
        /// Draws object on the board(graphObj)
        /// </summary>
        /// <param name="graphObj">Graph Object(board) to drawn on</param>
        /// <param name="dx">X region on board</param>
        /// <param name="dy">Y region on board</param>
        /// <param name="zoom">Zoom value</param>
        public override void Draw(Graphics graphObj, int dx, int dy, float zoom)
        {
            //myBrush.Color = this.Trasparency(this.fillColor, this.alpha);
            Pen myPen = this.CreatePen(zoom);

            // Create a path and add the object.
            GraphicsPath myPath = new GraphicsPath();

            // To ARRAY
            PointF[] myArr      = new PointF[this.points.Count];
            Color[]  myColorArr = new Color[this.points.Count];
            int      i          = 0;

            foreach (PointElement point in this.points)
            {
                myArr[i] = new PointF((point.X + region.X0 + dx) * zoom,
                                      (point.Y + region.Y0 + dy) * zoom);
                if (point is ColoredPoint)
                {
                    myColorArr[i++] = ((ColoredPoint)point).Color;
                }
            }
            if (myArr.Length < 3 | !this.curved)
            {
                if (closed & myArr.Length >= 3)
                {
                    myPath.AddPolygon(myArr);
                }
                else
                {
                    myPath.AddLines(myArr);
                }
            }
            else
            {
                if (closed)
                {
                    myPath.AddClosedCurve(myArr);
                }
                else
                {
                    myPath.AddCurve(myArr);
                }
            }
            PathGradientBrush myBrush = new PathGradientBrush(myPath);

            myBrush.SurroundColors = myColorArr;
            myBrush.CenterColor    = this.FillColor;

            Matrix translateMatrix = new Matrix();

            translateMatrix.RotateAt(this.Rotation, region.GetActualregion(dx, dy, zoom));
            myPath.Transform(translateMatrix);

            // Draw the transformed obj to the screen.
            graphObj.FillPath(myBrush, myPath);
            if (this.ShowBorder)
            {
                graphObj.DrawPath(myPen, myPath);
            }

            myPath.Dispose();
            myPen.Dispose();
            if (myBrush != null)
            {
                myBrush.Dispose();
            }
        }
예제 #25
0
파일: ToolTip.cs 프로젝트: orf53975/src
 private void drawBackground(Graphics g)
 {
     if (!mPopup._ownerDrawBackground)
     {
         if (mPopup._showShadow)
         {
             System.Drawing.Drawing2D.LinearGradientBrush bgBrush;
             GraphicsPath      aPath;
             Rectangle         aRect       = new Rectangle(0, 0, this.Width - 4, this.Height - 4);
             Rectangle         rectShadow  = new Rectangle(4, 4, this.Width - 4, this.Height - 4);
             GraphicsPath      pathShadow  = Ai.Renderer.Drawing.roundedRectangle(rectShadow, 4, 4, 4, 4);
             PathGradientBrush shadowBrush = new PathGradientBrush(pathShadow);
             Color[]           sColor      = new Color[4];
             float[]           sPos        = new float[4];
             ColorBlend        sBlend      = new ColorBlend();
             sColor[0] = Color.FromArgb(0, 0, 0, 0);
             sColor[1] = Color.FromArgb(16, 0, 0, 0);
             sColor[2] = Color.FromArgb(32, 0, 0, 0);
             sColor[3] = Color.FromArgb(128, 0, 0, 0);
             if (rectShadow.Width > rectShadow.Height)
             {
                 sPos[0] = 0.0F;
                 sPos[1] = 4 / rectShadow.Width;
                 sPos[2] = 8 / rectShadow.Width;
                 sPos[3] = 1.0F;
             }
             else
             {
                 if (rectShadow.Width < rectShadow.Height)
                 {
                     sPos[0] = 0.0F;
                     sPos[1] = 4 / rectShadow.Height;
                     sPos[2] = 8 / rectShadow.Height;
                     sPos[3] = 1.0F;
                 }
                 else
                 {
                     sPos[0] = 0.0F;
                     sPos[1] = 4 / rectShadow.Width;
                     sPos[2] = 8 / rectShadow.Width;
                     sPos[3] = 1.0F;
                 }
             }
             sBlend.Colors    = sColor;
             sBlend.Positions = sPos;
             shadowBrush.InterpolationColors = sBlend;
             if (rectShadow.Width > rectShadow.Height)
             {
                 shadowBrush.CenterPoint = new Point(
                     rectShadow.X + (rectShadow.Width / 2),
                     rectShadow.Bottom - (rectShadow.Width / 2));
             }
             else
             {
                 if (rectShadow.Width == rectShadow.Height)
                 {
                     shadowBrush.CenterPoint = new Point(
                         rectShadow.X + (rectShadow.Width / 2),
                         rectShadow.Y + (rectShadow.Height / 2));
                 }
                 else
                 {
                     shadowBrush.CenterPoint = new Point(
                         rectShadow.Right - (rectShadow.Height / 2),
                         rectShadow.Y + (rectShadow.Height / 2));
                 }
             }
             aPath   = Ai.Renderer.Drawing.roundedRectangle(aRect, 2, 2, 2, 2);
             bgBrush = new System.Drawing.Drawing2D.LinearGradientBrush(aRect,
                                                                        Color.FromArgb(255, 255, 255), Color.FromArgb(201, 217, 239), System.Drawing.Drawing2D.LinearGradientMode.Vertical);
             g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
             g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
             g.Clear(Color.Transparent);
             g.FillPath(shadowBrush, pathShadow);
             g.FillPath(bgBrush, aPath);
             g.DrawPath(new Pen(Color.FromArgb(118, 118, 118)), aPath);
             bgBrush.Dispose();
             aPath.Dispose();
             pathShadow.Dispose();
             shadowBrush.Dispose();
         }
         else
         {
             System.Drawing.Drawing2D.LinearGradientBrush bgBrush;
             GraphicsPath aPath;
             Rectangle    aRect = new Rectangle(0, 0, this.Width, this.Height);
             aPath   = Ai.Renderer.Drawing.roundedRectangle(aRect, 2, 2, 2, 2);
             bgBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height),
                                                                        Color.FromArgb(255, 255, 255), Color.FromArgb(201, 217, 239), System.Drawing.Drawing2D.LinearGradientMode.Vertical);
             g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
             g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
             g.Clear(Color.Transparent);
             g.FillPath(bgBrush, aPath);
             g.DrawPath(new Pen(Color.FromArgb(118, 118, 118)), aPath);
             bgBrush.Dispose();
             aPath.Dispose();
         }
     }
     else
     {
         g.Clear(Color.Transparent);
         mPopup.invokeDrawBackground(g, new Rectangle(0, 0, this.Width - 1, this.Height - 1));
     }
 }
예제 #26
0
        private unsafe static void CreateLights()
        {
            for (int i = Lights.Count - 1; i >= 0; i--)
            {
                Lights[i].Dispose();
            }

            Lights.Clear();

            for (int i = 1; i < LightSizes.Length; i++)
            {
                // int width = 125 + (57 *i);
                //int height = 110 + (57 * i);
                int width  = LightSizes[i].X;
                int height = LightSizes[i].Y;

                Texture light = new Texture(Device, width, height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);

                DataRectangle stream = light.LockRectangle(0, LockFlags.Discard);
                using (Bitmap image = new Bitmap(width, height, width * 4, PixelFormat.Format32bppArgb, stream.Data.DataPointer))
                {
                    using (Graphics graphics = Graphics.FromImage(image))
                    {
                        using (GraphicsPath path = new GraphicsPath())
                        {
                            //path.AddEllipse(new Rectangle(0, 0, width, height));
                            //using (PathGradientBrush brush = new PathGradientBrush(path))
                            //{
                            //    graphics.Clear(Color.FromArgb(0, 0, 0, 0));
                            //    brush.SurroundColors = new[] { Color.FromArgb(0, 255, 255, 255) };
                            //    brush.CenterColor = Color.FromArgb(255, 255, 255, 255);
                            //    graphics.FillPath(brush, path);
                            //    graphics.Save();
                            //}

                            path.AddEllipse(new Rectangle(0, 0, width, height));
                            using (PathGradientBrush brush = new PathGradientBrush(path))
                            {
                                Color[] blendColours = { Color.White,
                                                         Color.FromArgb(255, 150, 150, 150),
                                                         Color.FromArgb(255,  60,  60,  60),
                                                         Color.FromArgb(255,  30,  30,  30),
                                                         Color.FromArgb(255,  10,  10,  10),
                                                         Color.FromArgb(0,     0,   0, 0) };

                                float[] radiusPositions = { 0f, .20f, .40f, .60f, .80f, 1.0f };

                                ColorBlend colourBlend = new ColorBlend();
                                colourBlend.Colors    = blendColours;
                                colourBlend.Positions = radiusPositions;

                                graphics.Clear(Color.FromArgb(0, 0, 0, 0));
                                brush.InterpolationColors = colourBlend;
                                brush.SurroundColors      = blendColours;
                                brush.CenterColor         = Color.White;
                                graphics.FillPath(brush, path);
                                graphics.Save();
                            }
                        }
                    }
                }
                //light.Disposing += (o, e) => Lights.Remove(light);
                Lights.Add(light);
            }
        }
예제 #27
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            //g.Clear(Parent.BackColor);
            //Color clr = BackColor;

            switch (mouseAction)
            {
            case MouseActionType.Click:
                shadowOffset = 4;
                //clr = Color.Gold;
                btnOffset = 2;
                break;

            case MouseActionType.Hover:
                //clr = Color.Gold;
                break;
            }
            g.SmoothingMode = SmoothingMode.HighQuality;

            ///
            /// Create main colored shape
            ///
            Rectangle           rc    = new Rectangle(btnOffset, btnOffset, this.ClientSize.Width - 8 - btnOffset, this.ClientSize.Height - 8 - btnOffset);
            GraphicsPath        path1 = this.GetPath(rc, 20);
            LinearGradientBrush br1   = new LinearGradientBrush(new Point(0, 0), new Point(0, rc.Height + 6), color1, color2);

            ///
            /// Create shadow
            ///
            if (addShadow == true)
            {
                Rectangle rc2 = rc;
                rc2.Offset(shadowOffset, shadowOffset);
                GraphicsPath      path2 = this.GetPath(rc2, 20);
                PathGradientBrush br2   = new PathGradientBrush(path2);
                br2.CenterColor    = ControlPaint.DarkDark(Color.Silver);
                br2.SurroundColors = new Color[] { Color.Transparent };

                g.FillPath(br2, path2); //draw shadow

                ///
                ///Set the region for the button
                Region rgn = new Region(path1);
                rgn.Union(path2);
                this.Region = rgn;
            }


            ///
            /// Create top water color to give "aqua" effect
            ///
            Rectangle rc3 = rc;

            rc3.Inflate(-5, -5);
            rc3.Height = 15;
            GraphicsPath        path3 = GetPath(rc3, 20);
            LinearGradientBrush br3   = new LinearGradientBrush(rc3, Color.FromArgb(255, gradientColor), Color.FromArgb(0, gradientColor), gradientMode);

            ///
            ///draw shapes
            ///

            g.FillPath(br1, path1); //draw main
            g.FillPath(br3, path3); //draw top bubble

            ///
            ///Create a backup of the button image to a bitmap so we can manipulate it's pulsing action
            ///
            buttonBitmapRectangle = new Rectangle(rc.Location, rc.Size);
            buttonBitmap          = new Bitmap(buttonBitmapRectangle.Width, buttonBitmapRectangle.Height);
            Graphics g_bmp = Graphics.FromImage(buttonBitmap);

            g_bmp.SmoothingMode = SmoothingMode.HighQuality;
            g_bmp.FillPath(br1, path1);
            g_bmp.FillPath(br3, path3);



            ///
            /// Create a Path to draw the text to give the button a nice outline
            ///
            GraphicsPath path4 = new GraphicsPath();

            RectangleF path1bounds = path1.GetBounds();
            Rectangle  rcText      = new Rectangle((int)path1bounds.X, (int)path1bounds.Y, (int)path1bounds.Width, (int)path1bounds.Height);

            StringFormat strformat = new StringFormat();

            strformat.Alignment     = StringAlignment.Center;
            strformat.LineAlignment = StringAlignment.Center;
            path4.AddString(this.Text, this.Font.FontFamily, (int)this.Font.Style, this.Font.Size,
                            rcText, strformat);

            Pen txtPen = new Pen(this.ForeColor, 1);

            g.DrawPath(txtPen, path4);
            g_bmp.DrawPath(txtPen, path4);
        }
예제 #28
0
        public static Bitmap DrawShadowBitmap(int width, int height, int borderRadius, int blur, int spread, Color color)
        {
            int ex     = blur + spread;
            int w      = width + ex * 2;
            int h      = height + ex * 2;
            int solidW = width + spread * 2;
            int solidH = height + spread * 2;

            var      bitmap = new Bitmap(w, h);
            Graphics g      = Graphics.FromImage(bitmap);

            // fill background
            g.FillRectangle(new SolidBrush(color)
                            , blur, blur, width + spread * 2 + 1, height + spread * 2 + 1);
            // +1 to fill the gap

            if (blur > 0)
            {
                // four dir gradiant
                {
                    // left
                    var brush = new LinearGradientBrush(new Point(0, 0), new Point(blur, 0), Color.Transparent, color);
                    // will thorw ArgumentException
                    // brush.WrapMode = WrapMode.Clamp;


                    g.FillRectangle(brush, 0, blur, blur, solidH);
                    // up
                    brush.RotateTransform(90);
                    g.FillRectangle(brush, blur, 0, solidW, blur);

                    // right
                    // make sure parttern is currect
                    brush.ResetTransform();
                    brush.TranslateTransform(w % blur, h % blur);

                    brush.RotateTransform(180);
                    g.FillRectangle(brush, w - blur, blur, blur, solidH);
                    // down
                    brush.RotateTransform(90);
                    g.FillRectangle(brush, blur, h - blur, solidW, blur);
                }


                // four corner
                {
                    var gp = new GraphicsPath();
                    //gp.AddPie(0,0,blur*2,blur*2, 180, 90);
                    gp.AddEllipse(0, 0, blur * 2, blur * 2);


                    var pgb = new PathGradientBrush(gp);
                    pgb.CenterColor    = color;
                    pgb.SurroundColors = new[] { Color.Transparent };
                    pgb.CenterPoint    = new Point(blur, blur);

                    // lt
                    g.FillPie(pgb, 0, 0, blur * 2, blur * 2, 180, 90);
                    // rt
                    var matrix = new Matrix();
                    matrix.Translate(w - blur * 2, 0);

                    pgb.Transform = matrix;
                    //pgb.Transform.Translate(w-blur*2, 0);
                    g.FillPie(pgb, w - blur * 2, 0, blur * 2, blur * 2, 270, 90);
                    // rb
                    matrix.Translate(0, h - blur * 2);
                    pgb.Transform = matrix;
                    g.FillPie(pgb, w - blur * 2, h - blur * 2, blur * 2, blur * 2, 0, 90);
                    // lb
                    matrix.Reset();
                    matrix.Translate(0, h - blur * 2);
                    pgb.Transform = matrix;
                    g.FillPie(pgb, 0, h - blur * 2, blur * 2, blur * 2, 90, 90);
                }
            }

            //
            return(bitmap);
        }
예제 #29
0
 public void Transform_NonInvertible()
 {
     using (PathGradientBrush pgb = new PathGradientBrush(pts_2f, WrapMode.Clamp)) {
         Assert.Throws <ArgumentException> (() => pgb.Transform = new Matrix(123, 24, 82, 16, 47, 30));
     }
 }
예제 #30
0
 private void DrawButtonBackground(Graphics g, float glowOpacity)
 {
     #region " white border "
     Rectangle rect = ClientRectangle;
     rect.Width--;
     rect.Height--;
     using (GraphicsPath bw = CreateRoundRectangle(rect, 4))
     {
         using (Pen p = new Pen(outerBorderColor))
         {
             g.DrawPath(p, bw);
         }
     }
     #endregion
     rect.X++;
     rect.Y++;
     rect.Width  -= 2;
     rect.Height -= 2;
     Rectangle rect2 = rect;
     rect2.Height >>= 1;
     #region " content "
     using (GraphicsPath bb = CreateRoundRectangle(rect, 4))
     {
         int opacity = isPressed ? 0xcc : 0x7f;
         using (Brush br = new SolidBrush(Color.FromArgb(opacity, backColor)))
         {
             g.FillPath(br, bb);
         }
     }
     #endregion
     #region " glow "
     if ((isHovered || isAnimating) && !isPressed)
     {
         using (GraphicsPath clip = CreateRoundRectangle(rect, 4))
         {
             g.SetClip(clip, CombineMode.Intersect);
             using (GraphicsPath brad = CreateBottomRadialPath(rect))
             {
                 using (PathGradientBrush pgr = new PathGradientBrush(brad))
                 {
                     unchecked
                     {
                         int opacity = (int)(0xB2 * glowOpacity + .5f);
                         pgr.CenterColor    = Color.FromArgb(opacity, glowColor);
                         pgr.SurroundColors = new Color[] { Color.FromArgb(0, glowColor) };
                     }
                     g.FillPath(pgr, brad);
                 }
             }
             g.ResetClip();
         }
     }
     #endregion
     #region " shine "
     if (rect2.Width > 0 && rect2.Height > 0)
     {
         rect2.Height++;
         using (GraphicsPath bh = CreateTopRoundRectangle(rect2, 4))
         {
             rect2.Height++;
             int opacity = 0x99;
             if (isPressed)
             {
                 opacity = (int)(.4f * opacity + .5f);
             }
             using (LinearGradientBrush br = new LinearGradientBrush(rect2, Color.FromArgb(opacity, shineColor), Color.FromArgb(opacity / 3, shineColor), LinearGradientMode.Vertical))
             {
                 g.FillPath(br, bh);
             }
         }
         rect2.Height -= 2;
     }
     #endregion
     #region " black border "
     using (GraphicsPath bb = CreateRoundRectangle(rect, 4))
     {
         using (Pen p = new Pen(innerBorderColor))
         {
             g.DrawPath(p, bb);
         }
     }
     #endregion
 }
예제 #31
0
    private void CreateGradient()
    {
        // Create a new PathGradientBrush, supplying
        // an array of points created by calling
        // the GetPoints method.
        using (PathGradientBrush pgb =
            new PathGradientBrush(GetPoints(radius, new Point(radius, radius))))
        {
            // Set the various properties. Note the SurroundColors
            // property, which contains an array of points,
            // in a one-to-one relationship with the points
            // that created the gradient.
            pgb.CenterColor = Color.White;
            pgb.CenterPoint = new PointF(radius, radius);
            pgb.SurroundColors = GetColors();

            // Create a new bitmap containing
            // the color wheel gradient, so the
            // code only needs to do all this
            // work once. Later code uses the bitmap
            // rather than recreating the gradient.
            colorImage = new Bitmap(
                colorRectangle.Width, colorRectangle.Height,
                PixelFormat.Format32bppArgb);

            using (Graphics newGraphics =
                             Graphics.FromImage(colorImage))
            {
                newGraphics.FillEllipse(pgb, 0, 0,
                    colorRectangle.Width, colorRectangle.Height);
            }
        }
    }
예제 #32
0
        int deltaHeight = 0;  // изменение по высоте
        /// <summary>
        /// Рисование графики в графическом контексте.
        /// </summary>
        /// <param name="g">graphics окна вывода</param>
        public void Draw(Graphics g)
        {
            g.FillRectangle(BrushCell(), CellCoordinate.X + 1,
                            CellCoordinate.Y + 1, CellCoordinate.Width - 1, CellCoordinate.Height - 1);

            // При невидимой геометрической фигуре прорисовывается только квадрат ячейки.
            if (visible == false)
            {
                return;
            }

            // Вспомогательный квадрат для эффекта исчезания и эффекта
            // активности в выбранном состоянии.
            Rectangle rectInflate = CellCoordinate;

            rectInflate.Inflate(deltaWidth, deltaHeight);


            // ---------- Формирование геометрической фигуры внутри ячейки -------------------

            // Подготовка координат для прорисовки ромба
            Point point1 = new Point(CellCoordinate.Left + CellCoordinate.Width / 2, rectInflate.Top);
            Point point2 = new Point(rectInflate.Left + rectInflate.Width, CellCoordinate.Top + CellCoordinate.Height / 2);
            Point point3 = new Point(CellCoordinate.Left + CellCoordinate.Width / 2, rectInflate.Top + rectInflate.Height);
            Point point4 = new Point(rectInflate.Left, CellCoordinate.Top + CellCoordinate.Height / 2);

            Point[] pt = { point1, point2, point3, point4 };

            // Выбор вида графической фигуры.
            GraphicsPath gp = new GraphicsPath();

            switch (CurrentTypeGraphItem)
            {
            case TypeGraphItem.tEllipse:
                gp.AddEllipse(rectInflate);
                break;

            case TypeGraphItem.tRectangle:
                gp.AddRectangle(rectInflate);
                break;

            case TypeGraphItem.tRhombus:
                gp.AddPolygon(pt);
                break;
            }

            // При минимальном размере окна могут возникать
            // при исчезании фигур отрицательные значения ширины и высоты.
            // Для предотвращения сбоев предназначена эта строка.
            if (rectInflate.Width < 0 || rectInflate.Height < 0)
            {
                return;
            }


            // Раскраска геометрической фигуры.
            PathGradientBrush pathBrush = new PathGradientBrush(gp);

            pathBrush.SurroundColors = new Color[] { this.Color };
            pathBrush.CenterPoint    = new PointF(CellCoordinate.Left + CellCoordinate.Width / 2, CellCoordinate.Top + CellCoordinate.Height / 2);
            pathBrush.CenterColor    = Color.White;



            // Рисование текущей геометрической фигуры.
            switch (CurrentTypeGraphItem)
            {
            case TypeGraphItem.tEllipse:
                g.FillEllipse(pathBrush, rectInflate);
                break;

            case TypeGraphItem.tRectangle:
                g.FillRectangle(pathBrush, rectInflate);
                break;

            case TypeGraphItem.tRhombus:
                g.FillPolygon(pathBrush, pt);
                break;
            }
        }
예제 #33
0
        /// <summary>
        /// Draws an elliptical style of gradient in the specified region passed to the function.  The ellipitical gradient will be drawn using the
        /// starting and ending colors specified in the function's parameters.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="gradColor1"></param>
        /// <param name="gradColor2"></param>
        /// <param name="oOutputData"></param>
        /// <param name="blDrawCircle"></param>
        public static void DrawEllipsisGradient(Graphics graphics, Color gradColor1, Color gradColor2, object oOutputData, bool blDrawCircle = false)
        {
            GraphicsPath      pathEllipse   = null;
            PathGradientBrush pathGradBrush = null;

            try
            {
                RectangleF   rectBounds;
                GraphicsPath pathOutput = null;

                GetOutputDataObjects(oOutputData, out rectBounds, out pathOutput);

                SizeF szEllipse;

                //The largest dimension of the specified region will be used to determine the diameter of the circle to draw.
                float fCircLen;

                if (blDrawCircle)
                {
                    if (rectBounds.Width > rectBounds.Height)
                    {
                        fCircLen = rectBounds.Width;
                    }
                    else
                    {
                        fCircLen = rectBounds.Height;
                    }

                    szEllipse = new SizeF(fCircLen * 1.5f, fCircLen * 1.5f);
                }
                else
                {
                    szEllipse = new SizeF(rectBounds.Width * 2, rectBounds.Height * 2);
                }//end if


                // Create a path that consists of a single ellipse.
                pathEllipse = new GraphicsPath();
                pathEllipse.AddEllipse(0, 0, szEllipse.Width, szEllipse.Height);

                // Use the path to construct a brush.
                pathGradBrush = new PathGradientBrush(pathEllipse);

                // Set the color at the center of the path to first gradient color.
                pathGradBrush.CenterColor = gradColor1;

                // Set the color along the entire boundary of the path to second gradient color.
                Color[] colors = { gradColor2 };
                pathGradBrush.SurroundColors = colors;

                if (pathOutput == null)
                {
                    Bitmap   bmpMemory = new Bitmap(Convert.ToInt32(szEllipse.Width), Convert.ToInt32(szEllipse.Height));
                    Graphics gMemory   = Graphics.FromImage(bmpMemory);

                    //Draws the ellipitical gradient in a expanded region in memory, so that the desired region of the ellipsis gradient can be
                    //rendered onto the device context (paintable surface/display) of the control's UI.
                    gMemory.FillEllipse(pathGradBrush, 0, 0, bmpMemory.Width, bmpMemory.Height);
                    gMemory.Dispose();

                    RectangleF rectSrc, rectDest;

                    float fSrcX = (bmpMemory.Width - rectBounds.Width) / 2;
                    float fSrcY = (bmpMemory.Height - rectBounds.Height) / 2;

                    rectSrc  = new RectangleF(fSrcX, fSrcY, rectBounds.Width, rectBounds.Height);
                    rectDest = new RectangleF(rectBounds.Left, rectBounds.Top, rectBounds.Width, rectBounds.Height);

                    //Draws a cropped region of the center-most area of the ellipitical gradient in the memory-resident image which will be
                    //rendered on the control's UI display.  This will result in producing the desired gradient effect for the control.
                    graphics.DrawImage(bmpMemory, rectDest, rectSrc, GraphicsUnit.Pixel);
                    bmpMemory.Dispose();
                }
                else
                {
                    Bitmap   bmpMemory = new Bitmap(Convert.ToInt32(szEllipse.Width), Convert.ToInt32(szEllipse.Height));
                    Graphics gMemory   = Graphics.FromImage(bmpMemory);

                    Rectangle    rectBoundsGrad = new Rectangle(Convert.ToInt32(rectBounds.Left), Convert.ToInt32(rectBounds.Top), Convert.ToInt32(rectBounds.Width * 3), Convert.ToInt32(rectBounds.Height * 3));
                    GraphicsPath pathGrad       = CoolDraw.GetRoundedRectPath(rectBoundsGrad, 10, 10, 0);

                    //Draws the ellipitical gradient in a expanded region in memory, so that the desired region of the ellipsis gradient can be
                    //rendered onto the device context (paintable surface/display) of the control's UI.
                    gMemory.FillPath(pathGradBrush, pathGrad);
                    gMemory.Dispose();

                    RectangleF rectSrc, rectDest;

                    float fSrcX = (bmpMemory.Width - rectBounds.Width) / 2;
                    float fSrcY = (bmpMemory.Height - rectBounds.Height) / 2;

                    rectSrc  = new RectangleF(fSrcX, fSrcY, rectBounds.Width, rectBounds.Height);
                    rectDest = new RectangleF(rectBounds.Left, rectBounds.Top, rectBounds.Width, rectBounds.Height);

                    bmpMemory.MakeTransparent();

                    //Draws a cropped region of the center-most area of the ellipitical gradient in the memory-resident image which will be
                    //rendered on the control's UI display.  This will result in producing the desired gradient effect for the control.
                    graphics.DrawImage(bmpMemory, rectDest, rectSrc, GraphicsUnit.Pixel);
                    bmpMemory.Dispose();
                }//end if
            }
            catch (Exception err)
            {
                ErrorHandler.ShowErrorMessage(err, "Error in DrawEllipsisGradient function of CoolGradient class.");
            }
            finally
            {
                if (pathEllipse != null)
                {
                    pathEllipse.Dispose();
                }

                if (pathGradBrush != null)
                {
                    pathGradBrush.Dispose();
                }
            }
        }
예제 #34
0
파일: Theme.cs 프로젝트: massimoca/Wedit
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
        GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);

        PB1 = new PathGradientBrush(GP1);
        PB1.CenterColor = Color.FromArgb(50, 50, 50);
        PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
        PB1.FocusScales = new PointF(0.9f, 0.5f);

        G.FillPath(PB1, GP1);

        G.DrawPath(P2, GP1);
        G.DrawPath(P1, GP2);
    }
예제 #35
0
파일: Theme.cs 프로젝트: massimoca/Wedit
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = ThemeModule.CreateRound(0, 2, Height - 5, Height - 5, 5);
        GP2 = ThemeModule.CreateRound(1, 3, Height - 7, Height - 7, 5);

        PB1 = new PathGradientBrush(GP1);
        PB1.CenterColor = Color.FromArgb(50, 50, 50);
        PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
        PB1.FocusScales = new PointF(0.3f, 0.3f);

        G.FillPath(PB1, GP1);
        G.DrawPath(P11, GP1);
        G.DrawPath(P22, GP2);

        if (_Checked)
        {
            G.DrawLine(P3, 5, Height - 9, 8, Height - 7);
            G.DrawLine(P3, 7, Height - 7, Height - 8, 7);

            G.DrawLine(P4, 4, Height - 10, 7, Height - 8);
            G.DrawLine(P4, 6, Height - 8, Height - 9, 6);
        }

        SZ1 = G.MeasureString(Text, Font);
        PT1 = new PointF(Height - 3, Height / 2 - SZ1.Height / 2);

        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
        G.DrawString(Text, Font, Brushes.White, PT1);
    }
예제 #36
0
파일: Theme.cs 프로젝트: massimoca/Wedit
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);

        Rectangle R = default(Rectangle);

        int Offset = 0;
        G.DrawRectangle(P1, 0, 0, (12 * 32) + 1, (5 * 32) + 1);

        for (int I = 0; I <= Buttons.Length - 1; I++)
        {
            R = Buttons[I];

            Offset = 0;
            if (I == Pressed)
            {
                Offset = 1;

                GP1 = new GraphicsPath();
                GP1.AddRectangle(R);

                PB1 = new PathGradientBrush(GP1);
                PB1.CenterColor = Color.FromArgb(60, 60, 60);
                PB1.SurroundColors = new Color[] { Color.FromArgb(55, 55, 55) };
                PB1.FocusScales = new PointF(0.8f, 0.5f);

                G.FillPath(PB1, GP1);
            }
            else {
                GB1 = new LinearGradientBrush(R, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
                G.FillRectangle(GB1, R);
            }

            switch (I)
            {
                case 48:
                case 49:
                case 50:
                    SZ1 = G.MeasureString(Other[I - 48], Font);
                    G.DrawString(Other[I - 48], Font, Brushes.Black, R.X + (R.Width / 2 - SZ1.Width / 2) + Offset + 1, R.Y + (R.Height / 2 - SZ1.Height / 2) + Offset + 1);
                    G.DrawString(Other[I - 48], Font, Brushes.White, R.X + (R.Width / 2 - SZ1.Width / 2) + Offset, R.Y + (R.Height / 2 - SZ1.Height / 2) + Offset);
                    break;
                case 47:
                    DrawArrow(Color.Black, R.X + Offset + 1, R.Y + Offset + 1);
                    DrawArrow(Color.White, R.X + Offset, R.Y + Offset);
                    break;
                default:
                    if (Shift)
                    {
                        G.DrawString(Upper[I].ToString(), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1);
                        G.DrawString(Upper[I].ToString(), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset);

                        if (!char.IsLetter(Lower[I]))
                        {
                            PT1 = LowerCache[I];
                            G.DrawString(Lower[I].ToString(), Font, B1, PT1.X + Offset, PT1.Y + Offset);
                        }
                    }
                    else {
                        G.DrawString(Lower[I].ToString(), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1);
                        G.DrawString(Lower[I].ToString(), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset);

                        if (!char.IsLetter(Upper[I]))
                        {
                            PT1 = UpperCache[I];
                            G.DrawString(Upper[I].ToString(), Font, B1, PT1.X + Offset, PT1.Y + Offset);
                        }
                    }
                    break;
            }

            G.DrawRectangle(P2, R.X + 1 + Offset, R.Y + 1 + Offset, R.Width - 2, R.Height - 2);
            G.DrawRectangle(P3, R.X + Offset, R.Y + Offset, R.Width, R.Height);

            if (I == Pressed)
            {
                G.DrawLine(P1, R.X, R.Y, R.Right, R.Y);
                G.DrawLine(P1, R.X, R.Y, R.X, R.Bottom);
            }
        }
    }
예제 #37
0
파일: Theme.cs 프로젝트: massimoca/Wedit
    protected override void OnPaint(PaintEventArgs e)
    {
        G = e.Graphics;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
        GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);

        PB1 = new PathGradientBrush(GP1);
        PB1.CenterColor = Color.FromArgb(50, 50, 50);
        PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
        PB1.FocusScales = new PointF(0.9f, 0.5f);

        G.FillPath(PB1, GP1);

        G.DrawPath(P1, GP1);
        G.DrawPath(P2, GP2);

        G.SmoothingMode = SmoothingMode.None;

        for (int I = 0; I <= Table.Length - 1; I++)
        {
            int C = Math.Max(Table[I], (byte)75);

            int X = ((I % RowSize) * ItemSize) + WA.X;
            int Y = ((I / RowSize) * ItemSize) + WA.Y;

            B2 = new SolidBrush(Color.FromArgb(C, C, C));

            G.FillRectangle(B1, X + 1, Y + 1, DrawSize, DrawSize);
            G.FillRectangle(B2, X, Y, DrawSize, DrawSize);

            B2.Dispose();
        }

    }
예제 #38
0
파일: Theme.cs 프로젝트: massimoca/Wedit
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
        GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);

        PB1 = new PathGradientBrush(GP1);
        PB1.CenterColor = Color.FromArgb(50, 50, 50);
        PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
        PB1.FocusScales = new PointF(0.3f, 0.3f);

        G.FillPath(PB1, GP1);
        G.DrawPath(P1, GP1);
        G.DrawPath(P2, GP2);

        R1 = new Rectangle(5, 0, Width - 10, Height + 2);
        R2 = new Rectangle(6, 1, Width - 10, Height + 2);

        R3 = new Rectangle(1, 1, (Width / 2) - 1, Height - 3);

        if (_Checked)
        {
            G.DrawString("On", Font, Brushes.Black, R2, SF1);
            G.DrawString("On", Font, Brushes.White, R1, SF1);

            R3.X += (Width / 2) - 1;
        }
        else {
            G.DrawString("Off", Font, B1, R2, SF2);
            G.DrawString("Off", Font, B2, R1, SF2);
        }

        GP3 = ThemeModule.CreateRound(R3, 7);
        GP4 = ThemeModule.CreateRound(R3.X + 1, R3.Y + 1, R3.Width - 2, R3.Height - 2, 7);

        GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);

        G.FillPath(GB1, GP3);
        G.DrawPath(P2, GP3);
        G.DrawPath(P3, GP4);

        Offset = R3.X + (R3.Width / 2) - 3;

        for (int I = 0; I <= 1; I++)
        {
            if (_Checked)
            {
                G.FillRectangle(B1, Offset + (I * 5), 7, 2, Height - 14);
            }
            else {
                G.FillRectangle(B3, Offset + (I * 5), 7, 2, Height - 14);
            }

            G.SmoothingMode = SmoothingMode.None;

            if (_Checked)
            {
                G.FillRectangle(B4, Offset + (I * 5), 7, 2, Height - 14);
            }
            else {
                G.FillRectangle(B5, Offset + (I * 5), 7, 2, Height - 14);
            }

            G.SmoothingMode = SmoothingMode.AntiAlias;
        }
    }
예제 #39
0
파일: Theme.cs 프로젝트: massimoca/Wedit
    protected override void OnPaint(PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(Color.FromArgb(50, 50, 50));
        G.SmoothingMode = SmoothingMode.AntiAlias;

        ItemHeight = ItemSize.Height + 2;

        GP1 = ThemeModule.CreateRound(0, 0, ItemHeight + 3, Height - 1, 7);
        GP2 = ThemeModule.CreateRound(1, 1, ItemHeight + 3, Height - 3, 7);

        PB1 = new PathGradientBrush(GP1);
        PB1.CenterColor = Color.FromArgb(50, 50, 50);
        PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
        PB1.FocusScales = new PointF(0.8f, 0.95f);

        G.FillPath(PB1, GP1);

        G.DrawPath(P1, GP1);
        G.DrawPath(P2, GP2);

        for (int I = 0; I <= TabCount - 1; I++)
        {
            R1 = GetTabRect(I);
            R1.Y += 2;
            R1.Height -= 3;
            R1.Width += 1;
            R1.X -= 1;

            TP1 = TabPages[I];
            Offset = 0;

            if (SelectedIndex == I)
            {
                G.FillRectangle(B1, R1);

                for (int J = 0; J <= 1; J++)
                {
                    G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9);

                    G.SmoothingMode = SmoothingMode.None;
                    G.FillRectangle(B3, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9);
                    G.SmoothingMode = SmoothingMode.AntiAlias;

                    Offset += 5;
                }

                G.DrawRectangle(P3, R1.X + 1, R1.Y - 1, R1.Width, R1.Height + 2);
                G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2);
                G.DrawRectangle(P2, R1);
            }
            else {
                for (int J = 0; J <= 1; J++)
                {
                    G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9);

                    G.SmoothingMode = SmoothingMode.None;
                    G.FillRectangle(B4, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9);
                    G.SmoothingMode = SmoothingMode.AntiAlias;

                    Offset += 5;
                }
            }

            R1.X += 5 + Offset;

            R2 = R1;
            R2.Y += 1;
            R2.X += 1;

            G.DrawString(TP1.Text, Font, Brushes.Black, R2, SF1);
            G.DrawString(TP1.Text, Font, Brushes.White, R1, SF1);
        }

        GP3 = ThemeModule.CreateRound(ItemHeight, 0, Width - ItemHeight - 1, Height - 1, 7);
        GP4 = ThemeModule.CreateRound(ItemHeight + 1, 1, Width - ItemHeight - 3, Height - 3, 7);

        G.DrawPath(P2, GP3);
        G.DrawPath(P1, GP4);
    }
예제 #40
-1
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
        GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);

        if (IsMouseDown)
        {
            PB1 = new PathGradientBrush(GP1);
            PB1.CenterColor = Color.FromArgb(60, 60, 60);
            PB1.SurroundColors = new Color[] { Color.FromArgb(55, 55, 55) };
            PB1.FocusScales = new PointF(0.8f, 0.5f);

            G.FillPath(PB1, GP1);
        }
        else
        {
            GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
            G.FillPath(GB1, GP1);
        }

        G.DrawPath(P1, GP1);
        G.DrawPath(P2, GP2);

        SZ1 = G.MeasureString(Text, Font);
        PT1 = new PointF(5, Height / 2 - SZ1.Height / 2);

        if (IsMouseDown)
        {
            PT1.X += 1f;
            PT1.Y += 1f;
        }

        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
        G.DrawString(Text, Font, Brushes.White, PT1);
    }
예제 #41
-1
파일: Theme.cs 프로젝트: massimoca/Wedit
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.AntiAlias;

        GP1 = new GraphicsPath();
        GP1.AddEllipse(0, 2, Height - 5, Height - 5);

        PB1 = new PathGradientBrush(GP1);
        PB1.CenterColor = Color.FromArgb(50, 50, 50);
        PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) };
        PB1.FocusScales = new PointF(0.3f, 0.3f);

        G.FillPath(PB1, GP1);

        G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5);
        G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7);

        if (_Checked)
        {
            G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15);
            G.FillEllipse(Brushes.White, 5, 7, Height - 15, Height - 15);
        }

        SZ1 = G.MeasureString(Text, Font);
        PT1 = new PointF(Height - 3, Height / 2 - SZ1.Height / 2);

        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
        G.DrawString(Text, Font, Brushes.White, PT1);
    }