本文整理汇总了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);
}
}
}
}
示例2: FillRoundRectangle
public static void FillRoundRectangle(Graphics g, Brush brush, Rectangle rect, int cornerRadius)
{
using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
{
g.FillPath(brush, path);
}
}
示例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);
}
}
示例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();
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}