本文整理匯總了C#中System.Drawing.Graphics.FillRectangle方法的典型用法代碼示例。如果您正苦於以下問題:C# Graphics.FillRectangle方法的具體用法?C# Graphics.FillRectangle怎麽用?C# Graphics.FillRectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.FillRectangle方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FillRectangleRectangle
private void FillRectangleRectangle(PaintEventArgs e)
{
// Create solid brush.
SolidBrush blueBrush = new SolidBrush(Color.Blue);
// Create rectangle.
Rectangle rect = new Rectangle(0, 0, 200, 200);
// Fill rectangle to screen.
e.Graphics.FillRectangle(blueBrush, rect);
}
示例2: FillRectangleRectangleF
private void FillRectangleRectangleF(PaintEventArgs e)
{
// Create solid brush.
SolidBrush blueBrush = new SolidBrush(Color.Blue);
// Create rectangle.
RectangleF rect = new RectangleF(0.0F, 0.0F, 200.0F, 200.0F);
// Fill rectangle to screen.
e.Graphics.FillRectangle(blueBrush, rect);
}
示例3: FillRectangleInt
private void FillRectangleInt(PaintEventArgs e)
{
// Create solid brush.
SolidBrush blueBrush = new SolidBrush(Color.Blue);
// Create location and size of rectangle.
int x = 0;
int y = 0;
int width = 200;
int height = 200;
// Fill rectangle to screen.
e.Graphics.FillRectangle(blueBrush, x, y, width, height);
}
示例4: FillRectangleFloat
private void FillRectangleFloat(PaintEventArgs e)
{
// Create solid brush.
SolidBrush blueBrush = new SolidBrush(Color.Blue);
// Create location and size of rectangle.
float x = 0.0F;
float y = 0.0F;
float width = 200.0F;
float height = 200.0F;
// Fill rectangle to screen.
e.Graphics.FillRectangle(blueBrush, x, y, width, height);
}
示例5: OnPaint
//引入命名空間
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form {
protected override void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
g.FillRectangle(Brushes.White, this.ClientRectangle);
Font f = new Font("Times New Roman", 12);
Font bf = new Font(f, FontStyle.Bold);
StringFormat sf = new StringFormat();
float[] ts = { 10.0f, 70.0f, 100.0f, 90.0f };
sf.SetTabStops(0.0f, ts);
string s1 = "\tA\tAA\tAAA\tAAAA";
string s2 = "\tAAAA\tAAA\tAA\tA";
string s3 = "\tAAAAAAAA\tAAAAAAA\tAAAAAA\tAAAAA\n\tAAAA\tAAA\tAA\tAA";
g.DrawString(s1, bf, Brushes.Black, 20, 20, sf);
g.DrawString(s2, f, Brushes.Blue, 20, 20 + bf.Height, sf);
g.DrawString(s3, f, Brushes.Blue, 20,
20 + bf.Height + f.Height, sf);
f.Dispose();
bf.Dispose();
}
public static void Main() {
Application.Run(new Form1());
}
}