本文整理汇总了C#中System.Drawing.Brush类的典型用法代码示例。如果您正苦于以下问题:C# Brush类的具体用法?C# Brush怎么用?C# Brush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Brush类属于System.Drawing命名空间,在下文中一共展示了Brush类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InterestPointDrawer
public InterestPointDrawer(Bitmap background, SRegion[] regions)
: base(background, regions)
{
Color c = Color.FromArgb(125, Color.Red);
pen = new Pen(c);
brush = new SolidBrush(c);
}
示例2: ImageSplitter
public ImageSplitter(Image source, string format, int sizeX, int sizeY, int marginX, int marginY, Color background, Brush foreground)
{
_sizeX = sizeX;
_sizeY = sizeY;
_source = source;
_format = format;
_marginX = marginX;
_marginY = marginY;
_background = background;
_tileSizeX = _sizeX + 1;
_tileSizeY = _sizeY + 1;
_innerTilesX = (_source.Width - 1)/_sizeX;
_innerTilesY = (_source.Height - 1)/_sizeY;
_lastTileSizeX = (_source.Width - 1)%_sizeX + 1;
_lastTileSizeY = (_source.Height - 1)%_sizeY + 1;
_dirName = "out_" + _sizeX + "_" + _sizeY;
_combinedBitmap = new Bitmap(
_marginX + _innerTilesX * _tileSizeX + _lastTileSizeX,
_marginY + _innerTilesY * _tileSizeY + _lastTileSizeY);
_combinedG = Graphics.FromImage(_combinedBitmap);
_foreground = foreground;
}
示例3: DrawBrick
static protected void DrawBrick (Graphics graphics, Brush b1, Brush b2, Brush b3)
{
if (graphics == null) return;
graphics.FillPolygon (b1, brickPoints1);
graphics.FillPolygon (b2, brickPoints2);
graphics.FillPolygon (b3, brickPoints3);
}
示例4: FillRoundedRectangle
public static void FillRoundedRectangle(this Graphics g, Brush brush, RectangleF rect, float topLeftCorner, float topRightCorner, float bottomLeftCorner, float bottomRightCorner)
{
using(var gp = GraphicsUtility.GetRoundedRectangle(rect, topLeftCorner, topRightCorner, bottomLeftCorner, bottomRightCorner))
{
g.FillPath(brush, gp);
}
}
示例5: DrawStringML
private static void DrawStringML(this Graphics G, string Text, Font font, Brush brush, float x, ref float y, float mX)
{
string[] words = Text.Split(' ');
float tempX = x;
float totalSpace = mX - x;
SizeF measureWord = new SizeF(0, font.GetHeight());
float tempWordWidth = 0;
foreach (string word in words)
{
//measure word width (based in font size)
tempWordWidth = G.MeasureString(word + " ", font).Width;
measureWord.Width += tempWordWidth;
//check if the word fits in free line space
//if not then change line
if (measureWord.Width > totalSpace)
{
y += font.GetHeight();
tempX = x;
measureWord.Width = tempWordWidth;
}
G.DrawString(word + " ", font, brush, tempX, y);
tempX += tempWordWidth;
}
y += font.GetHeight();
}
示例6: Draw
public void Draw(Graphics gr, Pen pen, Brush backgroundBrush, Pen forePen)
{
//draw minus
gr.FillRectangle(backgroundBrush, rectangle);
gr.DrawRectangle(pen, rectangle);
gr.DrawLine(forePen, rectangle.Left + 2, rectangle.Top + rectangle.Height / 2, rectangle.Right - 2, rectangle.Top + rectangle.Height / 2);
}
示例7: Surface
public Surface()
{
ScreenRectangle = CaptureHelpers.GetScreenBounds();
ScreenRectangle0Based = CaptureHelpers.ScreenToClient(ScreenRectangle);
InitializeComponent();
using (MemoryStream cursorStream = new MemoryStream(Resources.Crosshair))
{
Cursor = new Cursor(cursorStream);
}
DrawableObjects = new List<DrawableObject>();
Config = new SurfaceOptions();
timerStart = new Stopwatch();
timerFPS = new Stopwatch();
borderPen = new Pen(Color.Black);
borderDotPen = new Pen(Color.White);
borderDotPen.DashPattern = new float[] { 5, 5 };
nodeBackgroundBrush = new SolidBrush(Color.White);
textFont = new Font("Verdana", 16, FontStyle.Bold);
infoFont = new Font("Verdana", 9);
textBackgroundBrush = new SolidBrush(Color.FromArgb(75, Color.Black));
textBackgroundPenWhite = new Pen(Color.FromArgb(50, Color.White));
textBackgroundPenBlack = new Pen(Color.FromArgb(150, Color.Black));
markerPen = new Pen(Color.FromArgb(200, Color.Red)) { DashStyle = DashStyle.Dash };
}
示例8: FillRoundRectangle
public static void FillRoundRectangle(Graphics g, Brush brush, Rectangle rect, int cornerRadius)
{
using (GraphicsPath path = CreateRoundedRectanglePath(rect, cornerRadius))
{
g.FillPath(brush, path);
}
}
示例9: Ellipse
public Ellipse(Pen pen, Brush brush, Point start, Point end)
{
Pen = pen;
Brush = brush;
Start = start;
End = end;
}
示例10: DrawRectangle
protected virtual void DrawRectangle(Pen outlinePen, Brush fillBrush)
{
if (fillBrush is LinearGradientBrush)
{
if ((rect.Width > 0) && (rect.Height > 0))
{
fillBrush = new LinearGradientBrush(rect,
args.settings.PrimaryColor,
args.settings.SecondaryColor,
args.settings.GradiantStyle);
//outlinePen = new Pen(fillBrush, args.settings.Width);
}
}
switch (args.settings.DrawMode)
{
case DrawMode.Outline:
g.DrawRectangle(outlinePen, rect);
break;
case DrawMode.Filled:
g.FillRectangle(fillBrush, rect);
break;
case DrawMode.Mixed:
g.FillRectangle(fillBrush, rect);
g.DrawRectangle(outlinePen, rect);
break;
case DrawMode.MixedWithSolidOutline:
g.FillRectangle(fillBrush, rect);
g.DrawRectangle(outlinePen, rect);
break;
}
}
示例11: NodeCursor
public NodeCursor(GameUI myGameUI, int myDepth)
: base(myGameUI, myDepth)
{
penCursorMini = new Pen(new SolidBrush(Color.FromArgb(180, Color.Wheat)), 2);
brushCellMarker = new SolidBrush(Color.FromArgb(40, Color.Yellow));
brushCursorMini = new SolidBrush(Color.FromArgb(200, Color.White));
}
示例12: WatermarkFileWithText
public void WatermarkFileWithText(string inputFile, string outputFile, string text, Font font, int x, int y,
bool renderOver,
Brush under, Brush over, StringAlignment xAlignment,
StringAlignment yAlignment)
{
Image imgPhoto = null;
Image outputPhoto = null;
try
{
try
{
imgPhoto = Image.FromFile(inputFile);
}
catch (Exception ex)
{
throw new InvalidOperationException("Failed to open file \"" + inputFile + "\"", ex);
}
WatermarkImageWithText(imgPhoto, ref outputPhoto, SmoothingMode.AntiAlias, text, font, x, y, renderOver,
under, over, xAlignment, yAlignment);
imgPhoto.Dispose();
imgPhoto = null;
outputPhoto.Save(outputFile, ImageFormat.Jpeg);
}
finally
{
if (imgPhoto != null) imgPhoto.Dispose();
if (outputPhoto != null) outputPhoto.Dispose();
}
}
示例13: BuildStatusMessageCellPainting
public static void BuildStatusMessageCellPainting(DataGridViewCellPaintingEventArgs e, GitRevision revision, Brush foreBrush, Font rowFont)
{
if (revision.BuildStatus != null)
{
Brush buildStatusForebrush = foreBrush;
switch (revision.BuildStatus.Status)
{
case BuildInfo.BuildStatus.Success:
buildStatusForebrush = Brushes.DarkGreen;
break;
case BuildInfo.BuildStatus.Failure:
buildStatusForebrush = Brushes.DarkRed;
break;
case BuildInfo.BuildStatus.InProgress:
buildStatusForebrush = Brushes.Blue;
break;
case BuildInfo.BuildStatus.Unstable:
buildStatusForebrush = Brushes.OrangeRed;
break;
case BuildInfo.BuildStatus.Stopped:
buildStatusForebrush = Brushes.Gray;
break;
}
var text = (string)e.FormattedValue;
e.Graphics.DrawString(text, rowFont, buildStatusForebrush, new PointF(e.CellBounds.Left, e.CellBounds.Top + 4));
}
}
示例14: BuildStatusImageColumnCellPainting
public static void BuildStatusImageColumnCellPainting(DataGridViewCellPaintingEventArgs e, GitRevision revision, Brush foreBrush, Font rowFont)
{
if (revision.BuildStatus != null)
{
Image buildStatusImage = null;
switch (revision.BuildStatus.Status)
{
case BuildInfo.BuildStatus.Success:
buildStatusImage = Resources.BuildSuccessful;
break;
case BuildInfo.BuildStatus.Failure:
buildStatusImage = Resources.BuildFailed;
break;
case BuildInfo.BuildStatus.Unknown:
buildStatusImage = Resources.BuildCancelled;
break;
case BuildInfo.BuildStatus.InProgress:
buildStatusImage = Resources.Icon_77;
break;
case BuildInfo.BuildStatus.Unstable:
buildStatusImage = Resources.bug;
break;
case BuildInfo.BuildStatus.Stopped:
buildStatusImage = Resources.BuildCancelled;
break;
}
if (buildStatusImage != null)
{
e.Graphics.DrawImage(buildStatusImage, new Rectangle(e.CellBounds.Left, e.CellBounds.Top + 4, 16, 16));
}
}
}
示例15: UpdateBackgroundBrush
/// ------------------------------------------------------------------------------------
/// <summary>
/// Updates the background brush.
/// </summary>
/// ------------------------------------------------------------------------------------
private void UpdateBackgroundBrush()
{
if (m_BackBrush != null)
m_BackBrush.Dispose();
m_BackBrush = null;
}