private void lv1_VisibleChanged(object sender, EventArgs e) { if (explorerLV.Visible && browseMode != BrowseModes.FolderBrowser) { //SystemImageListManager.SetListViewImageList(explorerLV, true, false); SystemImageListManager.SetListViewImageList(explorerLV, false, false); } }
private void DoLoadLv() { foreach (ListViewItem lvi in explorerLV.Items) { CShItem cshItem = lvi.Tag as CShItem; lvi.ImageIndex = SystemImageListManager.GetIconIndex(cshItem, false, false); } Event1.Set(); }
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { IDataObject data = Clipboard.GetDataObject(); if (!data.GetDataPresent(DataFormats.FileDrop)) { return; } string[] files = (string[])data.GetData(DataFormats.FileDrop); MemoryStream stream = (MemoryStream)data.GetData("Preferred DropEffect", true); int flag = stream.ReadByte(); if (flag != 2 && flag != 5) { return; } bool cut = (flag == 2); foreach (string file in files) { string dest = this.SelectedPath + "\\" + Path.GetFileName(file); try { if (cut) { System.IO.File.Move(file, dest); } else { System.IO.File.Copy(file, dest, false); } ListViewItem lvi = new ListViewItem(Path.GetFileName(dest)); CShItem item = new CShItem(dest); lvi.Tag = item; lvi.ImageIndex = SystemImageListManager.GetIconIndex(item, false, false); explorerLV.Items.Add(lvi); } catch (IOException ex) { MessageBox.Show(this, "Failed to perform the specified operation:\n\n" + ex.Message, "File operation failed", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } }
/** * encapsulated procedures to make icons appeared on the list view */ public void RefreshToShowExplorerIcons(ListView targetListView) { SystemImageListManager.SetListViewImageList(targetListView, false, false); SystemImageListManager.SetListViewImageList(targetListView, true, false); }
private void expTree1_ExpTreeNodeSelected(string pathName, CShItem CSI) { if (SelectedPathChanged != null) { SelectedPathChanged(this, EventArgs.Empty); } if (browseMode == BrowseModes.FolderBrowser) { return; } List <CShItem> dirList = new List <CShItem>(); List <CShItem> fileList = new List <CShItem>(); int TotalItems; if (CSI.DisplayName.Equals(CShItem.strMyComputer)) { //avoid re-query since only has dirs dirList = CSI.GetDirectories(true); } else { dirList = CSI.GetDirectories(true); fileList = (this.DesignMode || SelectedFilter == "*.*")? CSI.GetFiles() : CSI.GetFiles(SelectedFilter); } TotalItems = dirList.Count + fileList.Count; if (TotalItems > 0) { dirList.Sort(); fileList.Sort(); browseStatusBar.Text = dirList.Count + " Directories " + fileList.Count + " Files"; ArrayList combList = new ArrayList(TotalItems); combList.AddRange(dirList); combList.AddRange(fileList); //Build the ListViewItems & add to lv1 explorerLV.BeginUpdate(); explorerLV.Items.Clear(); foreach (CShItem item in combList) { ListViewItem lvi = new ListViewItem(item.DisplayName); /*if (!item.IsDisk && item.IsFileSystem) * { * FileAttributes attr = File.GetAttributes(item.Path); * StringBuilder SB = new StringBuilder(); * * if ((attr & FileAttributes.System) == FileAttributes.System) SB.Append("S"); * if ((attr & FileAttributes.Hidden) == FileAttributes.Hidden) SB.Append("H"); * if ((attr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) SB.Append("R"); * if ((attr & FileAttributes.Archive) == FileAttributes.Archive) SB.Append("A"); * * lvi.SubItems.Add(SB.ToString()); * } * else * lvi.SubItems.Add(""); * * if ((!item.IsDisk) && item.IsFileSystem && (!item.IsFolder)) * { * if (item.Length > 1024) * lvi.SubItems.Add(string.Format("{0:#,###} KB", item.Length / 1024)); * else * lvi.SubItems.Add(string.Format("{0:##0} Bytes", item.Length)); * } * else * lvi.SubItems.Add(""); * * lvi.SubItems.Add(item.TypeName); * if (item.IsDisk) * lvi.SubItems.Add("");*/ lvi.Tag = item; CShItem refItem = item; lvi.ImageIndex = SystemImageListManager.GetIconIndex(refItem, false, false); explorerLV.Items.Add(lvi); } explorerLV.EndUpdate(); //LoadLV1Images(); } else { explorerLV.Items.Clear(); browseStatusBar.Text = "No Items"; } pathTextBox.Text = (CSI.IsFileSystem) ? pathName : ""; }