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 WindowsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        /// <summary>
        /// 填充矩形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen drawPen = new Pen(Color.Red, 3);
            SolidBrush mybrush = new SolidBrush(Color.Blue);
            g.DrawRectangle(drawPen, 10, 10, 300, 100);
            g.FillRectangle(mybrush, 10, 10, 300, 100);
            g.Dispose();
            drawPen.Dispose();
            mybrush.Dispose();
        }
        /// <summary>
        /// 填充图形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen drawPen = new Pen(Color.Red, 3);
            TextureBrush mybrush = new TextureBrush(Image.FromFile(@"c:\1.jpg"));
            g.DrawRectangle(drawPen, 10, 10, 300, 100);
            g.FillRectangle(mybrush, 10, 10, 300, 100);
            g.Dispose();
            drawPen.Dispose();
            mybrush.Dispose();
        }
        /// <summary>
        /// 填充椭圆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen drawPen = new Pen(Color.Red, 3);
            SolidBrush sb = new SolidBrush(Color.Blue);
            g.FillEllipse(sb, 50, 30, 200, 100);
            g.Dispose();
            drawPen.Dispose();
        }
        /// <summary>
        /// 填充扇形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen drawPen = new Pen(Color.Red, 3);
            SolidBrush sb = new SolidBrush(Color.Blue);
            g.FillPie(sb, 50, 10, 150, 100, 0, 90);
            g.Dispose();
            drawPen.Dispose();
        }
        /// <summary>
        /// 填充多边形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button5_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            SolidBrush sb = new SolidBrush(Color.Green);
            Point p1, p2, p3, p4;
            p1 = new Point(100, 10);
            p2 = new Point(120, 70);
            p3 = new Point(200, 110);
            p4 = new Point(160, 30);
            Point[] points = { p1, p2, p3, p4 };
            g.FillPolygon(sb, points);
            g.Dispose();
            sb.Dispose();
        }
        /// <summary>
        /// 填充波形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button6_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen drawPen = new Pen(Color.Red, 3);
            HatchBrush mybrush = new HatchBrush(HatchStyle.Wave, Color.Red, Color.Blue);
            g.DrawRectangle(drawPen, 10, 10, 300, 100);
            g.FillRectangle(mybrush, 10, 10, 300, 100);
            g.Dispose();
            drawPen.Dispose();
            mybrush.Dispose();
        }
        /// <summary>
        /// 颜色渐变
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button7_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Pen drawPen = new Pen(Color.Red, 3);
            LinearGradientBrush mybrush = new LinearGradientBrush(ClientRectangle, Color.Black, Color.White, LinearGradientMode.Vertical);
            g.DrawRectangle(drawPen, 10, 10, 500, 500);
            g.FillRectangle(mybrush, 10, 10, 500, 500);
            g.Dispose();
            drawPen.Dispose();
            mybrush.Dispose();
        }
        /// <summary>
        /// 填充渐变圆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button8_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Rectangle r = new Rectangle(150, 50, 200, 200);
            LinearGradientBrush brush = new LinearGradientBrush(r, Color.Orange, Color.Purple, 90);
            g.FillEllipse(brush, r);
            g.Dispose();
            brush.Dispose();
        }


    }
}