本文整理匯總了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();
}