一、solidBrush
ソリッドカラーの塗りつぶし
ペイントイベントの形式を使用します
プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の { グラフィックG = e.Graphics。 ブラシBR = 新しいSolidBrush(Color.Red)。 g.FillRectangle(BR、10、10、100、100 )。 g.Dispose(); }
二、たTextureBrush
ビットマップの塗りを使用して
最初の画像を追加
使用してSystem.IOを。 プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の { 文字列のパス= @ " F:\ Lianxi \ App1の\ App1の\ IMG \となりのトトロ.JPG " 。 グラフィックG = e.Graphics。 ビットマップIMG; もし(File.Exists(パス)) { IMG = 新しいビットマップ(パス)。 ブラシBRは = 新しいたTextureBrush(IMG)。 g.FillRectangle(BR、30、30、500、400 )。 } 他 { MessageBox.Show(「あなたが記入したい画像を見つけることができません」、「ヒント」、MessageBoxButtons.OK)。 } g.Dispose(); // グラフィックスで使用されるリリースリソース }
三、LinearGradientBrush
直線勾配
使用してSystem.Drawing.Drawing2Dを。 プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の { グラフィックG = e.Graphics。 LinearGradientBrush LGB = 新しい LinearGradientBrush(新しい点(0、140)、新しいポイント(280、140 )、Color.Red、Color.White)。 g.FillEllipse(LGB、0、140、280、120 )。 lgb.Dispose(); g.Dispose(); }
四、PathGradientBrush
グラデーションの中心点
使用してSystem.Drawing.Drawing2Dを。 プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の { GraphicsPath GP = 新しいGraphicsPath(); gp.AddEllipse(0、80、280、120 )。 PathGradientBrush PGB = 新しいPathGradientBrush(GP); pgb.CenterColor = Color.FromArgb(0、255、255、20 )。 色[]色 = {Color.FromArgb(255、0、255、0)}。// FromArgb(透明度、R、G、B) pgb.SurroundColors = 色。 e.Graphics.FillEllipse(PGB、0、80、280、120 )。 pgb.Dispose(); }
五、HatchBrush
細長いテーブルを埋めるために
使用してSystem.Drawing.Drawing2Dを。 プライベート 無効 Form1_Paint(オブジェクト送信者、PaintEventArgsのe)の { HatchBrush hatchBrush = 新しいHatchBrush(HatchStyle.HorizontalBrick、Color.White、Color.Red)。 e.Graphics.FillRectangle(hatchBrush、10、10、100、100 )。 e.Graphics.Dispose(); }