Exemple #1
0
        private void searchBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            SearchResultItem[] results = e.Result as SearchResultItem[];

            // Process search results.
            if (results != null)
            {
                List <ListViewItem> items = new List <ListViewItem>();

                foreach (SearchResultItem result in results)
                {
                    ListViewItem item = new ListViewItem();
                    item.Text = Path.GetFileName(result.FileName);
                    item.SubItems.Add(result.Version.ToString());
                    item.SubItems.Add(Path.GetDirectoryName(result.FileName));
                    item.Name = result.FileName;

                    try
                    {
                        string extension = Path.GetExtension(result.FileName).ToLower();
                        item.ImageKey = extension;

                        if (smallImageList.Images.ContainsKey(extension) == false)
                        {
                            Icon icon = IconTools.GetIconForFile(result.FileName, ShellIconSize.SmallIcon);
                            if (icon != null)
                            {
                                smallImageList.Images.Add(icon);
                                smallImageList.Images.SetKeyName(smallImageList.Images.Count - 1, extension);
                            }
                        }
                    }
                    catch
                    {
                    }

                    items.Add(item);
                }

                listViewFiles.Items.AddRange(items.ToArray());

                if (listViewFiles.Items.Count > 0)
                {
                    listViewFiles.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                }
            }

            UpdateUIState();
        }
Exemple #2
0
 private void SearchOptionsDialog_Load(object sender, EventArgs e)
 {
     foreach (ListViewItem item in listViewExtensions.Items)
     {
         string extension = item.Text;
         Icon   icon      = IconTools.GetIconForExtension(extension, ShellIconSize.SmallIcon);
         if (icon != null)
         {
             imageList.Images.Add(icon);
             imageList.Images.SetKeyName(imageList.Images.Count - 1, extension);
             item.ImageKey = extension;
         }
         item.Checked = true;
     }
 }