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

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
           
        }
        /// <summary>
        /// 直线
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.Clear(Color.White);
            Pen p = new Pen(Color.Black);
            g.DrawLine(p, 0, this.Height / 2, this.Width, this.Height / 2);
            p.Dispose();
            g.Dispose();
        }
        /// <summary>
        /// 矩形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.Clear(Color.White);
            Pen p = new Pen(Color.Black);
            g.DrawRectangle(p, 50, 50, 200, 100);
            p.Dispose();
            g.Dispose();
        }
        /// <summary>
        /// 圆形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.Clear(Color.White);
            Pen p = new Pen(Color.Black);
            g.DrawEllipse(p, 50, 50, 100, 100);
            p.Dispose();
            g.Dispose();
        }
        /// <summary>
        /// 柱形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            int height = this.ClientSize.Height - 100;
            int width = this.ClientSize.Width - 50;
            int vHeigth = 200;
            int vwidth = 100;
            Graphics g = this.CreateGraphics();
            g.Clear(Color.White);
            Pen pen = new Pen(Color.Gray);
            SolidBrush brush = new SolidBrush(Color.Gainsboro);
            for (int i = height / 2; i > 0; i--)
            {
                g.DrawEllipse(pen, width / 2, i, vHeigth, vwidth);
            }
            g.FillEllipse(brush, width / 2, 0, vHeigth, vwidth);

        }
    }
}