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

namespace FileTypeRegist
{
    public partial class IconForm : Form
    {
        public IconForm()
        {
            InitializeComponent();
        }

        IconExactor ie;
        private void button1_Click(object sender, EventArgs e)
        {
            listView1.LargeImageList = new ImageList();
            listView1.LargeImageList.ImageSize = new Size(32,32);
            listView1.Items.Clear();

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = System.IO.Path.GetFileName(openFileDialog1.FileName);
                ie = new IconExactor(openFileDialog1.FileName);

                foreach (Icon var in ie.IconList)
                {
                    listView1.LargeImageList.Images.Add(var);
                }

                for (int i = 0; i < ie.IconList.Count; i++)
                {
                    ListViewItem item = new ListViewItem();
                    item.ImageIndex = i;
                    listView1.Items.Add(item);
                }
            }
        }

        private FileIconInfo iconInfo;

        public FileIconInfo IconInfo
        {
            get { return iconInfo; }
            set { iconInfo = value; }
        }

        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = listView1.SelectedItems[0].Index;
            iconInfo = new FileIconInfo(openFileDialog1.FileName, index);
            DialogResult = DialogResult.OK;
        }
    }
}