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

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

    void ThreadProc()
    {
      GeneratingImagesForm generatingImagesForm = new GeneratingImagesForm();
      generatingImagesForm.ShowDialog();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
      thread.Start();

      ImageList imageList = new ImageList();
      Image bmp;
      string rootPathName = System.Reflection.Assembly.GetExecutingAssembly().Location;
      rootPathName = System.IO.Path.GetDirectoryName(rootPathName);
      rootPathName = System.IO.Path.Combine(rootPathName, "bmps");
      Image blankBitmap = Bitmap.FromFile(System.IO.Path.Combine(rootPathName, "blank.bmp"));
      
      for (int i = 0; i < 10023 ; i++)
      {
        string fileName = System.IO.Path.Combine(rootPathName, i.ToString() + ".bmp");
        if (System.IO.File.Exists(fileName) == true)
        {
          bmp = Bitmap.FromFile(fileName);
          imageList.Images.Add(bmp);
        }
        else
        {
          imageList.Images.Add(blankBitmap);
        }
      }

      listView1.LargeImageList = imageList;

      for (int i = 0; i < 10023 ; i++)
      {
        listView1.Items.Add(i.ToString(), i);
      }

      thread.Abort();
    }
  }
}