[svn]
r7521: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
anatoly.popov
svnadmin at nemerle.org
Tue Mar 6 23:02:03 CET 2007
Log:
Add support for drag'n'drop from shell.
Reorder usings.
Author: anatoly.popov
Date: Tue Mar 6 23:02:01 2007
New Revision: 7521
Modified:
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs Tue Mar 6 23:02:01 2007
@@ -1,6 +1,8 @@
using System;
using System.CodeDom.Compiler;
+using System.Collections.Generic;
using System.Diagnostics;
+using System.Drawing;
using System.Globalization;
using System.IO;
using System.Reflection;
@@ -18,7 +20,6 @@
using Nemerle.VisualStudio.LanguageService;
using PkgUtils = Microsoft.VisualStudio.Package.Utilities;
-using System.Drawing;
namespace Nemerle.VisualStudio.Project
{
@@ -542,6 +543,11 @@
return new NemerleProjectNodeProperties(this);
}
+ public override int AddItem(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, VSADDRESULT[] result)
+ {
+ return AddManyItemsHelper(itemIdLoc, op, itemName, filesToOpen, files, dlgOwner, result);
+ }
+
#endregion
#region IVsProjectSpecificEditorMap2 Members
@@ -630,5 +636,63 @@
}
#endregion
+
+ #region Helper methods
+
+ private int AddManyItemsHelper(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, VSADDRESULT[] result)
+ {
+ List<string> actualFiles = new List<string>(files.Length);
+ List<string> dirs = new List<string>();
+ foreach (string file in files)
+ {
+ if (File.Exists(file))
+ actualFiles.Add(file);
+ else
+ {
+ if (Directory.Exists(file))
+ {
+ dirs.Add(file);
+ }
+ }
+ }
+
+ if (actualFiles.Count > 0)
+ ErrorHandler.ThrowOnFailure(base.AddItem(itemIdLoc, op, itemName, (uint) actualFiles.Count, actualFiles.ToArray(), dlgOwner, result));
+
+ foreach (string directory in dirs)
+ {
+ HierarchyNode folderNode = CreateFolderNodeHelper(directory, itemIdLoc);
+ List<string> directoryEntries = new List<string>();
+ directoryEntries.AddRange(Directory.GetFiles(directory));
+ directoryEntries.AddRange(Directory.GetDirectories(directory));
+ AddManyItemsHelper(folderNode.ID, op, null, (uint) directoryEntries.Count, directoryEntries.ToArray(), dlgOwner, result);
+ }
+
+ return VSConstants.S_OK;
+ }
+
+ private HierarchyNode CreateFolderNodeHelper(string directory, uint parentID)
+ {
+ if (!Path.GetFullPath(directory).Contains(this.ProjectFolder))
+ {
+ HierarchyNode parent = this.NodeFromItemId(parentID);
+ if (parent is FolderNode)
+ return CreateFolderNodeHelper(directory, parent.Url);
+
+ if (parent is ProjectNode)
+ return CreateFolderNodeHelper(directory, Path.GetDirectoryName(parent.Url));
+ }
+
+ return base.CreateFolderNodes(newFolderUrl);
+ }
+
+ private HierarchyNode CreateFolderNodeHelper(string sourcePath, string parentPath)
+ {
+ string newFolderUrl = Path.Combine(parentPath, Path.GetFileName(sourcePath));
+ Directory.CreateDirectory(newFolderUrl);
+ return base.CreateFolderNodes(newFolderUrl);
+ }
+
+ #endregion
}
}
More information about the svn
mailing list