private void tagArchiveFileListView1_ItemDoubleClicked(object sender, EventArgs e) { ListView.SelectedListViewItemCollection items = tagArchiveFileListView1.SelectedItems; if (items.Count == 0) { return; } ListViewItem item = items[0]; if (item.Tag == null) { return; } if (!(item.Tag is FileEntryInformation)) { return; } FileEntryInformation entry = (item.Tag as FileEntryInformation); if (entry.FileType == FileEntryType.Folder) { ChangePath(entry.FullPath); } if (entry.FileType == FileEntryType.File) { if (this.selectedTag == null) { return; } this.DialogResult = DialogResult.OK; this.Close(); } }
private void tagTree_AfterSelect(object sender, TreeViewEventArgs e) { //if (defaultNodeBeingSelected) return; // Raise the FolderSelected event so that any sub controls that need to // display files (listview for example) can do so. if (tagLibrary != null) { FileEntryInformation entryInfo = (e.Node.Tag as FileEntryInformation); if (entryInfo != null) { if (entryInfo.FileType == FileEntryType.Folder) { string[] files = tagLibrary.GetFileList(entryInfo.FullPath); if (FolderSelected != null) { FolderSelected(new FolderSelectedEventArgs(files, entryInfo.FullPath)); } } if (NodeSelected != null) { if (!IgnoreNodeSelectionEvents) { NodeSelected(sender, e); } } } } }
private void tagArchiveFileListView1_SelectedIndexChanged(object sender, EventArgs e) { ListView.SelectedListViewItemCollection items = tagArchiveFileListView1.SelectedItems; if (items.Count == 0) { return; } ListViewItem item = items[0]; if (item.Tag == null) { return; } if (!(item.Tag is FileEntryInformation)) { return; } FileEntryInformation entry = (item.Tag as FileEntryInformation); if (entry.FileType == FileEntryType.File) { UpdateTagComboBox(entry.FullPath); this.selectedTag = new TagFileName(entry.FullPath.Trim('\\'), mapfileVersion, WhichSource(this.activeLibrary)); } }
protected TreeNode LocateNodeByPath(TreeNode rootNode, string path) { path = path.Trim('\\'); string[] parts = path.Split('\\'); foreach (TreeNode node in rootNode.Nodes) { if (node.Text == parts[0]) { if (parts.Length > 1) { // If cildren have not been created, create them. if (node.Tag == null) { continue; } if (!(node.Tag is FileEntryInformation)) { continue; } FileEntryInformation info = (node.Tag as FileEntryInformation); if (!info.ChildrenCreated) { CreateSubLevel(node.Parent); } return(LocateNodeByPath(node, path.Substring(path.IndexOf('\\') + 1))); } return(node); } } return(null); }
protected void CreateFile(string path) { string filename = Path.GetFileName(path); ListViewItem i = this.tagList.Items.Add(new ListViewItem(filename, 1)); FileEntryInformation entry = new FileEntryInformation(FileEntryType.File, path); i.Tag = entry; }
protected void CreateFolder(string path) { path = path.TrimStart('\\').TrimEnd('\\'); string folderName = Path.GetFileNameWithoutExtension(path + ".bin"); // Hack to make it return the highest level folder. ListViewItem item = this.tagList.Items.Add(new ListViewItem(folderName, 0)); FileEntryInformation entry = new FileEntryInformation(FileEntryType.Folder, path); item.Tag = entry; }
protected void CreateSubLevel(TreeNode parentNode) { foreach (TreeNode node in parentNode.Nodes) { // If neccessary, create all of this node's child nodes. FileEntryInformation fileInfo = (node.Tag as FileEntryInformation); if (fileInfo.FileType == FileEntryType.Folder) { if (!fileInfo.ChildrenCreated) { AddFiles(node, fileInfo.FullPath); fileInfo.ChildrenCreated = true; } } } }
protected BetterTreeView.BetterTreeNode CreateFileNode(string path, object tag) { string filename = Path.GetFileName(path); BetterTreeView.BetterTreeNode newNode = new BetterTreeView.BetterTreeNode(filename); newNode.CollapsedImageIndex = 3; newNode.ExpandedImageIndex = 3; newNode.SelectedImageIndex = newNode.CollapsedImageIndex; newNode.ImageIndex = newNode.CollapsedImageIndex; FileEntryInformation fileInfo = new FileEntryInformation(FileEntryType.File, path); fileInfo.Tag = tag; newNode.Tag = fileInfo; return(newNode); }
protected void InitializeTree() { tagTree.BeginUpdate(); tagTree.Nodes.Clear(); // TODO: Move BetterTreeNode outside of BetterTreeView class. BetterTreeView.BetterTreeNode rootNode = new BetterTreeView.BetterTreeNode("Archive"); rootNode.CollapsedImageIndex = 0; rootNode.ExpandedImageIndex = 0; FileEntryInformation fileInfo = new FileEntryInformation(FileEntryType.Folder, "\\"); rootNode.Tag = fileInfo; tagTree.Nodes.Add(rootNode); AddFiles(rootNode, "\\"); CreateSubLevel(rootNode); tagTree.Nodes[0].Expand(); tagTree.SelectedNode = tagTree.Nodes[0]; tagTree.EndUpdate(); }
protected BetterTreeView.BetterTreeNode CreateFolderNode(string path, object tag) { // TODO: We need to standardize how these files are named. // Slashes are a bit unneccessary IMO, and we have to keep removing them // for parsing paths - which sucks. // HACK: For now, we need to add a leading and trailing backslash. if (!path.StartsWith("\\")) { path = "\\" + path; } if (!path.EndsWith("\\")) { path = path + "\\"; } string trimmedFolder = path.TrimEnd('\\'); int slashIndex = trimmedFolder.LastIndexOf('\\'); string folderName = trimmedFolder; if (slashIndex > -1) { folderName = trimmedFolder.Substring(slashIndex); } string nodeTitle = folderName.Replace("\\", ""); BetterTreeView.BetterTreeNode newNode = new BetterTreeView.BetterTreeNode(nodeTitle); newNode.CollapsedImageIndex = 2; newNode.ExpandedImageIndex = 1; newNode.SelectedImageIndex = newNode.CollapsedImageIndex; newNode.ImageIndex = newNode.CollapsedImageIndex; FileEntryInformation fileInfo = new FileEntryInformation(FileEntryType.Folder, path); fileInfo.Tag = tag; newNode.Tag = fileInfo; return(newNode); }