本文整理汇总了C#中System.Drawing.RectangleF.RectangleF构造函数的典型用法代码示例。如果您正苦于以下问题:C# RectangleF构造函数的具体用法?C# RectangleF怎么用?C# RectangleF使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Drawing.RectangleF
的用法示例。
在下文中一共展示了RectangleF构造函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertRectangleToRectangleF
private void ConvertRectangleToRectangleF(PaintEventArgs e)
{
// Create a rectangle.
Rectangle rectangle1 = new Rectangle(30, 40, 50, 100);
// Convert it to a RectangleF.
RectangleF convertedRectangle = rectangle1;
// Create a new RectangleF.
RectangleF rectangle2 = new RectangleF(new PointF(30.0F, 40.0F),
new SizeF(50.0F, 100.0F));
// Create a custom, partially transparent brush.
SolidBrush redBrush = new SolidBrush(Color.FromArgb(40, Color.Red));
// Compare the converted rectangle with the new one. If they
// are equal draw and fill the rectangles on the form.
if (convertedRectangle == rectangle2)
{
e.Graphics.FillRectangle(redBrush, rectangle2);
}
// Dispose of the custom brush.
redBrush.Dispose();
}
示例2: RoundingAndTruncatingRectangles
private void RoundingAndTruncatingRectangles(PaintEventArgs e)
{
// Construct a new RectangleF.
RectangleF myRectangleF =
new RectangleF(30.6F, 30.7F, 40.8F, 100.9F);
// Call the Round method.
Rectangle roundedRectangle = Rectangle.Round(myRectangleF);
// Draw the rounded rectangle in red.
Pen redPen = new Pen(Color.Red, 4);
e.Graphics.DrawRectangle(redPen, roundedRectangle);
// Call the Truncate method.
Rectangle truncatedRectangle = Rectangle.Truncate(myRectangleF);
// Draw the truncated rectangle in white.
Pen whitePen = new Pen(Color.White, 4);
e.Graphics.DrawRectangle(whitePen, truncatedRectangle);
// Dispose of the custom pens.
redPen.Dispose();
whitePen.Dispose();
}