本文整理汇总了C#中System.Drawing.Graphics.FillRegion方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.FillRegion方法的具体用法?C# Graphics.FillRegion怎么用?C# Graphics.FillRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.FillRegion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1_Paint
private void Form1_Paint (object sender, PaintEventArgs e)
{
gfx = e.Graphics;
if (shape1checkBox.Checked && (r1 != null))
gfx.FillRegion (Brushes.Red, r1);
if (shape2checkBox.Checked && (r2 != null))
gfx.FillRegion (Brushes.Green, r2);
if (shape3checkBox.Checked && (op != null))
gfx.FillRegion (Brushes.Blue, op);
}
示例2: PointDrawer
public PointDrawer(ref Graphics graph)
{
_graph = graph;
_graph.FillRegion(new SolidBrush(Color.White),_graph.Clip);
CurrentPos.X = (int) _graph.VisibleClipBounds.Width/2;
CurrentPos.Y = (int) _graph.VisibleClipBounds.Height/2;
Redraw(new Point(0,0));
}
示例3: DrawShapeOnGraphics
public override void DrawShapeOnGraphics(GraphicsPath shapeAsGraphicsPath, Graphics g)
{
styleToDecorate.DrawShapeOnGraphics(shapeAsGraphicsPath, g);
Region shapeAsRegion = new Region(shapeAsGraphicsPath);
RectangleF rr = shapeAsRegion.GetBounds(g);
CreateGradient(rr);
g.FillRegion(styleToDecorate.fillBrush_, shapeAsRegion);
}
示例4: FillRoundedRectangle
/// <summary>
/// Fill a rounded rectangle with the specified brush.
/// </summary>
/// <param name="g"></param>
/// <param name="roundRect"></param>
/// <param name="brush"></param>
public static void FillRoundedRectangle(Graphics g, RoundedRectangle roundRect, Brush brush)
{
Rectangle rectangleBorder;
rectangleBorder = new Rectangle(roundRect.Rectangle.X,
roundRect.Rectangle.Y,
roundRect.Rectangle.Width - 1,
roundRect.Rectangle.Height - 1);
RoundedRectangle roundToDraw = new RoundedRectangle(rectangleBorder, roundRect.RoundValue);
g.FillRegion(brush, new Region( roundToDraw.ToGraphicsPath() ));
}
示例5: Draw
public void Draw(Graphics graphics)
{
ReInitialize(graphics);
int innerRadius = (int)(_partitionControl.Owner.InnerRadius);
int outerRadius = (int)(_partitionControl.Owner.OuterRadius);
Color color;
if (_partitionControl.Partition.IsProtected)
color = Color.LightGoldenrodYellow;
else
color = Color.LightGray;
graphics.FillRegion(new SolidBrush(color), _region);
Font currentFont = _isSelected ? selectedFont : mountFont;
graphics.DrawString(
normalizeMountPoint(_partitionControl.Partition.GetMountPoints()),
currentFont,
new SolidBrush(Color.DarkBlue),
mountTextPoint
);
graphics.DrawString(
SizeFormatter.Format(_partitionControl.Partition.Size),
sizeFont,
new SolidBrush(Color.DarkBlue),
sizeTextPoint
);
if (_isSelected)
{
if (sharePath == null)
graphics.DrawString(Properties.Resources.noSharePath
+ sharePath,
SystemFonts.CaptionFont,
new SolidBrush(Color.Red),
_partitionControl.Owner.Center.X - outerRadius,
_partitionControl.Owner.Center.Y + outerRadius);
else
graphics.DrawString(Properties.Resources.openInExplorer
+ sharePath,
SystemFonts.CaptionFont,
new SolidBrush(Color.Red),
_partitionControl.Owner.Center.X - outerRadius,
_partitionControl.Owner.Center.Y + outerRadius);
}
}
示例6: doDraw
private void doDraw(Graphics g)
{
Region baseR = new Region(new Rectangle(0, 0, this.pbParent.Width, this.pbParent.Height));
foreach (KeyValuePair<String, drawObject> item in drawObjects) {
if (item.Key.Substring(0, 5) == "table") {
baseR.Exclude(Rectangle.Round(item.Value.loc));
}
}
g.FillRegion(new SolidBrush(this.pbParent.BackColor), baseR);
foreach (KeyValuePair<String, drawObject> item in drawObjects) {
item.Value.draw(g);
}
}
示例7: DrawRegionOperations
private void DrawRegionOperations()
{
g = this.CreateGraphics();
// Создаем два прямоугольника
Rectangle rect1 = new Rectangle(100, 100, 120, 120);
Rectangle rect2 = new Rectangle(70, 70, 120, 120);
// Создаем два региона
Region rgn1 = new Region(rect1);
Region rgn2 = new Region(rect2);
// рисуем прямоугольники
g.DrawRectangle(Pens.Green, rect1);
g.DrawRectangle(Pens.Black, rect2);
// обработаем перечисление и вызовем соответствующий метод
switch (rgnOperation)
{
case RegionOperations.Union:
rgn1.Union(rgn2);
break;
case RegionOperations.Complement:
rgn1.Complement(rgn2);
break;
case RegionOperations.Intersect:
rgn1.Intersect(rgn2);
break;
case RegionOperations.Exclude:
rgn1.Exclude(rgn2);
break;
case RegionOperations.Xor:
rgn1.Xor(rgn2);
break;
default:
break;
}
// Рисуем регион
g.FillRegion(Brushes.Blue, rgn1);
g.Dispose();
}
示例8: DrawRegionOperation
void DrawRegionOperation()
{
g = this.CreateGraphics();
Rectangle rect1 = new Rectangle(100, 100, 120, 120);
Rectangle rect2 = new Rectangle(70, 70, 120, 120);
Region rgn1 = new Region(rect1);
Region rgn2 = new Region(rect2);
g.DrawRectangle(Pens.Blue, rect1);
g.DrawRectangle(Pens.Red, rect2);
switch(rgnOperation)
{
case RegionOperation.Union:
rgn1.Union(rgn2);
break;
case RegionOperation.Complement:
rgn1.Complement(rgn2);
break;
case RegionOperation.Intersect:
rgn1.Intersect(rgn2);
break;
case RegionOperation.Exclude:
rgn1.Exclude(rgn2);
break;
case RegionOperation.Xor:
rgn1.Xor(rgn2);
break;
default:
break;
}
g.FillRegion(Brushes.Tomato, rgn1);
g.Dispose();
}
示例9: DrawDocumentTab
public static void DrawDocumentTab(Graphics g, Rectangle rect, Color backColorBegin, Color backColorEnd, Color edgeColor, TabDrawType tabType, bool closed)
{
GraphicsPath path = null;
Region region = null;
Brush brush = null;
Pen pen = null;
brush = new LinearGradientBrush(rect, backColorBegin, backColorEnd, LinearGradientMode.Vertical);
pen = new Pen(edgeColor, 1.0F);
path = new GraphicsPath();
if (tabType == TabDrawType.First)
{
path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
}
else
{
if (tabType == TabDrawType.Active)
{
path.AddLine(rect.Left + 1, rect.Bottom + 1, rect.Left + rect.Height, rect.Top + 2);
path.AddLine(rect.Left + rect.Height + 4, rect.Top, rect.Right - 3, rect.Top);
path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
}
else
{
path.AddLine(rect.Left, rect.Top + 6, rect.Left + 4, rect.Top + 2);
path.AddLine(rect.Left + 8, rect.Top, rect.Right - 3, rect.Top);
path.AddLine(rect.Right - 1, rect.Top + 2, rect.Right - 1, rect.Bottom + 1);
path.AddLine(rect.Right - 1, rect.Bottom + 1, rect.Left, rect.Bottom + 1);
}
}
region = new Region(path);
g.FillRegion(brush, region);
g.DrawPath(pen, path);
}
示例10: DrawTabFocusIndicator
private void DrawTabFocusIndicator(GraphicsPath tabpath, int index, Graphics graphics)
{
if (this._FocusTrack && this._TabControl.Focused && index == this._TabControl.SelectedIndex)
{
Brush focusBrush = null;
RectangleF pathRect = tabpath.GetBounds();
Rectangle focusRect = Rectangle.Empty;
switch (this._TabControl.Alignment)
{
case TabAlignment.Top:
focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Y, (int)pathRect.Width, 4);
focusBrush = new LinearGradientBrush(focusRect, this._FocusColor, SystemColors.Window, LinearGradientMode.Vertical);
break;
case TabAlignment.Bottom:
focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Bottom - 4, (int)pathRect.Width, 4);
focusBrush = new LinearGradientBrush(focusRect, SystemColors.ControlLight, this._FocusColor, LinearGradientMode.Vertical);
break;
case TabAlignment.Left:
focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Y, 4, (int)pathRect.Height);
focusBrush = new LinearGradientBrush(focusRect, this._FocusColor, SystemColors.ControlLight, LinearGradientMode.Horizontal);
break;
case TabAlignment.Right:
focusRect = new Rectangle((int)pathRect.Right - 4, (int)pathRect.Y, 4, (int)pathRect.Height);
focusBrush = new LinearGradientBrush(focusRect, SystemColors.ControlLight, this._FocusColor, LinearGradientMode.Horizontal);
break;
}
// Ensure the focus stip does not go outside the tab
Region focusRegion = new Region(focusRect);
focusRegion.Intersect(tabpath);
graphics.FillRegion(focusBrush, focusRegion);
focusRegion.Dispose();
focusBrush.Dispose();
}
}
示例11: PaintClient
//.........这里部分代码省略.........
Coordinates minCoords = PixToCoords(0, 0, z);
Coordinates maxCoords = PixToCoords(ClientSize.Width, ClientSize.Height, z);
#region Draw Coordinates (Part I: Gridlines)
float lastTickNS = 0, firstTickEW = 0, lastTickEW = 0, firstTickNS = 0;
RectangleF mapRect = new RectangleF(), insideGutter = new RectangleF();
Region coordGutter = null;
string precision = "";
if (DrawCoords)
{
g.SmoothingMode = SmoothingMode.Default;
if (mCoordTickDelta >= 1)
precision = "0";
else if (mCoordTickDelta >= 0.1)
precision = "0.0";
else
precision = "0.00";
lastTickNS = (float)(Math.Floor(minCoords.NS / mCoordTickDelta) * mCoordTickDelta);
firstTickEW = (float)(Math.Floor(minCoords.EW / mCoordTickDelta) * mCoordTickDelta);
lastTickEW = (float)(Math.Ceiling(maxCoords.EW / mCoordTickDelta) * mCoordTickDelta);
firstTickNS = (float)(Math.Ceiling(maxCoords.NS / mCoordTickDelta) * mCoordTickDelta);
mapRect = new RectangleF(coordPadX, coordPadY,
ClientSize.Width - 2 * coordPadX, ClientSize.Height - 2 * coordPadY);
insideGutter = new RectangleF(
coordPadX + CoordGutterSize,
coordPadY + CoordGutterSize,
ClientSize.Width - 2 * (CoordGutterSize + coordPadX),
ClientSize.Height - 2 * (CoordGutterSize + coordPadY));
coordGutter = new Region(mapRect);
coordGutter.Xor(insideGutter);
g.FillRegion(CoordGutterFill, coordGutter);
// Draw Gridlines
for (float ns = firstTickNS, ew = firstTickEW;
ns <= lastTickNS || ew <= lastTickEW;
ns += mCoordTickDelta, ew += mCoordTickDelta)
{
PointF pos = CoordsToPix(ns, ew, z);
if (pos.Y > insideGutter.Top && pos.Y < insideGutter.Bottom)
{
// Draw horizontal NS gridline
g.DrawLine(CoordGridline, CoordGutterSize + coordPadX, pos.Y,
ClientSize.Width - CoordGutterSize - coordPadX - 1, pos.Y);
}
if (pos.X > insideGutter.Left && pos.X < insideGutter.Right)
{
// Draw vertical EW gridline
g.DrawLine(CoordGridline, pos.X, CoordGutterSize + coordPadY,
pos.X, ClientSize.Height - CoordGutterSize - coordPadY - 1);
}
}
}
#endregion
#region Draw Locations
mHotspots.Clear();
float z2 = (float)(Math.Pow(z / ZoomBase, 0.25));
if (ShowLocations)
{
g.SmoothingMode = SmoothingMode.Default;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
Dictionary<LocationType, List<Location>> visibleLocations
示例12: RenderAreas
public void RenderAreas(RequestedTileInformation ti, Graphics g, Way way, RenderInfo ri)
{
bool drawOutline = true;
if (way.WayDataBlocks != null && way.WayDataBlocks.Count > 0)
{
foreach (Way.WayData wd in way.WayDataBlocks)
{
if (wd.DataBlock[0].CoordBlock.Count > 2)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddPolygon((from p in wd.DataBlock[0].CoordBlock select new System.Drawing.PointF((float)toRelTileX(p.Longitude, ti.X, ti.Zoom), (float)toRelTileY(p.Latitude, ti.Y, ti.Zoom))).ToArray());
if (wd.DataBlock.Count == 1)
{
g.FillPath(ri.Brush ?? new SolidBrush(Color.Black), gp);
}
else
{
GraphicsPath[] gpExclude = new GraphicsPath[wd.DataBlock.Count - 1];
for (int i = 0; i < gpExclude.Length; i++)
{
gpExclude[i] = new GraphicsPath();
Way.WayCoordinateBlock cb = wd.DataBlock[i + 1];
gpExclude[i].AddPolygon((from p in cb.CoordBlock select new System.Drawing.Point((int)toRelTileX(p.Longitude, ti.X, ti.Zoom), (int)toRelTileY(p.Latitude, ti.Y, ti.Zoom))).ToArray());
}
Region region = new Region(gp);
for (int i = 0; i < gpExclude.Length; i++)
{
region.Exclude(gpExclude[i]);
}
g.FillRegion(ri.Brush ?? new SolidBrush(Color.White), region);
for (int i = 0; i < gpExclude.Length; i++)
{
if (drawOutline && ri.Pen != null)
{
g.DrawPolygon(ri.Pen, gpExclude[i].PathPoints);
}
gpExclude[i].Dispose();
}
}
if (drawOutline && ri.Pen != null)
{
g.DrawPolygon(ri.Pen, gp.PathPoints);
}
}
}
}
}
}
示例13: PaintControl
private void PaintControl(Graphics g, Rectangle clipRectangle)
{
if ( g == null ) return;
if ( clipRectangle == null || clipRectangle.IsEmpty ) return;
float distRing1 = -(this.Width * 5) / 100; // 5%
float distRing2 = -(this.Width * 10) / 100; // 10%
float distArcRing = -(this.Width * 4) / 100; // 4%
float distInnerCircle = -(this.Width * 30) / 100; // 30%
RectangleF externalRing1 = RectangleF.Inflate(this.ClientRectangle, distRing1, distRing1);
RectangleF externalRing2 = RectangleF.Inflate(this.ClientRectangle, distRing2, distRing2);
RectangleF innerEllipseRing = RectangleF.Inflate(this.ClientRectangle, distInnerCircle, distInnerCircle);
RectangleF progressArcRing = RectangleF.Inflate(this.ClientRectangle, distArcRing, distArcRing);
using ( var smoothDrawing = new SmoothDrawing(g) )
using ( var progressCircleBrush = new SolidBrush(ProgressColor) )
{
// Set smooth drawing
g.SmoothingMode = SmoothingMode.AntiAlias;
// Paint inner circular progress
PaintProgress(g, progressCircleBrush, innerEllipseRing, externalRing2);
// Draw progress arc
using ( var penProgressArc = new Pen(ProgressColor, 3.0f) )
{
float progressAngle = 0;
if ( Style == ProgressBarStyle.Marquee )
progressAngle = 360 * CalcScaledValue(_marqueeValue);
else
progressAngle = 360 * ScaledValue;
try
{
g.DrawArc(penProgressArc, progressArcRing, 270, progressAngle);
}
catch { }
}
// Draw the circular extenal ring
using ( GraphicsPath p1 = new GraphicsPath() )
{
p1.AddEllipse(externalRing1);
using ( Region r1 = new Region(p1) )
using ( GraphicsPath p2 = new GraphicsPath() )
{
p2.AddEllipse(externalRing2);
r1.Exclude(p2);
g.FillRegion(Brushes.WhiteSmoke, r1);
}
}
// Draw the ring border
g.DrawEllipse(Pens.White, externalRing1);
g.DrawEllipse(Pens.White, externalRing2);
// Draw the inner Ellipse
g.FillEllipse(Brushes.WhiteSmoke, innerEllipseRing);
g.DrawEllipse(Pens.White, innerEllipseRing);
if ( Style != ProgressBarStyle.Marquee )
{
// Draw the the progress percent
using ( System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat() )
{
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
drawFormat.Alignment = StringAlignment.Center;
drawFormat.LineAlignment = StringAlignment.Center;
string percentString = this.Value.ToString() + "%";
g.DrawString(percentString, this.Font, progressCircleBrush, this.ClientRectangle, drawFormat);
}
}
}
}
示例14: Paint
public override void Paint(Graphics g) {
base.Paint(g);
g.SmoothingMode = SmoothingMode.HighQuality;
using (Pen pen = new Pen(lineColor, lineWidth)) {
SizeF titleSize = g.MeasureString(this.Title, ArtPalette.DefaultBoldFont, Rectangle.Width - 45);
titleSize.Height += 10; //add spacing
SizeF subtitleSize = g.MeasureString(this.Subtitle, ArtPalette.DefaultFont, Rectangle.Width - 45);
subtitleSize.Height += 5; //add spacing
if (this.Title == this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) subtitleSize = new SizeF(0, 0);
if ((int)titleSize.Height + (int)subtitleSize.Height != Rectangle.Height) {
headerHeight = (int)titleSize.Height + (int)subtitleSize.Height;
this.UpdateLabels();
}
GraphicsPath path = new GraphicsPath();
path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90);
path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y);
path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90);
path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10);
path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90);
path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height);
path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90);
path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10);
//shadow
if (ArtPalette.EnableShadows) {
Region darkRegion = new Region(path);
darkRegion.Translate(5, 5);
g.FillRegion(ArtPalette.ShadowBrush, darkRegion);
}
//background
g.FillPath(Brush, path);
using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) {
Region gradientRegion = new Region(path);
g.FillRegion(gradientBrush, gradientRegion);
}
if (!this.Collapsed) {
TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near);
StringFormat stringFormat = textStyle.StringFormat;
stringFormat.Trimming = StringTrimming.EllipsisWord;
stringFormat.FormatFlags = StringFormatFlags.LineLimit;
Rectangle rect;
const int verticalHeaderSpacing = 5;
Point separationLineStart = new Point(Rectangle.X + 25, Rectangle.Y + headerHeight - verticalHeaderSpacing);
Point separationLineEnd = new Point(Rectangle.X + Rectangle.Width - 25, Rectangle.Y + headerHeight - verticalHeaderSpacing);
using (LinearGradientBrush brush = new LinearGradientBrush(separationLineStart, separationLineEnd, Color.Black, Color.White)) {
using (Pen separationLinePen = new Pen(brush)) {
g.DrawLine(separationLinePen, separationLineStart, separationLineEnd);
}
}
for (int i = 0; i < this.labels.Count; i++) {
rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + headerHeight + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT);
g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat);
}
}
//the border
g.DrawPath(pen, path);
//the title
g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black,
new Rectangle(Rectangle.X + 25, Rectangle.Y + 5,
Rectangle.Width - 45, Rectangle.Height - 5 - (int)subtitleSize.Height));
//the subtitle
if (this.Title != this.Subtitle || string.IsNullOrEmpty(this.Subtitle)) {
g.DrawString(this.Subtitle, ArtPalette.DefaultFont, Brushes.Black,
new Rectangle(Rectangle.X + 25, Rectangle.Y + (int)titleSize.Height -5 ,
Rectangle.Width - 45, Rectangle.Height - 5));
}
//the material
foreach (IShapeMaterial material in Children)
material.Paint(g);
//the connectors
if (this.ShowConnectors) {
foreach (IConnector t in Connectors)
t.Paint(g);
}
}
}
示例15: RenderComboBoxBackground
private void RenderComboBoxBackground(Graphics g, Rectangle rect, Rectangle buttonRect)
{
Color color = base.Enabled ? base.BackColor : SystemColors.Control;
using (SolidBrush brush = new SolidBrush(color))
{
buttonRect.Inflate(-1, -1);
rect.Inflate(-1, -1);
using (Region region = new Region(rect))
{
region.Exclude(buttonRect);
region.Exclude(this.EditRect);
g.FillRegion(brush, region);
}
}
}