Exemplo n.º 1
0
 /// <summary>
 /// 根据文件夹加载列表
 /// </summary>
 /// <param name="dir"></param>
 private void LoadDir(DirectoryInfo dir)
 {
     Settings.NowTabIndex = Settings.sorter.IndexOf(dir);
     listView1.Items.Clear();
     ImageList iList = imageListInvocations[dir];
     iList.Images.Clear();
     listView1.LargeImageList = iList;
     int i = 0;
     Settings.invocations[dir] = dir.GetFiles().ToList();
     foreach (FileInfo file in Settings.invocations[dir]) {
         string fileName = file.Name.EndsWith(".lnk") ? file.Name.Substring(0, file.Name.LastIndexOf(".lnk")) : file.Name;
         SimpleItem item = new SimpleItem(fileName, i++);
         item.TargetFile = file;
         iList.Images.Add(GetSystemIcon.GetIcon(file.FullName));
         listView1.Items.Add(item);
     }
 }
Exemplo n.º 2
0
 private void listView1_DragDrop(object sender, DragEventArgs e)
 {
     string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false);
     DirectoryInfo now = Settings.sorter[Settings.NowTabIndex];
     for (int i = 0; i < s.Length; i++) {
         FileInfo file = new FileInfo(s[i]);
         FileInfo newFile = new FileInfo(@"lnks\" + now.Name + "\\" + file.Name);
         File.Copy(s[i], newFile.FullName);
         Settings.invocations[now].Add(file);
         string fileName = file.Name.EndsWith(".lnk") ? file.Name.Substring(0, file.Name.LastIndexOf(".lnk")) : file.Name;
         SimpleItem item = new SimpleItem(fileName, listView1.Items.Count);
         item.TargetFile = file;
         imageListInvocations[now].Images.Add(GetSystemIcon.GetIcon(newFile.FullName));
         listView1.Items.Add(item);
     }
 }