private void tv1_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) { Cursor oldCursor = Cursor; Cursor = Cursors.WaitCursor; if (e.Node.Nodes.Count == 1 && e.Node.Nodes[0].Text.Equals(" : ")) { //Debug.WriteLine("Expanding -- " & e.Node.Text) e.Node.Nodes.Clear(); CShItem CSI = e.Node.Tag as CShItem; List <CShItem> D = CSI.GetDirectories(true); if (D.Count > 0) { D.Sort(); //uses the class comparer CShItem item; foreach (CShItem tempLoopVar_item in D) { item = tempLoopVar_item; if (!(item.IsHidden && !m_showHiddenFolders)) { e.Node.Nodes.Add(MakeNode(item)); } } } } else //Ensure content is accurate { RefreshNode(e.Node); } Cursor = oldCursor; }
private void explorerLV_AfterLabelEdit(object sender, LabelEditEventArgs e) { if (e.Label == null) { e.CancelEdit = true; return; } CShItem item = explorerLV.Items[e.Item].Tag as CShItem; try { if (item.IsFolder) { Directory.Move(item.Path, item.Parent.Path + "\\" + e.Label); } else { System.IO.File.Move(item.Path, item.Parent.Path + "\\" + e.Label); } CShItem newItem = new CShItem(item.Parent.Path + "\\" + e.Label); explorerLV.Items[e.Item].Tag = newItem; } catch (Exception ex) { MessageBox.Show(ex.Message); e.CancelEdit = true; return; } }
private void tv1_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) { //Primary (internal) data type ArrayList toDrag = new ArrayList(); CShItem csi = ((TreeNode)e.Item).Tag as CShItem; toDrag.Add(csi); //also need Shell IDList Array System.IO.MemoryStream MS; MS = CProcDataObject.MakeShellIDArray(toDrag); //Fairly universal data type (must be an array) string[] strD = new string[1]; strD[0] = csi.Path; //Build data to drag DataObject dataObj = new DataObject(); dataObj.SetData(toDrag); if (MS != null) { dataObj.SetData("Shell IDList Array", true, MS); } dataObj.SetData("FileDrop", true, strD); //Do drag, allowing Copy and Move DragDropEffects ddeff; ddeff = tv1.DoDragDrop(dataObj, DragDropEffects.Copy | DragDropEffects.Move); //the following line commented out, since we can't depend on ddeff //If ddeff = DragDropEffects.None Then Exit Sub 'nothing happened RefreshNode(FindAncestorNode(csi)); }
private void etShortcuts_ExpTreeNodeSelected(string selectedPath, CShItem item) { currentShortcutItem = item; if (initializing) { return; } // The operation that will trigger the thumbnail refresh MUST only be called at the end. // Otherwise the other threads take precedence and the thumbnails are not // shown progressively but all at once, when other operations are over. if (currentExptreeItem == null || currentExptreeItem.Path != currentShortcutItem.Path) { // Maintain synchronization with the explorer tree. UpdateFileList(currentShortcutItem, lvExplorer, false, false); expanding = true; etExplorer.ExpandANode(currentShortcutItem); expanding = false; currentExptreeItem = etExplorer.SelectedItem; } // Finally update the shortcuts tab, and refresh thumbs. UpdateFileList(currentShortcutItem, lvShortcuts, true, true); }
private void etShortcuts_ExpTreeNodeSelected(string selPath, CShItem item) { // Update the list view and thumb page. Log.Debug(string.Format("Shortcut Selected : {0}.", Path.GetFileName(selPath))); _mCurrentShortcutItem = item; // Initializing happens on the explorer tab. We'll refresh later. if (!_mBInitializing) { // The operation that will trigger the thumbnail refresh MUST only be called at the end. // Otherwise the other threads take precedence and the thumbnails are not // shown progressively but all at once, when other operations are over. // Start by updating hidden explorer tab. // Update list and maintain synchronization with the tree. UpdateFileList(_mCurrentShortcutItem, lvExplorer, false); _mBExpanding = true; etExplorer.ExpandANode(_mCurrentShortcutItem); _mBExpanding = false; _mCurrentExptreeItem = etExplorer.SelectedItem; // Finally update the shortcuts tab, and refresh thumbs. UpdateFileList(_mCurrentShortcutItem, lvShortcuts, true); } Log.Debug("Shortcut Selected - Operations done."); }
private TreeNode MakeNode(CShItem item) { TreeNode newNode = new TreeNode(item.DisplayName); newNode.Tag = item; newNode.ImageIndex = SystemImageListManager.GetIconIndex(item, false, false); newNode.SelectedImageIndex = SystemImageListManager.GetIconIndex(item, true, false); //The following code, from Calum implements the following logic // Allow/disallow the showing of Hidden folders based on ShowHidden Propert // For Removable disks, always show + (allow expansion) - avoids floppy access // For all others, add + based on HasSubFolders // Except - If showing Hidden dirs, do extra check to allow for // the case of all hidden items in the Dir which will cause // HasSubFolders to be always left unset if (item.IsRemovable) //Calum's fix to hidden file fix { newNode.Nodes.Add(new TreeNode(" : ")); } else if (item.HasSubFolders) { newNode.Nodes.Add(new TreeNode(" : ")); //Begin Calum's change so Hidden dirs with all hidden content are expandable } else if (item.GetDirectories(true).Count > 0) //Added Code { newNode.Nodes.Add(new TreeNode(" : ")); //Added Code //End Calum's change } return(newNode); }
private void DragWrapper_ShDragDrop(ArrayList DragList, object Node, int grfKeyState, int pdwEffect) { expandNodeTimer.Stop(); //Debug.WriteLine("Enter ExpTree ShDragDrop. PdwEffect = " & pdwEffect) //Debug.WriteLine(vbTab & "Over node: " & CType(Node, TreeNode).Text) if (dropNode != null) { ResetTreeviewNodeColor(dropNode); } else { ResetTreeviewNodeColor(tv1.Nodes[0]); } // If Directories were Moved, we must find and update the DragSource TreeNodes // of course, it is possible that the Drag was external to the App and // the DragSource TreeNode might not exist in the Tree //All of this is somewhat chancy since we can't count on pdwEffect or // on a Move having actually started, let alone finished CShItem CSI; //that is what is in DragList foreach (CShItem tempLoopVar_CSI in DragList) { CSI = tempLoopVar_CSI; if (CSI.IsFolder) //only care about Folders { RefreshNode(FindAncestorNode(CSI)); } } if (tv1.SelectedNode == dropNode) //Fake a reselect { System.Windows.Forms.TreeViewEventArgs e = new System.Windows.Forms.TreeViewEventArgs(tv1.SelectedNode, TreeViewAction.Unknown); tv1_AfterSelect(tv1, e); //will do a RefreshNode and raise AfterNodeSelect Event } else { RefreshNode(dropNode); //Otherwise, just refresh the Target if (pdwEffect != (int)DragDropEffects.Copy && pdwEffect != (int)DragDropEffects.Link) { //it may have been a move. if so need to do an AfterSelect on the DragSource if it is SelectedNode if (DragList.Count > 0) //can't happen but check { if (tv1.SelectedNode != null) //ditto { CShItem csiSel = tv1.SelectedNode.Tag as CShItem; CShItem csiSource = DragList[0] as CShItem; //assume all from same dir if (CShItem.IsAncestorOf(csiSel, csiSource, false)) //also true for equality { System.Windows.Forms.TreeViewEventArgs e = new System.Windows.Forms.TreeViewEventArgs(tv1.SelectedNode, TreeViewAction.Unknown); tv1_AfterSelect(tv1, e); //will do a RefreshNode and raise AfterNodeSelect Event } } } } } dropNode = null; //Debug.WriteLine("Leaving ExpTree ShDragDrop") }
private void filesContextMenuStrip_Opening(object sender, CancelEventArgs e) { CShItem item = explorerLV.SelectedItems[0].Tag as CShItem; cutToolStripMenuItem.Enabled = item.IsFileSystem; copyToolStripMenuItem.Enabled = item.IsFileSystem; deleteToolStripMenuItem.Enabled = item.IsFileSystem; renameToolStripMenuItem.Enabled = item.IsFileSystem; }
private void explorerLV_BeforeLabelEdit(object sender, LabelEditEventArgs e) { CShItem item = explorerLV.Items[e.Item].Tag as CShItem; if ((item.IsFileSystem && !item.IsDisk) == false) { e.CancelEdit = true; } }
private void renameToolStripMenuItem_Click(object sender, EventArgs e) { CShItem item = explorerLV.SelectedItems[0].Tag as CShItem; if (item.IsFileSystem && !item.IsDisk) { explorerLV.SelectedItems[0].BeginEdit(); } }
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 UpdateFileList(CShItem folder, ListView listView, bool bRefreshThumbnails) { // Update a file list with the given folder. // Triggers an update of the thumbnails pane if requested. Log.Debug(string.Format("Updating file list : {0}", listView.Name)); if (folder != null) { Cursor = Cursors.WaitCursor; listView.BeginUpdate(); listView.Items.Clear(); // Each list element will store the CShItem it's referring to in its Tag property. // Get all files in the folder, and add them to the list. var fileList = folder.GetFiles(); var fileNames = new List <string>(); for (var i = 0; i < fileList.Count; i++) { var shellItem = (CShItem)fileList[i]; if (IsKnownFileType(Path.GetExtension(shellItem.Path))) { var lvi = new ListViewItem(shellItem.DisplayName); lvi.Tag = shellItem; //lvi.ImageIndex = ExpTreeLib.SystemImageListManager.GetIconIndex(ref shellItem, false, false); lvi.ImageIndex = 6; listView.Items.Add(lvi); fileNames.Add(shellItem.Path); } } listView.EndUpdate(); Log.Debug("List updated"); // Even if we don't want to reload the thumbnails, we must ensure that // the screen manager backup list is in sync with the actual file list. // desync can happen in case of renaming and deleting files. // the screenmanager backup list is used at BringBackThumbnail, // (i.e. when we close a screen) var dp = DelegatesPool.Instance(); if (dp.DisplayThumbnails != null) { Log.Debug("Asking the ScreenManager to refresh the thumbnails."); dp.DisplayThumbnails(fileNames, bRefreshThumbnails); } Cursor = Cursors.Default; } }
private void mnuLocateFolder_Click(object sender, EventArgs e) { CShItem item = activeTab == ActiveFileBrowserTab.Explorer ? currentExptreeItem : currentShortcutItem; if (item == null || string.IsNullOrEmpty(item.Path) || item.Path.StartsWith("::")) { return; } FilesystemHelper.LocateDirectory(item.Path); }
private void etExplorer_ExpTreeNodeSelected(string selectedPath, CShItem item) { currentExptreeItem = item; if (!expanding && !initializing) { // We don't maintain synchronization with the Shortcuts tab. ResetShortcutList(); UpdateFileList(currentExptreeItem, lvExplorer, true, false); } }
private void UpdateFileWatcher(CShItem folder) { fileWatcher.EnableRaisingEvents = false; if (folder == null || folder.Path.StartsWith("::")) { return; } fileWatcher.Path = folder.Path; fileWatcher.EnableRaisingEvents = true; }
private void etExplorer_ExpTreeNodeSelected(string selPath, CShItem item) { _mCurrentExptreeItem = item; // Update the list view and thumb page. if (!_mBExpanding && !_mBInitializing) { // We don't maintain synchronization with the Shortcuts tab. ResetShortcutList(); UpdateFileList(_mCurrentExptreeItem, lvExplorer, true); } }
private void flatButton1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text)) { DialogResult dialo = MessageBox.Show("请输入文件路径然后在按上传按钮!", "请输入文件路径", MessageBoxButtons.OKCancel); if (dialo == DialogResult.OK) { this.textBox1.Focus(); } return; } dummyFile.ExpList1.FullRowSelect = true; ExpList.ExpListItemCollection items = dummyFile.ExpList1.Items; if (items.Count == 0) { DialogResult dialo = MessageBox.Show("请选择文件然后在按上传按钮!", "请选择文件", MessageBoxButtons.OKCancel); if (dialo == DialogResult.OK) { this.Browser1.Focus(); } return; } foreach (ExpListItem item in items) { CShItem itm = item.CShItem; List <MeUpLoadInfo> l = GetUpLoadInfoList(itm.Path); IDataLayer dataLayer = (IDataLayer)Settings.Default.Context["datalayer"]; this.m_outputWindow.OutputInfo = string.Empty; foreach (MeUpLoadInfo meUpLoadInfo in l) { foreach (FileInfo file in meUpLoadInfo.FileInfos) { DataLayerResult result = dataLayer.BatchUploadFile(File.ReadAllBytes(file.FullName), file.Name, this.hostIdList, meUpLoadInfo.RemovePath); if (result == DataLayerResult.Success) { foreach (string output in dataLayer.UploadResultList) { this.m_outputWindow.OutputInfo += output + "\r\n"; } } else if (result == DataLayerResult.LoginHostError) { this.m_outputWindow.OutputInfo += "远程主机登陆名或密码错误请与管理员联系!" + "\r\n"; } m_outputWindow.Show(dockManager); } } } }
private void mnuOpenAsReplayWatcher_Click(object sender, EventArgs e) { CShItem item = activeTab == ActiveFileBrowserTab.Explorer ? currentExptreeItem : currentShortcutItem; if (item == null || item.Path.StartsWith("::")) { return; } string path = Path.Combine(item.Path, "*"); VideoTypeManager.LoadVideo(path, -1); }
private void mnuAddToShortcuts_Click(object sender, EventArgs e) { CShItem itemToAdd = activeTab == ActiveFileBrowserTab.Explorer ? currentExptreeItem : currentShortcutItem; if (itemToAdd == null || itemToAdd.Path.StartsWith("::")) { return; } ShortcutFolder sf = new ShortcutFolder(Path.GetFileName(itemToAdd.Path), itemToAdd.Path); PreferencesManager.FileExplorerPreferences.AddShortcut(sf); PreferencesManager.Save(); ReloadShortcuts(); }
private void lv_ItemDrag(object sender, ItemDragEventArgs e) { // Starting a drag drop. ListViewItem lvi = e.Item as ListViewItem; if (lvi != null) { CShItem item = lvi.Tag as CShItem; if (item != null) { if (item.IsFileSystem) { DoDragDrop(item.Path, DragDropEffects.All); } } } }
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); } } }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { CShItem item = explorerLV.SelectedItems[0].Tag as CShItem; if (item.IsFileSystem && !item.IsDisk) { try { System.IO.File.Delete(item.Path); explorerLV.Items.Remove(explorerLV.SelectedItems[0]); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } }
public CustomFileItem(String fileName, CShItem cshItem) { CommonInitialization(); String targetPath = cshItem.Path; DealWithSpecialFolders(cshItem.Path, cshItem.DisplayName, ref targetPath); this.customFileName = fileName.Trim(); this.keyName = cshItem.Name.Trim(); this.Tag = cshItem.Tag; this.lastWriteTime = cshItem.LastWriteTime; this.creationTime = cshItem.CreationTime; this.typeName = SystemFilesDirInfo.GetFileTypeDescription(targetPath); this.fileLength = cshItem.Length; this.filePathFull = @targetPath; this.isFolder = FileSystemUtilities.IsFullPathIsDirectory(targetPath); this.FolderType = (this.isFolder) ? FolderType.TreeView : FolderType.File; SetIconsIndex(targetPath); }
private void explorer_ItemActivate(object sender, EventArgs e) { if (explorerLV.SelectedItems.Count == 0) { return; } CShItem csi = explorerLV.SelectedItems[0].Tag as CShItem; explorerLV.Cursor = Cursors.AppStarting; if (csi.IsFolder) { foldersExpTree.ExpandANode(csi); } else { switch (browseMode) { case BrowseModes.Explorer: if (!OnFileOk()) { try { ProcessStartInfo psi = new ProcessStartInfo(csi.Path); psi.WorkingDirectory = Path.GetDirectoryName(csi.Path); Process.Start(psi); //csi.Path); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error in starting application"); } } break; case BrowseModes.FileBrowser: OnFileOk(); break; } } explorerLV.Cursor = Cursors.Default; }
private void UpdateFileWatcher(CShItem folder) { fileWatcher.EnableRaisingEvents = false; if (folder == null || folder.Path.StartsWith("::")) { return; } try { fileWatcher.Path = folder.Path; fileWatcher.EnableRaisingEvents = true; } catch { // This happens with archive files, considered directories by Windows. log.ErrorFormat("Error while adding path to file watcher. {0}", folder.Path); } }
private string[] GetSelectedFiles() { if (explorerLV.SelectedItems.Count == 0) { return(null); } string[] files = new string[explorerLV.SelectedItems.Count]; int i = 0; foreach (ListViewItem lvi in explorerLV.SelectedItems) { CShItem item = lvi.Tag as CShItem; if (item.IsFileSystem && !item.IsDisk) { files[i++] = item.Path; } } return(files); }
private void tv1_AfterSelect(System.Object sender, System.Windows.Forms.TreeViewEventArgs e) { TreeNode node = e.Node; CShItem CSI = e.Node.Tag as CShItem; if (CSI == Root.Tag && !tv1.ShowRootLines) { try { tv1.BeginUpdate(); tv1.ShowRootLines = true; RefreshNode(node); tv1.ShowRootLines = false; } finally { tv1.EndUpdate(); } } else { RefreshNode(node); } if (EnableEventPost) //turned off during RefreshTree { if (CSI.Path.StartsWith(":")) { if (ExpTreeNodeSelectedEvent != null) { ExpTreeNodeSelectedEvent(CSI.DisplayName, CSI); } } else { if (ExpTreeNodeSelectedEvent != null) { ExpTreeNodeSelectedEvent(CSI.Path, CSI); } } } }
private void browser_SelectedItemsChanged(object sender, FileBrowser.SelectedItemsChangedEventArgs e) { if (e.SelectedItems.Count > 0) { CShItem item = e.SelectedItems[0]; if (item.IsFileSystem && !item.IsFolder) { string ext = Path.GetExtension(item.Path); if (ext == ".w3g") { //lv1.Cursor = Cursors.AppStarting; PreviewReplay(item.Path); //lv1.Cursor = Cursors.Default; return; } } } PreviewReplay(null); }
public bool ExpandANode(CShItem newItem) { bool returnValue; returnValue = false; //assume failure System.Windows.Forms.TreeNode baseNode = Root; tv1.BeginUpdate(); baseNode.Expand(); //Ensure base is filled in //do the drill down -- Node to expand must be included in tree TreeNode testNode; int lim = CShItem.PidlCount(newItem.PIDL) - CShItem.PidlCount((baseNode.Tag as CShItem).PIDL); //TODO: Test ExpandARow again on XP to ensure that the CP problem ix fixed while (lim > 0) { foreach (TreeNode tempLoopVar_testNode in baseNode.Nodes) { testNode = tempLoopVar_testNode; if (CShItem.IsAncestorOf(testNode.Tag as CShItem, newItem, false)) { baseNode = testNode; RefreshNode(baseNode); //ensure up-to-date baseNode.Expand(); lim--; goto NEXLEV; } } goto XIT; //on falling thru For, we can't find it, so get out NEXLEV: 1.GetHashCode(); //nop } //after falling thru here, we have found & expanded the node this.tv1.HideSelection = false; this.Select(); this.tv1.SelectedNode = baseNode; returnValue = true; XIT: tv1.EndUpdate(); return(returnValue); }
private void LaunchItemAt(ListView _listView, MouseEventArgs e) { // Launch the video. ListViewItem lvi = _listView.GetItemAt(e.X, e.Y); if (lvi != null && _listView.SelectedItems != null && _listView.SelectedItems.Count == 1) { CShItem item = _listView.SelectedItems[0].Tag as CShItem; if (item != null) { if (item.IsFileSystem) { DelegatesPool dp = DelegatesPool.Instance(); if (dp.LoadMovieInScreen != null) { dp.LoadMovieInScreen(item.Path, -1, true); } } } } }