本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.Dispose方法的具体用法?C# GraphicsPath.Dispose怎么用?C# GraphicsPath.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawPointerDown
private void DrawPointerDown(Graphics g)
{
Point[] points = new Point[] { new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1), new Point(ThumbBounds.Left, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), ThumbBounds.Location, new Point(ThumbBounds.Right - 1, ThumbBounds.Top), new Point(ThumbBounds.Right - 1, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1) };
GraphicsPath path = new GraphicsPath();
path.AddLines(points);
Region region = new Region(path);
g.Clip = region;
if (ThumbState == 3 || !base.Enabled)
ControlPaint.DrawButton(g, ThumbBounds, ButtonState.All);
else
g.Clear(SystemColors.Control);
g.ResetClip();
region.Dispose();
path.Dispose();
Point[] pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
g.DrawLines(SystemPens.ControlLightLight, pointArray2);
pointArray2 = new Point[] { points[3], points[4], points[5] };
g.DrawLines(SystemPens.ControlDarkDark, pointArray2);
points[0].Offset(0, -1);
points[1].Offset(1, 0);
points[2].Offset(1, 1);
points[3].Offset(-1, 1);
points[4].Offset(-1, 0);
points[5] = points[0];
pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
g.DrawLines(SystemPens.ControlLight, pointArray2);
pointArray2 = new Point[] { points[3], points[4], points[5] };
g.DrawLines(SystemPens.ControlDark, pointArray2);
}
示例2: BitmapFromText
public static Bitmap BitmapFromText(string text, Font f, Color col, Color glowCol, Rectangle rect, float glowScale)
{
Bitmap bm = new Bitmap((int)(rect.Width / glowScale), (int)(rect.Height / glowScale));
GraphicsPath pth = new GraphicsPath();
pth.AddString(text, f.FontFamily, (int)f.Style, f.Size, new Point(rect.Left, rect.Top), StringFormat.GenericTypographic);
Graphics g = Graphics.FromImage(bm);
Matrix mx = new Matrix(1.0f / glowScale, 0, 0, 1.0f / glowScale, -(1.0f / glowScale), -(1.0f / glowScale));
g.SmoothingMode = SmoothingMode.AntiAlias;
g.Transform = mx;
Pen p = new Pen(glowCol, 3);
g.DrawPath(p, pth);
g.FillPath(new SolidBrush(glowCol), pth);
g.Dispose();
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
Graphics g2 = Graphics.FromImage(bmp);
g2.Transform = new Matrix(1, 0, 0, 1, 50, 50);
g2.SmoothingMode = SmoothingMode.AntiAlias;
g2.InterpolationMode = InterpolationMode.HighQualityBicubic;
g2.DrawImage(bm, rect, 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel);
g2.FillPath(new SolidBrush(col), pth);
pth.Dispose();
return bmp;
}
示例3: FormSplashScreen_Paint
void FormSplashScreen_Paint(object sender, PaintEventArgs e) {
if ( Natives.CanUseAero ) {
Natives.FillBlackRegion(e.Graphics, ClientRectangle);
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
var gDevPath = new GraphicsPath();
var gLogPath = new GraphicsPath();
var brush = new SolidBrush(Color.FromArgb(0x99, Color.Black));
gDevPath.AddString(_devList, DrawingFont.FontFamily, (int)FontStyle.Regular, Constants.DEV_TEXT_SIZE,
new Point(Constants.LOGO_WIDTH + Constants.PADDING, Constants.TEXT_HEIGHT + Constants.PADDING), StringFormat.GenericDefault);
gLogPath.AddString(LogMessage, DrawingFont.FontFamily, (int)FontStyle.Bold, Constants.LOG_TEXT_SIZE, new Point(Constants.PADDING, Height - 65 - Constants.PADDING), StringFormat.GenericDefault);
e.Graphics.DrawImage(HammerBitmap, Constants.PADDING, Constants.PADDING, Constants.LOGO_WIDTH, Constants.LOGO_HEIGHT);
e.Graphics.DrawImage(MCForgeBitmap, Constants.LOGO_WIDTH + Constants.PADDING, Constants.PADDING, Constants.TEXT_WIDTH, Constants.TEXT_HEIGHT);
e.Graphics.FillPath(brush, gDevPath);
e.Graphics.FillPath(brush, gLogPath);
gDevPath.Dispose();
gLogPath.Dispose();
brush.Dispose();
}
}
示例4: Draw
/// <summary>
/// The graphics device and clip rectangle are in the parent coordinates.
/// </summary>
/// <param name="g"></param>
/// <param name="clipRectangle"></param>
/// <param name="symbol">The symbol to use for drawing.</param>
public void Draw(Graphics g, Rectangle clipRectangle, ISymbol symbol)
{
Color topLeft;
Color bottomRight;
if (_isSelected)
{
topLeft = _selectionColor.Darker(.3F);
bottomRight = _selectionColor.Lighter(.3F);
}
else
{
topLeft = _backColor.Lighter(.3F);
bottomRight = _backColor.Darker(.3F);
}
LinearGradientBrush b = new LinearGradientBrush(_bounds, topLeft, bottomRight, LinearGradientMode.ForwardDiagonal);
GraphicsPath gp = new GraphicsPath();
gp.AddRoundedRectangle(Bounds, _roundingRadius);
g.FillPath(b, gp);
gp.Dispose();
b.Dispose();
Matrix old = g.Transform;
Matrix shift = g.Transform;
shift.Translate(_bounds.Left + _bounds.Width / 2, _bounds.Top + _bounds.Height / 2);
g.Transform = shift;
if (symbol != null)
{
OnDrawSymbol(g, symbol);
}
g.Transform = old;
}
示例5: 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();
}
示例6: GetTopRoundedRect
//public static GraphicsPath GetBottomRoundRect(RectangleF r, int offset)
//{
// int left = Math.Min((int)r.Left, (int)r.Right);
// int right = Math.Max((int)r.Left, (int)r.Right);
// int top = Math.Min((int)r.Top, (int)r.Bottom);
// int bottom = Math.Max((int)r.Top, (int)r.Bottom);
// GraphicsPath path = new GraphicsPath();
// path.AddLine(r.Right, r.Top, r.Right, r.Top);
// path.AddArc(right - offset, bottom - offset, offset, offset, 0.0f, 90.0f);
// path.AddArc(left, bottom - offset, offset, offset, 90.0f, 90.0f);
// path.AddLine(r.Left, r.Top, r.Left, r.Top);
// path.CloseFigure();
// return path;
//}
public static GraphicsPath GetTopRoundedRect(RectangleF r, int offset)
{
int left = Math.Min((int)r.Left, (int)r.Right);
int right = Math.Max((int)r.Left, (int)r.Right);
int top = Math.Min((int)r.Top, (int)r.Bottom);
int bottom = Math.Max((int)r.Top, (int)r.Bottom);
GraphicsPath path = new GraphicsPath();
try
{
path.AddArc(right - offset, top, offset, offset, 270.0f, 90.0f);
path.AddLine(r.Right, r.Bottom, r.Right, r.Bottom);
path.AddLine(r.Left, r.Bottom, r.Left, r.Bottom);
path.AddArc(left, top, offset, offset, 180.0f, 90.0f);
path.CloseFigure();
return path;
}
catch
{
path.Dispose();
throw;
}
}
示例7: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics G = e.Graphics;
LinearGradientBrush linearGradientBrush1 = new LinearGradientBrush(//创建线性渐变画刷
new Point(0, 0),new Point(20, 20), //渐变起始点和终止点
Color.Yellow,Color.Blue); //渐变起始颜色和终止颜色
G.FillRectangle(linearGradientBrush1, new Rectangle(0, 0, 150, 150));//绘制矩形
LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(//创建线性渐变画刷
new Rectangle(0, 0, 20, 20), //渐变所在矩形
Color.Yellow, Color.Blue, 60f); //渐变起始颜色、终止颜色以及渐变方向
linearGradientBrush2.WrapMode = WrapMode.TileFlipXY;
G.FillRectangle(linearGradientBrush2, new Rectangle(150, 0, 150, 150));//绘制矩形
GraphicsPath graphicsPath1 = new GraphicsPath(); //创建绘制路径
graphicsPath1.AddArc(new Rectangle(0, 150, 100, 100), 90, 180);//向路径中添加半左圆弧
graphicsPath1.AddArc(new Rectangle(150, 150, 100, 100), 270, 180);//向路径中添加半右圆弧
graphicsPath1.CloseFigure(); //闭合路径
PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath1);//创建路径渐变画刷
pathGradientBrush.CenterColor = Color.Yellow; //指定画刷中心颜色
pathGradientBrush.SurroundColors = new Color[] { Color.Blue };//指定画刷周边颜色
pathGradientBrush.CenterPoint = new PointF(125, 200); //指定画刷中心点坐标
G.SmoothingMode = SmoothingMode.AntiAlias; //消锯齿
G.FillPath(pathGradientBrush, graphicsPath1); //利用画刷填充路径
G.DrawPath(new Pen(Color.Lime, 3f), graphicsPath1); //绘制闭合路径曲线
linearGradientBrush1.Dispose();
linearGradientBrush2.Dispose();
graphicsPath1.Dispose();
pathGradientBrush.Dispose();
}
示例8: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
Rectangle bounds = new Rectangle(0, 0, Width, Height);
bounds.Width = Width - 1;
bounds.Height -= 1;
int arcSize = 10;
GraphicsPath path = new GraphicsPath();
AddRoundedRectangle(path, bounds, arcSize);
using (SolidBrush brush = new SolidBrush(Renderer.BackColor))
{
g.FillPath(brush, path);
}
using (Pen pen = new Pen(Renderer.BorderPenColor))
{
g.DrawPath(pen, path);
}
path.Dispose();
}
示例9: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics myGraphics = e.Graphics;
Pen myPen = new Pen(Color.Black, 1.0f);
GraphicsPath gp = new GraphicsPath();
Matrix RotationTransform;
float centerX = this.Size.Width / 2f;
float centerY = this.Size.Height / 2f;
gp.AddPolygon(new PointF[] {
new PointF(centerX, centerY - 5),
new PointF(centerX-5, centerY + 5),
new PointF(centerX+5, centerY + 5)
});
RotationTransform = new Matrix(1, 0, 0, 1, 0, 0); // rotation matrix
PointF RotationPoint = new PointF(centerX, centerY); // rotation point
RotationTransform.RotateAt(heading, RotationPoint);
gp.Transform(RotationTransform);
myGraphics.FillPath(myPen.Brush, gp);
myGraphics.DrawPath(myPen, gp);
myPen.Dispose();
gp.Dispose();
}
示例10: WarpPath
public static void WarpPath(GraphicsPath path, PointF[] destPoints, RectangleF srcRect, Matrix matrix = null, WarpMode warpMode = WarpMode.Perspective, float flatness = 0.25f)
{
if (path.PointCount == 0)
return;
path.Flatten(matrix, flatness);
var pathData = path.PathData;
var pnts = path.PathPoints;
var srcPoints = new PointF[] { new PointF(srcRect.Left, srcRect.Top),
new PointF(srcRect.Right, srcRect.Top),
new PointF(srcRect.Left, srcRect.Bottom),
new PointF(srcRect.Right, srcRect.Bottom) };
var count = pnts.Length;
float x1, y1;
int i;
if (warpMode == WarpMode.Perspective)
{
CalcProjectiveXformCoeffs(srcPoints, destPoints, out coeffs);
for (i = 0; i < count; i++)
{
x1 = pnts[i].X;
y1 = pnts[i].Y;
var factor = 1.0f / (coeffs[6] * x1 + coeffs[7] * y1 + 1.0f);
pnts[i].X = (float)(factor * (coeffs[0] * x1 + coeffs[1] * y1 + coeffs[2]));
pnts[i].Y = (float)(factor * (coeffs[3] * x1 + coeffs[4] * y1 + coeffs[5]));
}
}
else
{
CalcBilinearXformCoeffs(srcPoints, destPoints, out coeffs);
for (i = 0; i < count; i++)
{
x1 = pnts[i].X;
y1 = pnts[i].Y;
pnts[i].X = (float)(coeffs[0] * x1 + coeffs[1] * y1 + coeffs[2] * x1 * y1 + coeffs[3]);
pnts[i].Y = (float)(coeffs[4] * x1 + coeffs[5] * y1 + coeffs[6] * x1 * y1 + coeffs[7]);
}
}
GraphicsPath warpedPath = new GraphicsPath(pnts, pathData.Types);
if (warpedPath != null)
{
FillMode fm = path.FillMode;
path.Reset();
path.FillMode = fm;
path.AddPath(warpedPath, true);
warpedPath.Dispose();
}
}
示例11: HandlePaintEvent
public void HandlePaintEvent(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Point topLeft = new Point()
{
X = (_control.GetClientRectangleWidth() - _currentLength) / 2,
Y = (_control.GetClientRectangleHeight() - _currentLength) / 2
};
Point bottomRight = new Point()
{
X = (_control.GetClientRectangleWidth() + _currentLength) / 2,
Y = (_control.GetClientRectangleHeight() + _currentLength) / 2
};
//Only update brush if previousLength != currentLength. When control is resized, keep the current brush if tick event hasn't happened yet
if (_previousLength != _currentLength)
{
if (_currentBrush == null)
_currentBrush = new HatchBrush(HatchStyle.Percent90, Color.Red);
else if (_currentBrush is HatchBrush)
{
_currentBrush.Dispose();
_currentBrush = new LinearGradientBrush(topLeft, bottomRight, Color.Green, Color.GreenYellow);
}
else if (_currentBrush is LinearGradientBrush)
{
// Create the path (which determines the shape of the gradient).
GraphicsPath path = new GraphicsPath();
path.AddRectangle(new Rectangle(topLeft.X, bottomRight.Y, _currentLength, _currentLength));
_currentBrush.Dispose();
_currentBrush = new PathGradientBrush(path);
((PathGradientBrush)_currentBrush).WrapMode = WrapMode.Tile;
((PathGradientBrush)_currentBrush).SurroundColors = new Color[] { Color.White };
((PathGradientBrush)_currentBrush).CenterColor = Color.Blue;
path.Dispose();
}
else
{
_currentBrush.Dispose();
_currentBrush = new HatchBrush(HatchStyle.Percent90, Color.Red);
}
}
Pen drawingPen = new Pen(Color.Black, 2);
g.DrawRectangle(drawingPen, topLeft.X, topLeft.Y, _currentLength, _currentLength);
g.FillRectangle(_currentBrush, topLeft.X, topLeft.Y, _currentLength, _currentLength);
//Free memory
drawingPen.Dispose();
//Update previousLength
_previousLength = _currentLength;
}
示例12: Form2_Load
private void Form2_Load(object sender, EventArgs e)
{
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(pic1.ClientRectangle);
Region region = new Region(gp);
pic1.Region = region;
gp.Dispose();
region.Dispose();
}
示例13: Draw
public void Draw(Graphics g, Color c)
{
GraphicsPath path = new GraphicsPath();
path.AddPolygon(m_HexagonPoints);
using (SolidBrush brush = new SolidBrush(c))
{
g.FillPath(brush, path);
}
path.Dispose();
}
示例14: OnDraw
/// <summary>
/// Handles the drawing code, extending it to include some outline content.
/// </summary>
/// <param name="g"></param>
/// <param name="scaleSize"></param>
protected override void OnDraw(Graphics g, double scaleSize)
{
base.OnDraw(g, scaleSize);
float dx = (float)(Size.Width * scaleSize / 2);
float dy = (float)(Size.Height * scaleSize / 2);
GraphicsPath gp = new GraphicsPath();
gp.AddRectangle(new RectangleF(-dx, -dy, 2F * dx, 2f * dy));
OnDrawOutline(g, scaleSize, gp);
gp.Dispose();
}
示例15: GetFigure
public Region GetFigure()
{
var path = new GraphicsPath();
path.AddPolygon(points);
var region = new Region(path);
path.Dispose();
return region;
}