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

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "*.jpg,*.jpeg,*.bmp,*.gif,*.ico,*.png,*.tif,*.wmf|*.jpg;*.jpeg;*.bmp;*.gif;*.ico;*.png;*.tif;*.wmf";
            openFileDialog1.ShowDialog();
            Image myImage = System.Drawing.Image.FromFile(openFileDialog1.FileName);
            pictureBox1.Image = myImage;
            textBox1.Text = myImage.Width.ToString();
            textBox2.Text = myImage.Height.ToString();
            textBox3.Text = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf(".") + 1,
                openFileDialog1.FileName.Length - openFileDialog1.FileName.LastIndexOf(".") - 1);
        }

        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            Bitmap bmp = (Bitmap)pictureBox1.Image;
            Color pointColor = bmp.GetPixel(e.X, e.Y);
            textBox4.Text = pointColor.R.ToString();
            textBox5.Text = pointColor.G.ToString();
            textBox6.Text = pointColor.B.ToString();
        }
    }
}
