public override void DoDragDrop(IDataObject dataObject, DragDropEffects effect) { AbstractProjectBrowserTreeNode parentNode = null; if (dataObject.GetDataPresent(typeof(SolutionFolderNode))) { SolutionFolderNode folderNode = (SolutionFolderNode)dataObject.GetData(typeof(SolutionFolderNode)); parentNode = folderNode.Parent as AbstractProjectBrowserTreeNode; folderNode.Remove(); folderNode.InsertSorted(this); this.solution.AddFolder(folderNode.Folder); } if (dataObject.GetDataPresent(typeof(ProjectNode))) { ProjectNode projectNode = (ProjectNode)dataObject.GetData(typeof(ProjectNode)); parentNode = projectNode.Parent as AbstractProjectBrowserTreeNode; projectNode.Remove(); projectNode.InsertSorted(this); projectNode.EnsureVisible(); this.solution.AddFolder(projectNode.Project); } if (parentNode != null) { parentNode.Refresh(); } solution.Save(); }
void LoadAndExpandToNode(FileName fileName) { IProject project = null; if (!SD.ProjectService.IsSolutionOrProjectFile(fileName)) { project = SD.ProjectService.FindProjectContainingFile(fileName); } Stack <ISolutionItem> itemsToExpand = new Stack <ISolutionItem>(); ISolutionItem item = project; if (project == null) { item = SD.ProjectService.CurrentSolution.AllItems .OfType <ISolutionFileItem>().FirstOrDefault(i => i.FileName.Equals(fileName)); } while (item != null) { itemsToExpand.Push(item); item = item.ParentFolder; } AbstractProjectBrowserTreeNode current = null; var currentChildren = treeView.Nodes; while (itemsToExpand.Any()) { var currentItem = itemsToExpand.Pop(); current = currentChildren.OfType <AbstractProjectBrowserTreeNode>().FirstOrDefault(n => n.Tag == currentItem); if (current == null) { break; } current.Expand(); currentChildren = current.Nodes; } if (project != null) { var fileItem = project.FindFile(fileName); var virtualPath = fileItem.VirtualName; if (!string.IsNullOrWhiteSpace(fileItem.DependentUpon)) { int index = virtualPath.LastIndexOf('\\') + 1; virtualPath = virtualPath.Insert(index, fileItem.DependentUpon + "\\"); } string[] relativePath = virtualPath.Split('\\'); for (int i = 0; i < relativePath.Length; i++) { current = currentChildren.OfType <AbstractProjectBrowserTreeNode>() .FirstOrDefault(n => n.Text.Equals(relativePath[i], StringComparison.OrdinalIgnoreCase)); if (current == null) { break; } current.Expand(); currentChildren = current.Nodes; } } treeView.SelectedNode = current; }
public override void DoDragDrop(IDataObject dataObject, DragDropEffects effect) { if (!isInitialized) { Initialize(); isInitialized = true; } if (dataObject.GetDataPresent(typeof(SolutionFolderNode))) { SolutionFolderNode folderNode = (SolutionFolderNode)dataObject.GetData(typeof(SolutionFolderNode)); AbstractProjectBrowserTreeNode parentNode = folderNode.Parent as AbstractProjectBrowserTreeNode; folderNode.Remove(); folderNode.InsertSorted(this); folderNode.EnsureVisible(); this.folder.AddFolder(folderNode.Folder); if (parentNode != null) { parentNode.Refresh(); } } if (dataObject.GetDataPresent(typeof(SolutionItemNode))) { SolutionItemNode solutionItemNode = (SolutionItemNode)dataObject.GetData(typeof(SolutionItemNode)); ISolutionFolderNode folderNode = (ISolutionFolderNode)solutionItemNode.Parent; folderNode.Container.SolutionItems.Items.Remove(solutionItemNode.SolutionItem); Container.SolutionItems.Items.Add(solutionItemNode.SolutionItem); solutionItemNode.Remove(); solutionItemNode.InsertSorted(this); solutionItemNode.EnsureVisible(); if (solutionItemNode.Parent != null) { ((ExtTreeNode)solutionItemNode.Parent).Refresh(); } } if (dataObject.GetDataPresent(typeof(ProjectNode))) { ProjectNode projectNode = (ProjectNode)dataObject.GetData(typeof(ProjectNode)); projectNode.Remove(); projectNode.InsertSorted(this); projectNode.EnsureVisible(); this.folder.AddFolder(projectNode.Project); if (projectNode.Parent != null) { ((ExtTreeNode)projectNode.Parent).Refresh(); } } solution.Save(); }
//public override void DoDragDrop(IDataObject dataObject, DragDropEffects effect) public virtual void DoDragDrop(IDataObject dataObject, DragDropEffects effect) { if (!IsInitialized) { Initialize(); //isInitialized = true; } if (dataObject.GetDataPresent(typeof(SolutionFolderNode))) { SolutionFolderNode folderNode = (SolutionFolderNode)dataObject.GetData(typeof(SolutionFolderNode)); AbstractProjectBrowserTreeNode parentNode = folderNode.Parent as AbstractProjectBrowserTreeNode; folderNode.Remove(); folderNode.InsertSorted(this); folderNode.EnsureVisible(); MoveItem(folderNode.Folder, this.folder); if (parentNode != null) { parentNode.Refresh(); } } if (dataObject.GetDataPresent(typeof(SolutionItemNode))) { SolutionItemNode solutionItemNode = (SolutionItemNode)dataObject.GetData(typeof(SolutionItemNode)); MoveItem(solutionItemNode.SolutionItem, this.folder); solutionItemNode.Remove(); solutionItemNode.InsertSorted(this); solutionItemNode.EnsureVisible(); if (solutionItemNode.Parent != null) { ((ExtTreeNode)solutionItemNode.Parent).Refresh(); } } if (dataObject.GetDataPresent(typeof(ProjectNode))) { ProjectNode projectNode = (ProjectNode)dataObject.GetData(typeof(ProjectNode)); projectNode.Remove(); projectNode.InsertSorted(this); projectNode.EnsureVisible(); MoveItem(projectNode.Project, this.folder); if (projectNode.Parent != null) { ((ExtTreeNode)projectNode.Parent).Refresh(); } } solution.Save(); }
void UpdateToolStrip(AbstractProjectBrowserTreeNode node) { toolStrip.Items.Clear(); toolStrip.Items.AddRange(standardItems); ToolbarService.UpdateToolbar(toolStrip); if (node != null && node.ToolbarAddinTreePath != null) { toolStrip.Items.Add(new ToolStripSeparator()); toolStrip.Items.AddRange((ToolStripItem[])AddInTree.BuildItems(node.ToolbarAddinTreePath, node, false).ToArray(typeof(ToolStripItem))); } }
void TreeViewBeforeSelect(object sender, TreeViewCancelEventArgs e) { // set current project & current combine AbstractProjectBrowserTreeNode node = e.Node as AbstractProjectBrowserTreeNode; if (node == null) { return; } ProjectService.CurrentProject = node.Project; propertyContainer.SelectedObject = node.Tag; }
void TreeViewDrawNode(object sender, DrawTreeNodeEventArgs e) { AbstractProjectBrowserTreeNode node = e.Node as AbstractProjectBrowserTreeNode; if (node != null) { Image img = node.Overlay; if (img != null) { Graphics g = e.Graphics; g.DrawImageUnscaled(img, e.Bounds.X - img.Width, e.Bounds.Bottom - img.Height); } } }
void TreeViewBeforeSelect(object sender, System.Windows.RoutedEventArgs e) // TreeViewCancelEventArgs e) { // set current project & current combine AbstractProjectBrowserTreeNode node = (AbstractProjectBrowserTreeNode)treeView.SelectedItem; // e.Source as AbstractProjectBrowserTreeNode; if (node == null) { return; } if (!inSelectFile) { ProjectService.CurrentProject = node.Project; } propertyContainer.SelectedObject = node.Tag; }
void UpdateToolStrip(AbstractProjectBrowserTreeNode node) { if (toolStrip == null) { return; } toolStrip.Items.Clear(); toolStrip.Items.AddRange(standardItems); SD.WinForms.ToolbarService.UpdateToolbar(toolStrip); if (node != null && node.ToolbarAddinTreePath != null) { toolStrip.Items.Add(new ToolStripSeparator()); toolStrip.Items.AddRange(SD.WinForms.ToolbarService.CreateToolStripItems(node.ToolbarAddinTreePath, node, false)); } }
public override AbstractProjectBrowserTreeNode GetNodeByRelativePath(string relativePath) { foreach (AbstractProjectBrowserTreeNode node in Nodes) { if (node != null) { AbstractProjectBrowserTreeNode returnedNode = node.GetNodeByRelativePath(relativePath); if (returnedNode != null) { return(returnedNode); } } } return(this); }
public virtual AbstractProjectBrowserTreeNode GetNodeByRelativePath(string relativePath) { if (relativePath == Text) { return(this); } string[] targets = relativePath.Trim('/', '\\').Split('/', '\\'); if (targets[0] != Text) { return(null); } if (!this.IsExpanded) { // the targetNode is not expanded so it's as deep as we can go //LoggingService.DebugFormatted("target node '{0};{1}' is not expanded.", targetNode, targetNode.Text); return(this); } string currentPath = relativePath.Trim('/', '\\').RemoveFromStart(targets[0]).Trim('/', '\\'); //LoggingService.Debug("entering depth loop..."); //LoggingService.DebugFormatted(@"\- looking for '{0}'", relativePath); //LoggingService.DebugFormatted(@"\- starting at '{0}'", targetNode != null ? targetNode.Text : "null"); //LoggingService.Debug("-- looking for: "+target); foreach (AbstractProjectBrowserTreeNode node in this.Nodes) { if (node == null) { // can happen when the node is currently expanding continue; } AbstractProjectBrowserTreeNode tempNode = node.GetNodeByRelativePath(currentPath); if (tempNode != null) { return(tempNode); } } return(null); }
protected override void Initialize() { if (removeMe != null) { Nodes.Remove(removeMe); removeMe = null; } LoggingService.Info("Initialize DirectoryNode " + Directory); Dictionary <string, FileNode> fileNodeDictionary = new Dictionary <string, FileNode>(StringComparer.OrdinalIgnoreCase); Dictionary <FileNode, string> dependendFileDictionary = new Dictionary <FileNode, string>(); Dictionary <string, DirectoryNode> directoryNodeList = new Dictionary <string, DirectoryNode>(StringComparer.OrdinalIgnoreCase); // Add files found in file system if (System.IO.Directory.Exists(Directory)) { foreach (string subDirectory in System.IO.Directory.GetDirectories(Directory)) { if (Path.GetFileName(subDirectory) != ".svn") { DirectoryNode newDirectoryNode = DirectoryNodeFactory.CreateDirectoryNode(this, Project, subDirectory); newDirectoryNode.InsertSorted(this); directoryNodeList[Path.GetFileName(subDirectory)] = newDirectoryNode; } } foreach (string file in System.IO.Directory.GetFiles(Directory)) { FileNode fileNode = new FileNode(file); fileNodeDictionary[Path.GetFileName(file)] = fileNode; fileNode.InsertSorted(this); } } if (Nodes.Count == 0) { SetClosedImage(); } string relativeDirectoryPath = this.RelativePath; if (relativeDirectoryPath.Length > 0) { relativeDirectoryPath = relativeDirectoryPath.Replace('\\', '/') + '/'; } // Add project items foreach (ProjectItem item in Project.Items) { if (item.ItemType == ItemType.WebReferenceUrl) { DirectoryNode node; if (directoryNodeList.TryGetValue(Path.GetFileName(item.FileName), out node)) { if (node.FileNodeStatus == FileNodeStatus.None) { node.FileNodeStatus = FileNodeStatus.InProject; } node.ProjectItem = item; } continue; } FileProjectItem fileItem = item as FileProjectItem; if (fileItem == null) { continue; } string virtualName = fileItem.VirtualName.Replace('\\', '/'); if (virtualName.EndsWith("/")) { virtualName = virtualName.Substring(0, virtualName.Length - 1); } string fileName = Path.GetFileName(virtualName); if (!string.Equals(virtualName, relativeDirectoryPath + fileName, StringComparison.OrdinalIgnoreCase)) { AddParentFolder(virtualName, relativeDirectoryPath, directoryNodeList); continue; } if (item.ItemType.IsFolder()) { DirectoryNode node; if (directoryNodeList.TryGetValue(fileName, out node)) { if (node.FileNodeStatus == FileNodeStatus.None) { node.FileNodeStatus = FileNodeStatus.InProject; } node.ProjectItem = item; } else { node = DirectoryNodeFactory.CreateDirectoryNode(item, FileNodeStatus.Missing); node.InsertSorted(this); directoryNodeList[fileName] = node; } } else { FileNode node; if (fileItem.IsLink) { node = new FileNode(fileItem.FileName, FileNodeStatus.InProject); node.InsertSorted(this); fileNodeDictionary[fileName] = node; } else { if (fileNodeDictionary.TryGetValue(fileName, out node)) { if (node.FileNodeStatus == FileNodeStatus.None) { node.FileNodeStatus = FileNodeStatus.InProject; } } else { node = new FileNode(fileItem.FileName, FileNodeStatus.Missing); node.InsertSorted(this); fileNodeDictionary[fileName] = node; } } node.ProjectItem = fileItem; if (fileItem != null && fileItem.DependentUpon != null && fileItem.DependentUpon.Length > 0) { dependendFileDictionary[node] = fileItem.DependentUpon; } } } // Insert 'code behind files' foreach (KeyValuePair <FileNode, string> pair in dependendFileDictionary) { string fileName = Path.GetFileName(pair.Value); if (!fileNodeDictionary.ContainsKey(fileName)) { continue; } AbstractProjectBrowserTreeNode parentNode = fileNodeDictionary[fileName]; pair.Key.Parent.Nodes.Remove(pair.Key); if (NodeIsParent(parentNode, pair.Key)) { // is pair.Key a parent of parentNode? // if yes, we have a parent cycle - break it by adding one node to the directory pair.Key.InsertSorted(this); } else { pair.Key.InsertSorted(parentNode); if (pair.Key.FileNodeStatus != FileNodeStatus.Missing) { pair.Key.FileNodeStatus = FileNodeStatus.BehindFile; } } } base.Initialize(); }
TreeNode FindDeepestOpenNodeForPath(string fileName) { //LoggingService.DebugFormatted("Finding Deepest for '{0}'", fileName); ISolution solution = ProjectService.OpenSolution; if (solution == null) { return(null); } IProject project = SD.ProjectService.FindProjectContainingFile(FileName.Create(fileName)); if (project == null) { //LoggingService.Debug("no IProject found"); return(null); } string relativePath = String.Empty; AbstractProjectBrowserTreeNode targetNode = FindProjectNode(project); if (targetNode == null) { // our project node is not yet created, // so start at the root and work down. if (treeView.Nodes == null || treeView.Nodes.Count < 1) { // the treeView is not yet prepared to assist in this request. return(null); } else { targetNode = treeView.Nodes[0] as AbstractProjectBrowserTreeNode; if (fileName.StartsWith(solution.Directory)) { relativePath = fileName.Replace(solution.Directory, ""); } } } else { // start from the project node and work upwards // to the first visible node TreeNode t = targetNode; TreeNode p = targetNode.Parent; while (p != null) { if (!p.IsExpanded) { t = p; } p = p.Parent; } if (t != targetNode) { // project node is instantiated but not visible // so select the most visible parent node. return(t); } else { // project node is instantiated and visible // so we start here and work down if (fileName.StartsWith((targetNode as ProjectNode).Directory)) { relativePath = fileName.Replace((targetNode as ProjectNode).Directory, ""); } } } return(targetNode.GetNodeByRelativePath(relativePath)); }
public object Visit(AbstractProjectBrowserTreeNode abstractProjectBrowserTreeNode, object data) { LoggingService.Warn("Warning visited default Visit() for : " + abstractProjectBrowserTreeNode); abstractProjectBrowserTreeNode.AcceptChildren(this, data); return(data); }