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 ch4_10
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

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

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            string message = "";
            if (e.Button == MouseButtons.Left)
                message = "You clicked Left Button";
            else if (e.Button == MouseButtons.Middle)
                message = "You clicked Middle Button";
            else if (e.Button == MouseButtons.Right)
                message = "You clicked Right Button";
            message += "(" + e.X.ToString() + " ," + e.Y.ToString() + ")";
            MessageBox.Show(message);
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
                case 0:
                    this.Cursor = Cursors .Cross ;
                    break;
                case 1 :
                    this.Cursor =  Cursors .Hand;
                    break;
                case 2:
                    this.Cursor = Cursors.Default;
                    break;
            }
        }

        private void label2_Click(object sender, EventArgs e)
        {
            label2.BackColor = Color.Green;
        }

        private void label2_MouseLeave(object sender, EventArgs e)
        {
            label2.BackColor = Color.Red;
        }

        private void button1_MouseLeave(object sender, EventArgs e)
        {
            MessageBox.Show("You leaved Exit button.");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
