void AddCutCopyPasteButtons(ContextMenuStrip cm, PrjExplorerNode node, bool CutAllowed, bool CopyAllowed, bool PasteAllowed) { if (CutAllowed || CopyAllowed || (PasteAllowed && CutCopyNode != null && IsDropAllowed(CutCopyNode.AbsolutePath, node))) { cm.Items.Add(new ToolStripSeparator()); } if (CutAllowed) { cm.Items.Add("Cut", CommonIcons.Icons_16x16_CutIcon, delegate(Object o, EventArgs _e) { IsCut = true; CutCopyNode = node; }); } if (CopyAllowed) { cm.Items.Add("Copy", CommonIcons.Icons_16x16_CopyIcon, delegate(Object o, EventArgs _e) { IsCut = false; CutCopyNode = node; }); } if (PasteAllowed && CutCopyNode != null && IsDropAllowed(CutCopyNode.AbsolutePath, node)) { cm.Items.Add("Paste", CommonIcons.Icons_16x16_PasteIcon, delegate(Object o, EventArgs _e) { DoPaste(CutCopyNode.AbsolutePath, new DnDData(node)); }); } }
public static bool IsDropAllowed(string file, PrjExplorerNode dropNode) { if (string.IsNullOrEmpty(file)) { return(false); } if (file.EndsWith(Solution.SolutionExtension)) { return(true); } if (dropNode == null) { return(false); } bool isPrj = false; AbstractLanguageBinding.SearchBinding(file, out isPrj); if (isPrj && dropNode is SolutionNode && !(dropNode as SolutionNode).Solution.ContainsProject(file)) { return(true); } else if (isPrj) // Ignore already existing projects { return(false); } if (dropNode is SolutionNode) { return(false); } /* * After checking for solution or project extension, check if 'file' is file or directory */ bool IsDir = Directory.Exists(file); var fileDir = Path.GetDirectoryName(file); var dropFile = dropNode.AbsolutePath; var dropDir = dropFile; if (!(dropNode is DirectoryNode)) { dropDir = Path.GetDirectoryName(dropFile); } if (IsDir && file != dropDir && !dropDir.Contains(file)) { return(true); } else if (fileDir != dropDir) // Ensure the file gets moved either to an other directory or project { return(true); } return(false); }
public DnDData(PrjExplorerNode n) { Node = n; }
void AddCutCopyPasteButtons(ContextMenuStrip cm, PrjExplorerNode node, bool CutAllowed, bool CopyAllowed, bool PasteAllowed) { if (CutAllowed || CopyAllowed || (PasteAllowed && CutCopyNode!=null && IsDropAllowed(CutCopyNode.AbsolutePath, node))) cm.Items.Add(new ToolStripSeparator()); if (CutAllowed) cm.Items.Add("Cut", CommonIcons.Icons_16x16_CutIcon, delegate(Object o, EventArgs _e) { IsCut = true; CutCopyNode = node; }); if (CopyAllowed) cm.Items.Add("Copy", CommonIcons.Icons_16x16_CopyIcon, delegate(Object o, EventArgs _e) { IsCut = false; CutCopyNode = node; }); if (PasteAllowed && CutCopyNode!=null && IsDropAllowed(CutCopyNode.AbsolutePath, node)) cm.Items.Add("Paste", CommonIcons.Icons_16x16_PasteIcon, delegate(Object o, EventArgs _e) { DoPaste(CutCopyNode.AbsolutePath,new DnDData(node)); }); }
public static bool IsDropAllowed(string file, PrjExplorerNode dropNode) { if (string.IsNullOrEmpty(file)) return false; if (file.EndsWith(Solution.SolutionExtension)) return true; if (dropNode == null) return false; bool isPrj = false; AbstractLanguageBinding.SearchBinding(file,out isPrj); if (isPrj && dropNode is SolutionNode && !(dropNode as SolutionNode).Solution.ContainsProject(file)) return true; else if (isPrj) // Ignore already existing projects return false; if (dropNode is SolutionNode) return false; /* * After checking for solution or project extension, check if 'file' is file or directory */ bool IsDir = Directory.Exists(file); var fileDir = Path.GetDirectoryName(file); var dropFile=dropNode.AbsolutePath; var dropDir = dropFile; if (!(dropNode is DirectoryNode)) dropDir = Path.GetDirectoryName(dropFile); if (IsDir && file!=dropDir && !dropDir.Contains(file)) return true; else if (fileDir!=dropDir) // Ensure the file gets moved either to an other directory or project return true; return false; }