本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.GetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.GetBounds方法的具体用法?C# GraphicsPath.GetBounds怎么用?C# GraphicsPath.GetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.GetBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBoundsExample
public void GetBoundsExample(PaintEventArgs e)
{
// Create path number 1 and a Pen for drawing.
GraphicsPath myPath = new GraphicsPath();
Pen pathPen = new Pen(Color.Black, 1);
// Add an Ellipse to the path and Draw it (circle in start
// position).
myPath.AddEllipse(20, 20, 100, 100);
e.Graphics.DrawPath(pathPen, myPath);
// Get the path bounds for Path number 1 and draw them.
RectangleF boundRect = myPath.GetBounds();
e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
boundRect.X,
boundRect.Y,
boundRect.Height,
boundRect.Width);
// Create a second graphics path and a wider Pen.
GraphicsPath myPath2 = new GraphicsPath();
Pen pathPen2 = new Pen(Color.Black, 10);
// Create a new ellipse with a width of 10.
myPath2.AddEllipse(150, 20, 100, 100);
myPath2.Widen(pathPen2);
e.Graphics.FillPath(Brushes.Black, myPath2);
// Get the second path bounds.
RectangleF boundRect2 = myPath2.GetBounds();
// Draw the bounding rectangle.
e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
boundRect2.X,
boundRect2.Y,
boundRect2.Height,
boundRect2.Width);
// Display the rectangle size.
MessageBox.Show(boundRect2.ToString());
}