protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Pen pn = new Pen(Color.Green, 10); g.DrawLine(pn, 100, 10, 30, 10); g.DrawEllipse( new Pen(Color.Red, 20), 20, 40, 20, 20); g.DrawBezier( new Pen(Color.Blue, 5), new Point(50,60), new Point(150,10), new Point(200,230), new Point(100,100) ); PointF point1 = new PointF(50.0f, 250.0f); PointF point2 = new PointF(100.0f, 25.0f); PointF point3 = new PointF(150.0f, 5.0f); PointF point4 = new PointF(250.0f, 50.0f); PointF point5 = new PointF(300.0f, 100.0f); PointF[] curvePoints = {point1, point2, point3, point4, point5 }; g.DrawPolygon(new Pen(Color.Chocolate, 10), curvePoints); } |
Graphics g = e.Graphics; SolidBrush sdBrush1 = new SolidBrush(Color.Red); SolidBrush sdBrush2 = new SolidBrush(Color.Green); SolidBrush sdBrush3 = new SolidBrush(Color.Blue); g.FillEllipse(sdBrush2, 20, 40, 60, 70); Rectangle rect = new Rectangle(0, 0, 200, 100); g.FillPie(sdBrush3, 0, 0, 200, 40, 0.0f, 30.0f ); PointF point1 = new PointF(50.0f, 250.0f); PointF point2 = new PointF(100.0f, 25.0f); PointF point3 = new PointF(150.0f, 40.0f); PointF point4 = new PointF(250.0f, 50.0f); PointF point5 = new PointF(300.0f, 100.0f); PointF[] curvePoints = {point1, point2, point3, point4, point5 }; g.FillPolygon(sdBrush1, curvePoints); |
Member Name |
BackwardDiagonal |
Cross |
DarkDownwardDiagonal |
DarkHorizontal |
DarkUpwardDiagonal |
DarkVertical |
DashedDownwardDiagonal |
DashedHorizontal |
DashedUpwardDiagonal |
DashedVertical |
DiagonalBrick |
DiagonalCross |
Divot |
DottedDiamond |
DottedGrid |
ForwardDiagonal |
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; HatchBrush hBrush1 = new HatchBrush(HatchStyle.DiagonalCross, Color.Chocolate, Color.Red); HatchBrush hBrush2 = new HatchBrush(HatchStyle.DashedHorizontal, Color.Green, Color.Black); HatchBrush hBrush3 = new HatchBrush(HatchStyle.Weave, Color.BlueViolet, Color.Blue); g.FillEllipse(hBrush1, 20, 80, 60, 20); Rectangle rect = new Rectangle(0, 0, 200, 100); g.FillPie(hBrush3, 0, 0, 200, 40, 0.0f, 30.0f ); PointF point1 = new PointF(50.0f, 250.0f); PointF point2 = new PointF(100.0f, 25.0f); PointF point3 = new PointF(150.0f, 40.0f); PointF point4 = new PointF(250.0f, 50.0f); PointF point5 = new PointF(300.0f, 100.0f); PointF[] curvePoints = {point1, point2, point3, point4, point5 }; g.FillPolygon(hBrush2, curvePoints); } |
private Brush txBrush; 厖 protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; g.FillRectangle(txBrush, ClientRectangle); } private void Form1_Load(object sender, System.EventArgs e) { Image img = new Bitmap(@""); txBrush = new TextureBrush(img); } |
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics ; Rectangle rect = new Rectangle(50, 30, 200, 200); LinearGradientBrush lBrush = new LinearGradientBrush(rect, Color.Red, Color.Green,LinearGradientMode.BackwardDiagonal); g.FillRectangle(lBrush, rect); } |
LinearGradientBrush lBrush = new LinearGradientBrush(rect, Color.Blue, Color.Green, LinearGradientMode.Vertical); |