Пример #1
0
        /// <summary> Fill the contents list window with files's own Icons, given a directory name path </summary>
        private void AddImagesExtsToFileLists(string directoryName)
        {
            contentsFileList.Clear();
            //part 2: resetList all subfiles, match the extension and find the icon.
            foreach (string file in Directory.GetFiles(directoryName))
            {
                var fileAttribs = File.GetAttributes(file);
                if ((fileAttribs & SharedHelper.SyncSettingstoInvisibleFlag()) != 0)
                {
                    continue; //skip the rest if its supposed to be "invisible" based on the mask
                }
                string justName = Path.GetFileName(file);
                SharedHelper.CurrExten = Path.GetExtension(file);
                if ((SharedHelper.CurrExten != ".lnk")) //if its not a shortcut
                {
                    //if not already in the resetList, then add it
                    if (filextlist.FindLastIndex(SharedHelper.FindCurExt) == -1)
                    {
                        filextlist.Add(SharedHelper.CurrExten);
                        //call NativeExtractIcon to get the filesystem icon of the filename
                        imageListFiles.Images.Add(SharedHelper.CurrExten, NativeExtractIcon.GetIcon(file, true));
                    }
                }
                else //if it is a shortcut, grab icon directly.
                {
                    imageListFiles.Images.Add(justName, NativeExtractIcon.GetIcon(file, true));
                }

                contentsFileList.Add(justName);
            }
        }
Пример #2
0
 /// <summary>
 /// turn the NameDateObj lists from Form_Main into the listview on Form_Confirm </summary>
 /// use the results as the new data model.
 public void MakeListView()
 {
     dataModel.FixReadonlyResults();
     _checklist = new List <bool>();
     listView1Confirm.BeginUpdate();
     listView1Confirm.ItemChecked -= listView1Confirm_ItemChecked; //event
     //this is wrapped in the event handlers -=, += because extremely modifying the collection with these handlers would cause lots of lag
     foreach (NameDateObj newobject in dataModel.FilestoConfirmList)
     {
         var theitem = new ListViewItem(newobject.Name, newobject.FileOrDirType);
         theitem.SubItems.Add(newobject.Created.ToString());
         theitem.SubItems.Add(newobject.Modified.ToString());
         theitem.SubItems.Add(newobject.Accessed.ToString());
         theitem.Checked = true;
         if (newobject.FileOrDirType == 0)
         {
             SharedHelper.CurrExten = Path.GetExtension(newobject.Name);
             if (_filextlist.FindLastIndex(SharedHelper.FindCurExt) == -1)
             {
                 _filextlist.Add(SharedHelper.CurrExten);
                 //call ExtractIcon to get the filesystem icon of the filename
                 imageList_Files.Images.Add(SharedHelper.CurrExten, NativeExtractIcon.GetIcon(newobject.Name, true));
             }
             theitem.ImageKey = SharedHelper.CurrExten;
         }
         listView1Confirm.Items.Add(theitem);
     }
     listView1Confirm.EndUpdate();
     listView1Confirm.ItemChecked += listView1Confirm_ItemChecked; //event
     UpdateStatusBar();
 }