using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D;namespace WindowsApplication22 { public partial class Form1 : Form { GraphicsPath GP = new GraphicsPath(); public Form1() { InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None; this.StartPosition = FormStartPosition.CenterScreen; GP.AddLines(new Point[] { new Point(15, 20), new Point(22, 0), new Point(26, 20), new Point(100, 20), new Point(100, 100),new Point(0, 100),new Point(0,20)}); GP.CloseFigure(); this.Region = new Region(GP); this.Paint += new PaintEventHandler(Form1_Paint); } void Form1_Paint(object sender, PaintEventArgs e) { Graphics G = this.CreateGraphics(); G.FillPath(Brushes.Green, GP); G.Dispose(); } } }
http://blog.csdn.net/anyushan/archive/2007/05/17/1612854.aspx看看这个吧。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;namespace WindowsApplication22
{
public partial class Form1 : Form
{
GraphicsPath GP = new GraphicsPath(); public Form1()
{
InitializeComponent(); this.FormBorderStyle = FormBorderStyle.None;
this.StartPosition = FormStartPosition.CenterScreen;
GP.AddLines(new Point[] { new Point(15, 20), new Point(22, 0), new Point(26, 20), new Point(100, 20),
new Point(100, 100),new Point(0, 100),new Point(0,20)});
GP.CloseFigure();
this.Region = new Region(GP);
this.Paint += new PaintEventHandler(Form1_Paint);
} void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics G = this.CreateGraphics();
G.FillPath(Brushes.Green, GP);
G.Dispose();
}
}
}