private void UxView_Click(object sender, EventArgs e)
 {
     if (uxImages.SelectedIndices.Count > 0)
     {
         var    viewer = new ViewImage();
         var    image  = TempImages.ElementAt(uxImages.SelectedIndices[0]).Value;
         string f      = TempImages.ElementAt(uxImages.SelectedIndices[0]).Key;
         if (image == null)
         {
             try
             {
                 image = Image.FromFile(f);
             }
             catch
             {
                 image = WindowsThumbnailProvider.GetThumbnail(f, 64, 64, ThumbnailOptions.None);
             }
         }
         viewer.pictureBox1.Image = image;
         viewer.EncFile           = f;
         viewer.PlainFileName     = uxImages.SelectedItems[0].Text;
         viewer.ShowDialog();
         //image.Dispose();
     }
 }
        private void UxImageAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    foreach (var inFile in openFileDialog1.FileNames)
                    {
                        string idx = imageList1.Images.Count.ToString();

                        using (Bitmap thumbnail = WindowsThumbnailProvider.GetThumbnail(inFile, 64, 64, ThumbnailOptions.None))
                        {
                            imageList1.Images.Add(idx, thumbnail);
                        }
                        TempImages.Add(inFile, null);

                        uxImages.Items.Add(Path.GetFileName(inFile), idx);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }