1. 程式人生 > >C#中繪製多邊形

C#中繪製多邊形

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace picture3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //繪製多邊形
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen Mypen = new Pen(Color .Blue ,0);
            Point p1 = new Point(50,50);
            Point p2 = new Point(80,50);
            Point p3 = new Point(30,80);
            Point p4 = new Point(60,80);
            Point[] p = { p1,p2 ,p3 ,p4 };
            g.DrawPolygon(Mypen ,p);
        }
    }
}