FillPath() public method

public FillPath ( Brush brush, GraphicsPath path ) : void
brush Brush
path System.Drawing.Drawing2D.GraphicsPath
return void
Example #1
1
        public static void RenderEllipseGlass(Graphics g, Rectangle ownerRect, GlassPosition position,
            float positionFactor, Color glassColor, int alphaCenter, int alphaSurround)
        {
            if (!(positionFactor > 0 && positionFactor < 1))
                throw new ArgumentException("positionFactor must be between 0 and 1, but not include 0 and 1. ",
                    "positionFactor");

            ownerRect.Height--;
            ownerRect.Width--;

            if (ownerRect.Width < 1 || ownerRect.Height < 1)
                return;

            using (GraphicsPath gp = new GraphicsPath())
            {
                gp.AddEllipse(ownerRect);
                using (PathGradientBrush pb = new PathGradientBrush(gp))
                {
                    pb.CenterPoint = GetEllipseGlassCenterPoint(ownerRect, position, positionFactor);
                    pb.CenterColor = Color.FromArgb(alphaCenter, glassColor);
                    pb.SurroundColors = new Color[] { Color.FromArgb(alphaSurround, glassColor) };
                    using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias))
                    {
                        g.FillPath(pb, gp);
                    }
                }
            }
        }
Example #2
1
 public static void FillRoundRectangle(Graphics g, Brush brush, Rectangle rect, int cornerRadius)
 {
     using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
     {
         g.FillPath(brush, path);
     }
 }
Example #3
0
        /// <summary>
        /// Renders a label to the map.
        /// </summary>
        /// <param name="graphics">Graphics reference</param>
        /// <param name="labelPoint">Label placement</param>
        /// <param name="offset">Offset of label in screen coordinates</param>
        /// <param name="font">Font used for rendering</param>
        /// <param name="forecolor">Font forecolor</param>
        /// <param name="backcolor">Background color</param>
        /// <param name="halo">Color of halo</param>
        /// <param name="rotation">Text rotation in degrees</param>
        /// <param name="text">Text to render</param>
        /// <param name="viewport"></param>
        public static void DrawLabel(Graphics graphics, Point labelPoint, Offset offset, Styles.Font font, Styles.Color forecolor, Styles.Brush backcolor, Styles.Pen halo, double rotation, string text, IViewport viewport, StyleContext context)
        {
            SizeF fontSize = graphics.MeasureString(text, font.ToGdi(context)); //Calculate the size of the text
            labelPoint.X += offset.X; labelPoint.Y += offset.Y; //add label offset
            if (Math.Abs(rotation) > Constants.Epsilon && !double.IsNaN(rotation))
            {
                graphics.TranslateTransform((float)labelPoint.X, (float)labelPoint.Y);
                graphics.RotateTransform((float)rotation);
                graphics.TranslateTransform(-fontSize.Width / 2, -fontSize.Height / 2);
                if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
                    graphics.FillRectangle(backcolor.ToGdi(context), 0, 0, fontSize.Width * 0.74f + 1f, fontSize.Height * 0.74f);
                var path = new GraphicsPath();
                path.AddString(text, new FontFamily(font.FontFamily), (int)font.ToGdi(context).Style, font.ToGdi(context).Size, new System.Drawing.Point(0, 0), null);
                if (halo != null)
                    graphics.DrawPath(halo.ToGdi(context), path);
                graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);
            }
            else
            {
                if (backcolor != null && backcolor.ToGdi(context) != Brushes.Transparent)
                    graphics.FillRectangle(backcolor.ToGdi(context), (float)labelPoint.X, (float)labelPoint.Y, fontSize.Width * 0.74f + 1, fontSize.Height * 0.74f);

                var path = new GraphicsPath();

                //Arial hack
                path.AddString(text, new FontFamily("Arial"), (int)font.ToGdi(context).Style, (float)font.Size, new System.Drawing.Point((int)labelPoint.X, (int)labelPoint.Y), null);
                if (halo != null)
                    graphics.DrawPath(halo.ToGdi(context), path);
                graphics.FillPath(new SolidBrush(forecolor.ToGdi()), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
            }
        }
        public static void FillRoundedRectangle(Rectangle rectangle, GlassGradient gradient, bool isSunk, bool isGlass,
                                                Graphics graphics)
        {
            if (rectangle.Width == 0 || rectangle.Height == 0)
                return;

            var path = GetRoundedRectanglePath(rectangle);

            var activeGradient = isSunk
                                     ? new GlassGradient(gradient.Bottom, gradient.Top)
                                     : new GlassGradient(gradient.Top, gradient.Bottom);

            var brush = activeGradient.GetBrush(rectangle);
            graphics.FillPath(brush, path);
            brush.Dispose();

            if (isGlass)
            {
                graphics.SetClip(path);

                var glassRectangle = isSunk
                                         ? new Rectangle(new Point(rectangle.Left, rectangle.Height/2),
                                                         new Size(rectangle.Width, rectangle.Height/2))
                                         : new Rectangle(rectangle.Location,
                                                         new Size(rectangle.Width, rectangle.Height/2));
                var glassPath = GetRoundedRectanglePath(glassRectangle);
                Brush glassBrush = new LinearGradientBrush(glassRectangle, Color.Transparent,
                                                           Color.FromArgb(32, 255, 255, 255), 90.0f);

                graphics.FillPath(glassBrush, glassPath);

                glassBrush.Dispose();
                glassPath.Dispose();
            }
        }
 public override void DrawTab(Color foreColor, Color backColor, Color highlightColor, Color shadowColor, Color borderColor, bool active, bool mouseOver, DockStyle dock, Graphics graphics, SizeF tabSize)
 {
     RectangleF headerRect = new RectangleF(0, 0, tabSize.Width, tabSize.Height);
     Rectangle header = new Rectangle(0, 0, (int)tabSize.Width, (int)tabSize.Height);
     using (var path = ShapeRender.GetTopRoundRect(0, 0, tabSize.Width, tabSize.Height, 0.5f))
     {
         if (active)
         {
             using (Brush brush = new SolidBrush(foreColor))
             using (Pen pen = new Pen(shadowColor, 0.2f))
             {
                 graphics.FillPath(brush, path);
                 graphics.DrawRectangle(pen, header);
             }
         }
         else
         {
             using (Brush brush = new SolidBrush(backColor))
             using (Pen pen = new Pen(shadowColor))
             {
                 graphics.FillPath(brush, path);
             }
         }
     }
 }
 private void DrawButton(Graphics graphics, ScrollButton scrollButton)
 {
     Rectangle buttonBounds = base.GetButtonBounds(scrollButton);
     if (base.Orientation == Orientation.Horizontal)
     {
         buttonBounds.Inflate(-base.itemStrip.ItemSize.Width / 6, -base.itemStrip.ItemSize.Height / 4);
     }
     else
     {
         buttonBounds.Inflate(-base.itemStrip.ItemSize.Width / 4, -base.itemStrip.ItemSize.Height / 6);
     }
     if (base.ActiveButton == scrollButton)
     {
         buttonBounds.Offset(1, 1);
         Size size = (base.Orientation == Orientation.Horizontal) ? new Size(0, 2) : new Size(2, 0);
         buttonBounds.Inflate(size.Width, size.Height);
         graphics.FillRectangle(SelectionBrush, buttonBounds);
         graphics.DrawRectangle(Pens.Black, buttonBounds);
         buttonBounds.Inflate(-size.Width, -size.Height);
     }
     using (GraphicsPath path = ActivityDesignerPaint.GetScrollIndicatorPath(buttonBounds, scrollButton))
     {
         graphics.FillPath(Brushes.Black, path);
         graphics.DrawPath(Pens.Black, path);
     }
 }
Example #7
0
 // paramters:
 //      pen 绘制边框。可以为null,那样就整体一个填充色,没有边框
 //      brush   绘制填充色。可以为null,那样就只有边框
 public static void RoundRectangle(Graphics graphics,
     Pen pen,
     Brush brush,
     float x,
     float y,
     float width,
     float height,
     float radius)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         path.AddLine(x + radius, y, x + width - (radius * 2), y);
         path.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90);
         path.AddLine(x + width, y + radius, x + width, y + height - (radius * 2));
         path.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
         path.AddLine(x + width - (radius * 2), y + height, x + radius, y + height);
         path.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
         path.AddLine(x, y + height - (radius * 2), x, y + radius);
         path.AddArc(x, y, radius * 2, radius * 2, 180, 90);
         path.CloseFigure();
         if (brush != null)
             graphics.FillPath(brush, path);
         if (pen != null)
             graphics.DrawPath(pen, path);
     }
 }
Example #8
0
 public override void Paint(ProcessOverlay processOverlay, Graphics graphics, Rectangle bounds)
 {
     var font = processOverlay.Font;
     var oldMode = graphics.SmoothingMode;
     graphics.SmoothingMode = SmoothingMode.HighQuality;
     const int spacing = 10;
     using(var path = GraphicsUtility.GetRoundedRectangle(bounds, processOverlay.Rounding))
     {
         using(var brush = new SolidBrush(BackgroundColor))
         {
             graphics.FillPath(brush, path);
         }
         using(var pen = new Pen(BorderColor, 2.0f))
         {
             graphics.DrawPath(pen, path);
         }
     }
     var tw = GitterApplication.TextRenderer.MeasureText(
         graphics, processOverlay.Title, font, bounds.Width, TitleStringFormat).Width;
     DrawIndeterminateProgress(graphics, bounds.X + (bounds.Width - tw) / 2 - 14 - 5, bounds.Y + (bounds.Height - 14) / 2, 14, 14);
     var titleRect = new Rectangle(bounds.X + (bounds.Width - tw) / 2, bounds.Y, bounds.Width - spacing * 2 - 5 - 14, bounds.Height);
     graphics.SmoothingMode = oldMode;
     if(!string.IsNullOrWhiteSpace(processOverlay.Title))
     {
         GitterApplication.TextRenderer.DrawText(
             graphics, processOverlay.Title, font, FontBrush, titleRect, TitleStringFormat);
     }
     if(!string.IsNullOrWhiteSpace(processOverlay.Message))
     {
         GitterApplication.TextRenderer.DrawText(
             graphics, processOverlay.Message, font, FontBrush, bounds, StringFormat);
     }
 }
Example #9
0
        /// <summary>
        /// 绘制圆角
        /// </summary>
        /// <param name="g"></param>
        /// <param name="p"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="radius"></param>
        public static void DrawRoundRect(Graphics g, Pen p, Brush brush,float X, float Y, float width, float height, float radius)
        {
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);

            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);

            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));

            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);

            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);

            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);

            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);

            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);

            gp.CloseFigure();

            g.DrawPath(p, gp);

            g.FillPath(brush, gp);

            gp.Dispose();
        }
Example #10
0
        public static void DrawGlass(Rectangle rectangle, Graphics graphics)
        {
            if (rectangle.Width == 0 || rectangle.Height == 0)
                return;

            var clipPath = GetRoundedRectanglePath(rectangle);

            graphics.SetClip(clipPath);

            var glassRectangle = new Rectangle(rectangle.Location, new Size(rectangle.Width, rectangle.Height/2));

            // Apply a glass look
            Brush glassBrush = new LinearGradientBrush(glassRectangle, Color.Transparent,
                                                       Color.FromArgb(32, 255, 255, 255), 90.0f);

            var glassPath = GetRoundedRectanglePath(glassRectangle);

            graphics.FillPath(glassBrush, glassPath);

            glassPath.Dispose();
            glassBrush.Dispose();

            glassRectangle = new Rectangle(0, rectangle.Height - (rectangle.Height/4), rectangle.Width,
                                           rectangle.Height*3);
            glassPath = GetRoundedRectanglePath(glassRectangle);
            glassBrush = new SolidBrush(Color.FromArgb(16, Color.White));

            glassBrush.Dispose();
            glassPath.Dispose();

            graphics.SetClip(rectangle);
            clipPath.Dispose();
        }
Example #11
0
 private void paint(Graphics g, GraphicsPath path, bool edge, Color edgeColour, int edgeWidth, bool fill, Color fillColour)
 {
     if (edge)
         g.DrawPath(new Pen(edgeColour, edgeWidth), path);
     if (fill)
         g.FillPath(new SolidBrush(fillColour), path);
 }
Example #12
0
        public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
        {
            Y+=5;
            X+=5;
            width -= 12;
            height -= 12;
            GraphicsPath gp = new GraphicsPath();
            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
            gp.CloseFigure();
            g.FillPath(Brushes.Transparent, gp);
            gp.Dispose();

            gp = new GraphicsPath();
            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
            gp.CloseFigure();
            g.DrawPath(p, gp);
            gp.Dispose();
        }
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);
            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
Example #14
0
        public override void DrawYourSelf(Graphics graphics)
        {
            int i = 0;
            Point[] points = new Point[this.pointsList.Count];//(Point[])pointsList.ToArray(typeof(Point));
            foreach(Point _point in this.pointsList)
            {
                points[i] = _point;
                i++;
            }

            GraphicsPath path = new GraphicsPath();
            path.AddPolygon(points);
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);

            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }

            graphics.DrawPath(pen, path);

            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
Example #15
0
        public override void DrawTab(Graphics gr, Rectangle borderrect, int index, bool selected, Color color1, Color color2, Color coloroutline, TabAlignment alignment)
        {
            GraphicsPath border = new GraphicsPath();
            GraphicsPath fill = new GraphicsPath();

            int xfar = borderrect.Right - 1;

            int ybot = (alignment == TabAlignment.Bottom) ? (borderrect.Y) : (borderrect.Bottom - 1);
            int ytop = (alignment == TabAlignment.Bottom) ? (borderrect.Bottom-1-((selected)?0:2)) : (borderrect.Y - ((selected) ? 2 : 0));

            border.AddLine(borderrect.X, ybot, borderrect.X + shift, ytop);
            border.AddLine(borderrect.X + shift, ytop, xfar, ytop);
            border.AddLine(xfar, ytop, xfar + shift, ybot);

            fill.AddLine(borderrect.X, ybot + 1, borderrect.X + shift, ytop);
            fill.AddLine(borderrect.X + shift, ytop, xfar, ytop);
            fill.AddLine(xfar, ytop, xfar + shift, ybot + 1);

            gr.SmoothingMode = SmoothingMode.Default;

            using (Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(borderrect, color1, color2, 90))
                gr.FillPath(b, fill);

            gr.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen p = new Pen(coloroutline, 1.0F))
                gr.DrawPath(p, border);
        }
Example #16
0
        public override void RenderObject(Graphics g, DrawContext dcxt)
        {
            GraphicsPath path = new GraphicsPath();
            foreach (Object ch in pathes)
            {
                if (ch is VectorPathLine)
                {
                    VectorPathLine vpl = (VectorPathLine)ch;
                    path.AddLine(dcxt.X_V2S(vpl.x1), dcxt.Y_V2S(vpl.y1), dcxt.X_V2S(vpl.x2), dcxt.Y_V2S(vpl.y2));
                }
                else if (ch is VectorPathArc)
                {
                    VectorPathArc vpa = (VectorPathArc)ch;
                    path.AddArc(dcxt.X_V2S(vpa.x - vpa.w / 2), dcxt.Y_V2S(vpa.y - vpa.h/2), dcxt.W_V2S(vpa.w), dcxt.H_V2S(vpa.h), vpa.startagl, vpa.sweepagl);
                }
                else if (ch is VectorPathPie)
                {
                    VectorPathPie vpp = (VectorPathPie)ch;
                    path.AddArc(dcxt.X_V2S(vpp.x - vpp.w / 2), dcxt.Y_V2S(vpp.y - vpp.h/2), dcxt.W_V2S(vpp.w), dcxt.H_V2S(vpp.h), vpp.startagl, vpp.sweepagl);
                }
            }

            if (fill)
                g.FillPath(BrushWhenCxt(dcxt).Brush, path);
            else
                g.DrawPath(PenWhenCxt(dcxt).Pen, path);
        }
        public static void DrawOuterGlow(Graphics gps, GraphicsPath gp, Rectangle rect, float size,
            Color lightColor,
            Color bodyColor)
        {
            Bitmap bm = new Bitmap(rect.Width / 5, rect.Height / 5);
            Graphics g = Graphics.FromImage(bm);
            Matrix mx = new Matrix(
                1.0f / 5,
                0,
                0,
                1.0f / 5,
                -(1.0f / 5),
                -(1.0f / 5));
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.Transform = mx;
            Pen p = new Pen(lightColor, size);
            g.DrawPath(p, gp);
            //g.FillPath(new SolidBrush(lightColor), gp);
            g.Dispose();
            gps.Transform = new Matrix();

            gps.SmoothingMode = SmoothingMode.AntiAlias;
            gps.InterpolationMode = InterpolationMode.HighQualityBicubic;
            gps.DrawImage(bm, rect, 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel);
            gps.FillPath(new SolidBrush(bodyColor), gp);
        }
Example #18
0
        /// <summary>
        /// The graphics device and clip rectangle are in the parent coordinates.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="clipRectangle"></param>
        /// <param name="symbol">The symbol to use for drawing.</param>
        public void Draw(Graphics g, Rectangle clipRectangle, ISymbol symbol)
        {
            Color topLeft;
            Color bottomRight;
            if (_isSelected)
            {
                topLeft = _selectionColor.Darker(.3F);
                bottomRight = _selectionColor.Lighter(.3F);
            }
            else
            {
                topLeft = _backColor.Lighter(.3F);
                bottomRight = _backColor.Darker(.3F);
            }
            LinearGradientBrush b = new LinearGradientBrush(_bounds, topLeft, bottomRight, LinearGradientMode.ForwardDiagonal);
            GraphicsPath gp = new GraphicsPath();
            gp.AddRoundedRectangle(Bounds, _roundingRadius);
            g.FillPath(b, gp);
            gp.Dispose();
            b.Dispose();

            Matrix old = g.Transform;
            Matrix shift = g.Transform;
            shift.Translate(_bounds.Left + _bounds.Width / 2, _bounds.Top + _bounds.Height / 2);
            g.Transform = shift;

            if (symbol != null)
            {
                OnDrawSymbol(g, symbol);
            }

            g.Transform = old;
        }
Example #19
0
        public static void DrawPolygon(Graphics graphics, Polygon pol, Brush brush, Pen pen, IViewport viewport)
        {
            if (pol.ExteriorRing == null) return;
            if (pol.ExteriorRing.Vertices.Count <= 2) return;

            //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
            var gp = new GraphicsPath();

            //Add the exterior polygon
            var points = GeometryRenderer.WorldToScreenGDI(pol.ExteriorRing, viewport);
            if (points.Length > 2)
                gp.AddPolygon(points);
            //Add the interior polygons (holes)
            foreach (LinearRing linearRing in pol.InteriorRings)
            {
                var interiorPoints = GeometryRenderer.WorldToScreenGDI(linearRing, viewport);
                if (interiorPoints.Length > 2)
                    gp.AddPolygon(interiorPoints);
            }

            if (gp.PointCount == 0) return;

            // Only render inside of polygon if the brush isn't null or isn't transparent
            if (brush != null && brush != Brushes.Transparent)
                graphics.FillPath(brush, gp);
            // Create an outline if a pen style is available
            if (pen != null)
                graphics.DrawPath(pen, gp);
        }
Example #20
0
        //------ End Constructors -----//
        public override void Paint(Graphics g, System.Drawing.Drawing2D.GraphicsPath gp, bool isSelected)
        {
            if (isSelected)
            {
                SolidBrush br = new SolidBrush(selectedBack);
                Pen pen = new Pen(selectedLine);
                g.FillPath(br, gp);
                g.DrawPath(pen, gp);
                br.Dispose();
                pen.Dispose();
            }
            else  //is not selected
            {
                if (_PaintBack)
                {
                    SolidBrush br = new SolidBrush(_BackColor);
                    g.FillPath(br,gp);
                    br.Dispose();
                }

                if (_PaintLine)
                {
                    Pen pen = new Pen(_LineColor);
                    g.DrawPath(pen, gp);
                    pen.Dispose();
                }
            }
        }
Example #21
0
        public static void DrawRoundedRectangle(Graphics newGraphics, Color boxColor, Color gradFillColor1, Color gradFillColor2, int xPosition, int yPosition,
                   int height, int width, int cornerRadius)
        {
            using (var boxPen = new Pen(boxColor))
            {
                using (var path = new GraphicsPath())
                {
                    path.AddLine(xPosition + cornerRadius, yPosition, xPosition + width - (cornerRadius * 2), yPosition);
                    path.AddArc(xPosition + width - (cornerRadius * 2), yPosition, cornerRadius * 2, cornerRadius * 2, 270, 90);
                    path.AddLine(xPosition + width, yPosition + cornerRadius, xPosition + width,
                                 yPosition + height - (cornerRadius * 2));
                    path.AddArc(xPosition + width - (cornerRadius * 2), yPosition + height - (cornerRadius * 2), cornerRadius * 2,
                                cornerRadius * 2, 0, 90);
                    path.AddLine(xPosition + width - (cornerRadius * 2), yPosition + height, xPosition + cornerRadius,
                                 yPosition + height);
                    path.AddArc(xPosition, yPosition + height - (cornerRadius * 2), cornerRadius * 2, cornerRadius * 2, 90, 90);
                    path.AddLine(xPosition, yPosition + height - (cornerRadius * 2), xPosition, yPosition + cornerRadius);
                    path.AddArc(xPosition, yPosition, cornerRadius * 2, cornerRadius * 2, 180, 90);
                    path.CloseFigure();
                    newGraphics.DrawPath(boxPen, path);

                    var b = new LinearGradientBrush(new Point(xPosition, yPosition),
                                                    new Point(xPosition + width, yPosition + height), gradFillColor1,
                                                    gradFillColor2);

                    newGraphics.FillPath(b, path);
                }
            }
        }
Example #22
0
 void paintshit(List<double> datta, int numPoints, double mulX, double mulY, int bw, int bh, Graphics g, LinearGradientBrush grad, Color cbase)
 {
     PointF[] points = new PointF[numPoints];
     lock (datta)
     {
         int s = 0;
         int samples = datta.Count;
         for (; s < (points.Length - 2) - samples; s++)
         {
             points[s + 1] = new PointF((float)(s * mulX), bh);
         }
         int ofs = (points.Length - 2) - samples;
         s = Math.Max(0, samples - (points.Length - 2));
         for (; s < samples; s++)
         {
             points[s + ofs + 1] = new PointF((float)((s + ofs) * mulX),
                 (float)(bh - datta[s] * mulY));
         }
         points[0] = new PointF(0f, bh);
         points[points.Length - 1] = new PointF(bw, bh);
     }
     GraphicsPath gp = new GraphicsPath();
     gp.AddLines(points);
     g.FillPath(grad, gp);
     g.DrawPath(new Pen(cbase, 2f), gp);
 }
 /// <summary>
 /// Instructs the drawing code to fill the specified path with the specified pattern
 /// </summary>
 /// <param name="g">The System.Drawing.Graphics device to draw to</param>
 /// <param name="gp">The System.Drawing.Drawing2D.GraphicsPath to fill</param>
 public override void FillPath(Graphics g, GraphicsPath gp)
 {
     System.Drawing.Drawing2D.HatchBrush hb = new HatchBrush(_hatchStyle, _foreColor, _backColor);
     g.FillPath(hb, gp);
     hb.Dispose();
     base.FillPath(g, gp);
 }
Example #24
0
        public override void Draw(Graphics g)
        {
            System.Drawing.Size st = g.MeasureString(Marker.ToolTipText, Font).ToSize();
             System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y - st.Height, st.Width + TextPadding.Width, st.Height + TextPadding.Height);
             rect.Offset(Offset.X, Offset.Y);

             using(GraphicsPath objGP = new GraphicsPath())
             {
            objGP.AddLine(rect.X + 2 * Radius, rect.Y + rect.Height, rect.X + Radius, rect.Y + rect.Height + Radius);
            objGP.AddLine(rect.X + Radius, rect.Y + rect.Height + Radius, rect.X + Radius, rect.Y + rect.Height);

            objGP.AddArc(rect.X, rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
            objGP.AddLine(rect.X, rect.Y + rect.Height - (Radius * 2), rect.X, rect.Y + Radius);
            objGP.AddArc(rect.X, rect.Y, Radius * 2, Radius * 2, 180, 90);
            objGP.AddLine(rect.X + Radius, rect.Y, rect.X + rect.Width - (Radius * 2), rect.Y);
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y, Radius * 2, Radius * 2, 270, 90);
            objGP.AddLine(rect.X + rect.Width, rect.Y + Radius, rect.X + rect.Width, rect.Y + rect.Height - (Radius * 2));
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90); // Corner

            objGP.CloseFigure();

            g.FillPath(Fill, objGP);
            g.DrawPath(Stroke, objGP);
             }

            #if !PocketPC
             g.DrawString(Marker.ToolTipText, Font, Brushes.Navy, rect, Format);
            #else
             g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);
            #endif
        }
Example #25
0
        public override void DrawTab(Graphics gr, Rectangle borderrect, int index, bool selected, Color color1, Color color2, Color coloroutline)
        {
            int additional = 0;                             // extra depth for fill

            if (selected)
            {
                additional = 1;
                borderrect.Height += borderrect.Y;          // this one uses any height to get it bigger
                borderrect.Y = 0;
            }

            int xfar = borderrect.Right - 1;
            int yfar = borderrect.Bottom - 1;

            GraphicsPath border = new GraphicsPath();
            border.AddLine(borderrect.X, yfar + additional, borderrect.X + shift, borderrect.Y);
            border.AddLine(borderrect.X + shift, borderrect.Y, xfar, borderrect.Y);
            border.AddLine(xfar, borderrect.Y, xfar + shift, yfar + additional);

            GraphicsPath fill = new GraphicsPath();
            fill.AddLine(borderrect.X, yfar + additional + 1, borderrect.X + shift, borderrect.Y);
            fill.AddLine(borderrect.X + shift, borderrect.Y, xfar, borderrect.Y);
            fill.AddLine(xfar, borderrect.Y, xfar + shift, yfar + additional + 1);

            gr.SmoothingMode = SmoothingMode.Default;

            using (Brush b = new System.Drawing.Drawing2D.LinearGradientBrush(borderrect, color1, color2, 90))
                gr.FillPath(b, fill);

            gr.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen p = new Pen(coloroutline, 1.0F))
                gr.DrawPath(p, border);
        }
        internal override void Draw(Graphics g)
        {
            IsInvalidated = false;

            Rectangle r = GetUnsignedRectangle();

            //Shadow
            GraphicsPath gp = CreatePath(r.X + 5, r.Y + 5, r.Width, r.Height, Radius);
            //g.FillPath(new SolidBrush(Color.FromArgb((int)(255.0f * (50 / 100.0f)), Color.LightGray)), gp);

            g.FillPath(new SolidBrush(Color.LightGray), gp);

            gp.Dispose();

            //Border
            gp = CreatePath(r.X, r.Y, r.Width, r.Height, Radius);

            Pen p = new Pen(borderColor, borderWidth);
            g.DrawPath(p, gp);            
            p.Dispose();

            //Color
            Brush b = this.GetBrush(r);
            g.FillPath(b, gp);
            gp.Dispose();

            b.Dispose();
        }
 public virtual void Draw(Graphics g)
 {
     GraphicsPath usepath = new GraphicsPath();
     usepath.AddString(usecharacter.ToString(), useFont.FontFamily, (int)useFont.Style, useFont.Size, currentposition,StringFormat.GenericDefault);
     g.FillPath(fillbrush, usepath);
     g.DrawPath(strokepen, usepath);
 }
Example #28
0
        /// <summary>
        /// Renders rectangle on canvas.
        /// </summary>
        /// <param name="g">Target graphics to render shape on.</param>
        /// <param name="bounds">Shape bounds.</param>
        public override void Paint(Graphics g, Rectangle bounds)
        {
            if (bounds.Width < 2 || bounds.Height < 2 || g == null || _Fill == null && _Border == null) return;

            GraphicsPath path = null;
            
            if (!_CornerRadius.IsZero)
            {
                path = DisplayHelp.GetRoundedRectanglePath(bounds, _CornerRadius.TopLeft, _CornerRadius.TopRight, 
                    _CornerRadius.BottomRight, _CornerRadius.BottomLeft);
            }

            if (_Fill != null)
            {
                Brush brush = _Fill.CreateBrush(bounds);
                if (brush != null)
                {
                    SmoothingMode sm = g.SmoothingMode;
                    if (brush is SolidBrush && path==null)
                        g.SmoothingMode = SmoothingMode.None;
                    if (path == null)
                        g.FillRectangle(brush, bounds);
                    else
                        g.FillPath(brush, path);
                    g.SmoothingMode = sm;
                    brush.Dispose();
                }
            }

            if (_Border != null)
            {
                Pen pen = _Border.CreatePen();
                if (pen != null)
                {
                    if (path == null)
                        g.DrawRectangle(pen, bounds);
                    else
                        g.DrawPath(pen, path);

                    pen.Dispose();
                }
            }

            Shape content = this.Content;
            if (content != null)
            {
                Rectangle contentBounds = Border.Deflate(bounds, _Border);
                Region oldClip = null;
                if (path != null && ClipToBounds)
                {
                    oldClip = g.Clip;
                    g.SetClip(path, CombineMode.Intersect);
                }
                content.Paint(g, contentBounds);
                if (oldClip != null) g.Clip = oldClip;
            }

            if (path != null) path.Dispose();
        }
Example #29
0
        public void Gen(List<BiliInterfaceInfo> infos)
        {
            Log.Info("【主榜】开始生成" + infos.Count + "个图片");

            for (int i = 0; i < infos.Count; i++)
            {
                image = Properties.Resources.zhubang;
                g = Graphics.FromImage(image);
                g.SmoothingMode = SmoothingMode.AntiAlias;

                ////
                Log.Info("正在生成 - " + infos[i].AVNUM);

                g.DrawString(infos[i].title, f, b, 350, 1000);
                g.DrawString(infos[i].AVNUM, f, b, 375, 900);
                g.DrawString(infos[i].created_at.Substring(0, infos[i].created_at.IndexOf(" ")), f, b, 900, 900);
                g.DrawString("UP:" + infos[i].author, f, b, 330, 800);

                Pen pp = new Pen(Color.Yellow, 3.5f);
                GraphicsPath pth = new GraphicsPath();
                pth.AddString(infos[i].Fpaiming.ToString("D2"), new FontFamily("微软雅黑"), (int)FontStyle.Bold, 180, new Point(1750, 0), sf);
                g.FillPath(new SolidBrush(Color.White), pth);
                g.DrawPath(pp, pth);

                AddKongxin(infos[i].Fdefen.ToString(), 160, 960, 70);
                AddKongxin(infos[i].play.ToString(), 1625, 500, 70);
                AddKongxin(infos[i].review.ToString(), 1820, 330, 50);
                AddKongxin(infos[i].coins.ToString(), 1810, 710, 50);
                AddKongxin(infos[i].favorites.ToString(), 1600, 825, 60);

                /*
                g.DrawString(infos[i].Fpaiming.ToString(), new Font("微软雅黑", 60, FontStyle.Bold), b, 110, nn - 30);

                g.DrawString(infos[i].AVNUM.Substring(2), f, b, 725, nn);
                g.DrawString(infos[i].Fdefen.ToString(), f, b, 1160, nn);
                if (infos[i].author.Length <= 6)
                {
                    g.DrawString(infos[i].author, f, b, new RectangleF(1518, nn, 320, 320));
                    //g.DrawString(infos[i].up, f, b, 1518, nn);
                }
                else
                {
                    g.DrawString(infos[i].author, f, b, new RectangleF(1518, nn, 320, 320));
                    //g.DrawString(infos[i].up.Substring(0, 6), f, b, 1518, nn);
                    //g.DrawString(infos[i].up.Substring(6), f, b, 1518, nn + 74);
                }

                g.DrawString(infos[i].created_at, f, b, 880, nn + 148);
                */

                ////

                string url = Environment.CurrentDirectory + @"\pic\Rank" + infos[i].Fpaiming + ".png";
                Log.Info("保存图片 " + url);
                image.Save(url);
            }

            Log.Info("主榜图片批量生成完成");
        }
Example #30
0
        public void drawMe(Graphics G)
        {
            if (innerBrush != null)
                G.FillPath(innerBrush, Path);

            if (boundPen != null)
                G.DrawPath(boundPen, Path);
        }