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

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

        private void Form1_Load(object sender, EventArgs e)
        {
           comboBox1.SelectedIndex = 0;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Graphics g1, g2;
            SolidBrush myBrush = new SolidBrush(Color.Blue);
            Pen myPen = new Pen(myBrush);
            g1 = pictureBox1.CreateGraphics();
            g2 = textBox1.CreateGraphics();
            g2.Clear(Color.White);
            g1.Clear(Color.White);
            Font font = new Font("Arial", 20, FontStyle.Bold);
            Point point = new Point(1, 1);
            string str = comboBox1.Items[comboBox1.SelectedIndex].ToString();
            Rectangle rect = new Rectangle();
            switch (comboBox1.SelectedIndex)
            {
                case 0 :
                    rect.X = 38;
                    rect.Y = 5;
                    rect.Width = 140;
                    rect.Height = 78;
                    g1.DrawRectangle(myPen, rect);
                    g2.DrawString(str  , font, myBrush, point);
                    break;
                case 1:
                    rect.X = 38;
                    rect.Y = 5;
                    rect.Width = 140;
                    rect.Height = 87;
                    g1.DrawEllipse(myPen, rect);
                    g2.DrawString(str, font, myBrush, point);
                    break;
                case 2:
                    rect.X = 38;
                    rect.Y = 5;
                    rect.Width = 140;
                    rect.Height = 78;
                    g1.FillRectangle(myBrush, rect);
                    g2.DrawString(str, font, myBrush, point);
                    break;
                case 3 :
                    rect.X = 38;
                    rect.Y = 5;
                    rect.Width = 140;
                    rect.Height = 87;
                    g1.FillEllipse(myBrush, rect);
                    g2.DrawString(str, font, myBrush, point);
                    break;
            }
        }
    }
}
