当前位置: 首页>>代码示例>>C#>>正文


C# Graphics.FillPath方法代码示例

本文整理汇总了C#中System.Drawing.Graphics.FillPath方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.FillPath方法的具体用法?C# Graphics.FillPath怎么用?C# Graphics.FillPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Graphics的用法示例。


在下文中一共展示了Graphics.FillPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderEllipseGlass

        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);
                    }
                }
            }
        }
开发者ID:webxiaohua,项目名称:SmartControls,代码行数:28,代码来源:GlassPainter.cs

示例2: FillRoundRectangle

 public static void FillRoundRectangle(Graphics g, Brush brush, Rectangle rect, int cornerRadius)
 {
     using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
     {
         g.FillPath(brush, path);
     }
 }
开发者ID:wawa0210,项目名称:jgq,代码行数:7,代码来源:ValidateCode.aspx.cs

示例3: DrawLabel

        /// <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);
            }
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:46,代码来源:LabelRenderer.cs

示例4: FillRoundedRectangle

        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();
            }
        }
开发者ID:HudsonAkridge,项目名称:Terrarium-2.5,代码行数:35,代码来源:GlassHelper.cs

示例5: DrawTab

 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);
             }
         }
     }
 }
开发者ID:solitas,项目名称:SolitasWinformControllib,代码行数:25,代码来源:FlatTabRenderer.cs

示例6: DrawButton

 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);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:PageStrip.cs

示例7: RoundRectangle

 // 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);
     }
 }
开发者ID:renyh1013,项目名称:dp2,代码行数:29,代码来源:NewPanelControl.cs

示例8: Paint

 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);
     }
 }
开发者ID:Kuzq,项目名称:gitter,代码行数:33,代码来源:DefaultOverlayRenderer.cs

示例9: DrawRoundRect

        /// <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();
        }
开发者ID:jyorin,项目名称:yinghe,代码行数:38,代码来源:绘图类.cs

示例10: DrawGlass

        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();
        }
开发者ID:Carolasb,项目名称:Terrarium,代码行数:33,代码来源:GlassHelper.cs

示例11: paint

 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);
 }
开发者ID:krich38,项目名称:Screenshotter,代码行数:7,代码来源:FormPreview.cs

示例12: DrawRoundRect

        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();
        }
开发者ID:ddg-igh,项目名称:crazy-taxi,代码行数:32,代码来源:DoubleBufferedPanel.cs

示例13: DrawYourSelf

        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);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:26,代码来源:EllipseLineIntersectionShape.cs

示例14: DrawYourSelf

        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);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:30,代码来源:PolygonShape.cs

示例15: DrawTab

        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);
        }
开发者ID:vendolis,项目名称:EDDiscovery,代码行数:28,代码来源:TabStyleCustom.cs


注:本文中的System.Drawing.Graphics.FillPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。