本文整理汇总了C#中Graphics.FillPath方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.FillPath方法的具体用法?C# Graphics.FillPath怎么用?C# Graphics.FillPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics.FillPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPaint
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);
}
示例2: DrawBar
private void DrawBar(Graphics objGraphics,
int Value, int BarNumber, string Label)
{
int intLeft = (BarNumber*75)+60;
int intBottom = 275;
int intHeight = (25*Value);
//绘制柱面
objGraphics.FillRectangle(Brushes.Red,intLeft,
intBottom-intHeight,35,intHeight);
//使用GraphicsPath方法绘制柱面顶层
GraphicsPath pthTop = new GraphicsPath();
pthTop.AddLine(intLeft-1, intBottom-intHeight,
intLeft+20, intBottom-intHeight-10);
pthTop.AddLine(intLeft+55,intBottom-
intHeight-10,intLeft+35,
intBottom-intHeight);
objGraphics.FillPath(Brushes.LightSalmon,
pthTop);
// 绘制柱面左侧
GraphicsPath pthRight = new GraphicsPath();
pthRight.AddLine(intLeft+35,intBottom-
intHeight,intLeft+55,intBottom-
intHeight-10);
pthRight.AddLine(intLeft+55,
intBottom-15,intLeft+35,intBottom);
objGraphics.FillPath(Brushes.Firebrick,
pthRight);
//绘制标签
objGraphics.TranslateTransform(intLeft+15,
intBottom-intHeight - 30);
objGraphics.RotateTransform(300);
objGraphics.DrawString(Label,new
Font("Arial",10,FontStyle.Bold),
Brushes.Black,0,0);
objGraphics.ResetTransform();
}
示例3: Run
public static void Run()
{
// ExStart:DrawingUsingGraphicsPath
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages();
// Create an instance of BmpOptions and set its various properties
BmpOptions ImageOptions = new BmpOptions();
ImageOptions.BitsPerPixel = 24;
// Create an instance of FileCreateSource and assign it to Source property
ImageOptions.Source = new FileCreateSource(dataDir + "sample_1.bmp", false);
// Create an instance of Image and initialize an instance of Graphics
using (Image image = Image.Create(ImageOptions, 500, 500))
{
Graphics graphics = new Graphics(image);
graphics.Clear(Color.White);
// Create an instance of GraphicsPath and Instance of Figure, add EllipseShape, RectangleShape and TextShape to the figure
GraphicsPath graphicspath = new GraphicsPath();
Figure figure = new Figure();
figure.AddShape(new EllipseShape(new RectangleF(0, 0, 499, 499)));
figure.AddShape(new RectangleShape(new RectangleF(0, 0, 499, 499)));
figure.AddShape(new TextShape("Aspose.Imaging", new RectangleF(170, 225, 170, 100), new Font("Arial", 20), StringFormat.GenericTypographic));
graphicspath.AddFigures(new[] { figure });
graphics.DrawPath(new Pen(Color.Blue), graphicspath);
// Create an instance of HatchBrush and set its properties also Fill path by supplying the brush and GraphicsPath objects
HatchBrush hatchbrush = new HatchBrush();
hatchbrush.BackgroundColor = Color.Brown;
hatchbrush.ForegroundColor = Color.Blue;
hatchbrush.HatchStyle = HatchStyle.Vertical;
graphics.FillPath(hatchbrush, graphicspath);
image.Save();
Console.WriteLine("Processing completed successfully.");
}
// ExEnd:DrawingUsingGraphicsPath
}
示例4: PaintBorder
/// <summary>
/// Paints the border of the box
/// </summary>
/// <param name="g"></param>
private void PaintBorder(Graphics g, RectangleF rectangle, bool isFirst, bool isLast)
{
SmoothingMode smooth = g.SmoothingMode;
if (InitialContainer != null && !InitialContainer.AvoidGeometryAntialias && IsRounded)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
}
//Top border
if (!(string.IsNullOrEmpty(BorderTopStyle) || BorderTopStyle == CssConstants.None))
{
using (SolidBrush b = new SolidBrush(ActualBorderTopColor))
{
if (BorderTopStyle == CssConstants.Inset) b.Color = CssDrawingHelper.Darken(ActualBorderTopColor);
g.FillPath(b, CssDrawingHelper.GetBorderPath(CssDrawingHelper.Border.Top, this, rectangle, isFirst, isLast));
}
}
if (isLast)
{
//Right Border
if (!(string.IsNullOrEmpty(BorderRightStyle) || BorderRightStyle == CssConstants.None))
{
using (SolidBrush b = new SolidBrush(ActualBorderRightColor))
{
if (BorderRightStyle == CssConstants.Outset) b.Color = CssDrawingHelper.Darken(ActualBorderRightColor);
g.FillPath(b, CssDrawingHelper.GetBorderPath(CssDrawingHelper.Border.Right, this, rectangle, isFirst, isLast));
}
}
}
//Bottom border
if (!(string.IsNullOrEmpty(BorderBottomStyle) || BorderBottomStyle == CssConstants.None))
{
using (SolidBrush b = new SolidBrush(ActualBorderBottomColor))
{
if (BorderBottomStyle == CssConstants.Outset) b.Color = CssDrawingHelper.Darken(ActualBorderBottomColor);
g.FillPath(b, CssDrawingHelper.GetBorderPath(CssDrawingHelper.Border.Bottom, this, rectangle, isFirst, isLast));
}
}
if (isFirst)
{
//Left Border
if (!(string.IsNullOrEmpty(BorderLeftStyle) || BorderLeftStyle == CssConstants.None))
{
using (SolidBrush b = new SolidBrush(ActualBorderLeftColor))
{
if (BorderLeftStyle == CssConstants.Inset) b.Color = CssDrawingHelper.Darken(ActualBorderLeftColor);
g.FillPath(b, CssDrawingHelper.GetBorderPath(CssDrawingHelper.Border.Left, this, rectangle, isFirst, isLast));
}
}
}
g.SmoothingMode = smooth;
}
示例5: Draw3DBorder
private void Draw3DBorder(Graphics g, float offset, Brush color, bool fill, float r, float percent)
{
int pen_width = 2;
float x = this.ClientRectangle.Left + (pen_width / 2) + offset;
float y = this.ClientRectangle.Top + (pen_width / 2) + offset;
float w = (this.ClientRectangle.Width - (pen_width / 2 + 2 + offset * 2)) * percent;
float h = this.ClientRectangle.Height - (pen_width / 2 + 2 + offset * 2);
Pen pen = new Pen(color, (float)pen_width);
GraphicsPath path = new GraphicsPath();
if (w < 2 * r) {
w = 2 * r;
}
path.AddLine(x + r, y, x + (w - r * 2), y);
path.AddArc(x + w - r * 2, y, r * 2, r * 2, 270, 90);
path.AddLine(x + w, y + r, x + w, y + h - r * 2);
path.AddArc(x + w - r * 2, y + h - r * 2, r * 2, r * 2, 0, 90);
path.AddLine(x + w - r * 2, y + h, x + r, y + h);
path.AddArc(x, y + h - r * 2, r * 2, r * 2, 90, 90);
path.AddLine(x, y + h - r * 2, x, y + r);
path.AddArc(x, y, r * 2, r * 2, 180, 90);
path.CloseFigure();
g.SmoothingMode = SmoothingMode.AntiAlias;
if (fill) {
g.FillPath(color, path);
} else {
g.DrawPath(pen, path);
}
}
示例6: OnPaint
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);
}
示例7: DrawBackground
/// <summary>
/// Draws the background for the control
/// using the background image and the
/// BaseColor.
/// </summary>
/// <param name="g">The graphics object used in the paint event.</param>
private void DrawBackground(Graphics g)
{
if (this.ButtonStyle == Style.Flat && this.mButtonState == State.None) { return; }
int alpha = (mButtonState == State.Pressed) ? 204 : 127;
Rectangle r = this.ClientRectangle;
r.Width--; r.Height--;
using (GraphicsPath rr = RoundRect(r, CornerRadius, CornerRadius, CornerRadius, CornerRadius))
{
using (SolidBrush sb = new SolidBrush(this.BaseColor))
{
g.FillPath(sb, rr);
}
SetClip(g);
if (this.BackImage != null) { g.DrawImage(this.BackImage, this.ClientRectangle); }
g.ResetClip();
using (SolidBrush sb = new SolidBrush(Color.FromArgb(alpha, this.ButtonColor)))
{
g.FillPath(sb, rr);
}
}
}
示例8: FillDualGradPath
public void FillDualGradPath(Graphics g, Color Col1, Color Col2, Rectangle rect, GraphicsPath gp, GradientAlignment align)
{
SmoothingMode stored = g.SmoothingMode;
ColorBlend Blend = new ColorBlend();
g.SmoothingMode = SmoothingMode.HighQuality;
LinearGradientBrush PathGradient;
switch (align)
{
case GradientAlignment.Vertical:
PathGradient = new LinearGradientBrush(new Point(rect.X, rect.Y), new Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black);
Blend.Positions = new[]{
0,
1 / 2f,
1
};
Blend.Colors = new[]{
Col1,
Col2,
Col1
};
PathGradient.InterpolationColors = Blend;
g.FillPath(PathGradient, gp);
break;
case GradientAlignment.Horizontal:
PathGradient = new LinearGradientBrush(new Point(rect.X, rect.Y), new Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black);
Blend.Positions = new[]{
0,
1 / 2f,
1
};
Blend.Colors = new[]{
Col1,
Col2,
Col1
};
PathGradient.InterpolationColors = Blend;
PathGradient.RotateTransform(0);
g.FillPath(PathGradient, gp);
break;
}
g.SmoothingMode = stored;
}
示例9: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
G = e.Graphics;
base.OnPaint(e);
G.Clear(Parent.BackColor);
if (Enabled)
{
using (SolidBrush Back = new SolidBrush(Color.FromArgb(34, 34, 33)))
{
G.FillPath(Back, Helpers.RoundRect(new Rectangle(0, 0, 16, 16), 1));
}
using (Pen Border = new Pen(Color.FromArgb(33, 33, 32)))
{
G.DrawPath(Border, Helpers.RoundRect(new Rectangle(0, 0, 16, 16), 1));
}
using (SolidBrush TextBrush = new SolidBrush(Color.FromArgb(220, 220, 219)))
{
using (Font TextFont = new Font("Segoe UI", 9))
{
G.DrawString(Text, TextFont, TextBrush, new Point(22, 0));
}
}
if (Checked)
{
using (SolidBrush TextBrush = new SolidBrush(Color.FromArgb(220, 220, 219)))
{
using (Font TextFont = new Font("Marlett", 12))
{
G.DrawString("b", TextFont, TextBrush, new Point(-2, 1));
}
}
}
}
else
{
using (SolidBrush Back = new SolidBrush(Color.FromArgb(37, 37, 36)))
{
G.FillPath(Back, Helpers.RoundRect(new Rectangle(0, 0, 16, 16), 1));
}
using (Pen Border = new Pen(Color.FromArgb(36, 36, 35)))
{
G.DrawPath(Border, Helpers.RoundRect(new Rectangle(0, 0, 16, 16), 1));
}
using (SolidBrush TextBrush = new SolidBrush(Color.FromArgb(130, 130, 129)))
{
using (Font TextFont = new Font("Segoe UI", 9))
{
G.DrawString(Text, TextFont, TextBrush, new Point(22, 0));
}
}
if (Checked)
{
using (SolidBrush TextBrush = new SolidBrush(Color.FromArgb(130, 130, 129)))
{
using (Font TextFont = new Font("Marlett", 12))
{
G.DrawString("b", TextFont, TextBrush, new Point(-2, 1));
}
}
}
}
}
示例10: Render
internal override void Render(Graphics g)
{
UpdateGP();
Brush brush;
if (anchored)
brush = new HatchBrush(HatchStyle.HorizontalBrick,Color.DarkGray,fillcolor);
else
brush = new SolidBrush(fillcolor);
g.FillPath(brush,gp);
g.DrawPath(Pens.Black,gp);
brush.Dispose();
Point cg = CG;
g.FillRectangle(Brushes.Black,cg.X-30,cg.Y-30,61,61);
}
示例11: PaintBackground
/// <summary>
/// Paints the background of the box
/// </summary>
/// <param name="g"></param>
private void PaintBackground(Graphics g, RectangleF rectangle)
{
//HACK: Background rectangles are being deactivated when justifying text.
if (ContainingBlock.TextAlign == CssConstants.Justify) return;
GraphicsPath roundrect = null;
Brush b = null;
SmoothingMode smooth = g.SmoothingMode;
if (IsRounded)
{
roundrect = CssDrawingHelper.GetRoundRect(rectangle, ActualCornerNW, ActualCornerNE, ActualCornerSE, ActualCornerSW);
}
if (BackgroundGradient != CssConstants.None && rectangle.Width > 0 && rectangle.Height > 0)
{
b = new LinearGradientBrush(rectangle, ActualBackgroundColor, ActualBackgroundGradient, ActualBackgroundGradientAngle);
}
else
{
b = new SolidBrush(ActualBackgroundColor);
}
if (InitialContainer != null && !InitialContainer.AvoidGeometryAntialias && IsRounded)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
}
if (roundrect != null)
{
g.FillPath(b, roundrect);
}
else
{
g.FillRectangle(b, rectangle);
}
g.SmoothingMode = smooth;
if (roundrect != null) roundrect.Dispose();
if (b != null) b.Dispose();
}
示例12: DrawGlow
/// <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();
}
示例13: DrawHighlight
/// <summary>
/// Draws the Highlight over the top of the
/// control using the HightlightColor.
/// </summary>
/// <param name="g">The graphics object used in the paint event.</param>
private void DrawHighlight(Graphics g)
{
if (this.ButtonStyle == Style.Flat && this.mButtonState == State.None) { return; }
int alpha = (mButtonState == State.Pressed) ? 60 : 150;
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height / 2);
using (GraphicsPath r = RoundRect(rect, CornerRadius, CornerRadius, 0, 0))
{
using (LinearGradientBrush lg = new LinearGradientBrush(r.GetBounds(),
Color.FromArgb(alpha, this.HighlightColor),
Color.FromArgb(alpha / 3, this.HighlightColor),
LinearGradientMode.Vertical))
{
g.FillPath(lg, r);
}
}
}
示例14: DrawData
// REAL MAGIC HERE! y- B-
private void DrawData(Graphics g, float Xunit, float Yunit,int xstart )
{
PeptideMW PMW = new PeptideMW(PeptideSequence);
float[] Bs = PMW.GetPepFragmentBValues();
float[] Ys = PMW.GetPepFragmentYValues();
bool bPhos = PMW.IsPhosphorylation();
int Count = SpectrumData.Count;
int i = 0;
for (i = 0; i < Count; i++)
{
float mz = ((MZintensitiy )SpectrumData[i]).mz ;
float intensity = ((MZintensitiy )SpectrumData[i]).intensity ;
float x = (mz - xstart)*Xunit + NETAREALEFTMARGIN ;
float y;
if (bZoomOut)
{
if (intensity * 100 / MaxIntensitiy > DisplayMaxY)
{
y = NETAREATOPMARGIN ;
}
else
{
y = HEIGHT - NETAREABOTTOMMARGIN - intensity * 100 * Yunit / MaxIntensitiy;
}
}
else
y = HEIGHT - NETAREABOTTOMMARGIN - intensity * 100 * Yunit / MaxIntensitiy;
Pen dataPen = new Pen (Brushes.Black ,1);
Pen BLinePen = new Pen(Brushes.Blue, 2);
Pen YLinePen = new Pen(Brushes.Red, 2);
Pen ALinePen = new Pen (Brushes.Green ,2);
Pen MLinePen = new Pen(Brushes.Gray , 2);
Font Numberfont = new Font("Arial", 9, FontStyle.Regular);
if (y < HEIGHT - NETAREABOTTOMMARGIN -20 && bShowLabel )
{
string strAnn = GetAnnotation(SpectrumData,i, Bs, Ys,PrecursorMZ,int.Parse (ChargeState ),bPhos );
if (strAnn.StartsWith("(b"))
{
g.DrawLine(BLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
g.DrawString(strAnn, Numberfont, Brushes.Blue , new PointF(x, y));
}
else if (strAnn.StartsWith("(y"))
{
g.DrawLine(YLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y));
}
else if (strAnn.StartsWith("(a"))
{
g.DrawLine(ALinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
g.DrawString(strAnn, Numberfont, Brushes.Green, new PointF(x, y));
}
else if (strAnn.StartsWith("(M") && y < HEIGHT - NETAREABOTTOMMARGIN -100)
{
g.DrawLine(MLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
g.DrawString(strAnn, Numberfont, Brushes.Gray , new PointF(x, y));
}
else
{
g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
}
//g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y));
}
else
g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
if (intensity == MaxIntensitiy)
{
//peak value point
GraphicsPath p = new GraphicsPath();
p.AddLine(x, (float)HEIGHT - NETAREABOTTOMMARGIN, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength);
p.AddLine(x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength, x - XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength);
p.CloseFigure();
g.FillPath(Brushes.Red, p);
g.DrawString(mz.ToString(), Numberfont, Brushes.Red, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN);
}
}
}
示例15: RoundedRect
public static void RoundedRect(Graphics aGraph, Rectangle aRect, int aR, Pen aPen, Brush aBrush)
{
// First, build path:
GraphicsPath lPath = new GraphicsPath();
lPath.StartFigure();
lPath.AddArc(aRect.Left, aRect.Top, aR, aR, 180, 90);
lPath.AddArc(aRect.Left + aRect.Width - aR, aRect.Top, aR, aR, 270, 90);
lPath.AddArc(aRect.Left + aRect.Width - aR, aRect.Top + aRect.Height - aR, aR, aR, 0, 90);
lPath.AddArc(aRect.Left + 0, aRect.Top + aRect.Height - aR, aR, aR, 90, 90);
lPath.CloseFigure();
if (aBrush != null)
aGraph.FillPath(aBrush, lPath);
if (aPen != null)
aGraph.DrawPath(aPen, lPath);
}