本文整理汇总了C#中VSADDITEMOPERATION类的典型用法代码示例。如果您正苦于以下问题:C# VSADDITEMOPERATION类的具体用法?C# VSADDITEMOPERATION怎么用?C# VSADDITEMOPERATION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VSADDITEMOPERATION类属于命名空间,在下文中一共展示了VSADDITEMOPERATION类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddItem
public int AddItem(uint itemidLoc, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, VSADDRESULT[] pResult)
{
AddItemCalled = true;
AddItemArgumentItemidLoc = itemidLoc;
AddItemArgumentAddItemOperation = dwAddItemOperation;
AddItemArgumentItemName = pszItemName;
AddItemArgumentFilesToOpen = cFilesToOpen;
AddItemArgumentArrayFilesToOpen = rgpszFilesToOpen;
return VSConstants.S_OK;
}
开发者ID:attilah,项目名称:ProjectLinker,代码行数:12,代码来源:MockVsHierarchy.cs
示例2: AddItem
public int AddItem(uint itemid, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, VSADDRESULT[] pResult) {
_logger.LogHierarchy("AddItem({0})", (int)itemid);
Guid guid = Guid.Empty;
return AddItemWithSpecific(itemid, dwAddItemOperation, pszItemName, cFilesToOpen, rgpszFilesToOpen, hwndDlgOwner, 0U, ref guid, (string)null, ref guid, pResult);
}
开发者ID:mbbill,项目名称:vs-chromium,代码行数:5,代码来源:VsHierarchy.cs
示例3: AddNodeIfTargetExistInStorage
/// <summary>
/// Add an existing item (file/folder) to the project if it already exist in our storage.
/// </summary>
/// <param name="parentNode">Node to that this item to</param>
/// <param name="name">Name of the item being added</param>
/// <param name="targetPath">Path of the item being added</param>
/// <returns>Node that was added</returns>
protected virtual HierarchyNode AddNodeIfTargetExistInStorage(HierarchyNode parentNode, string name, string targetPath, VSADDITEMOPERATION addItemOp)
{
HierarchyNode newNode = parentNode;
// If the file/directory exist, add a node for it
if (addItemOp == VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE || File.Exists(targetPath))
{
VSADDRESULT[] result = new VSADDRESULT[1];
ErrorHandler.ThrowOnFailure(this.AddItem(parentNode.ID, addItemOp, name, 1, new string[] { targetPath }, IntPtr.Zero, result));
if (result[0] != VSADDRESULT.ADDRESULT_Success)
throw new ApplicationException();
newNode = this.FindChild(targetPath);
if (newNode == null)
throw new ApplicationException();
}
else if (Directory.Exists(targetPath))
{
newNode = this.CreateFolderNodes(targetPath);
}
return newNode;
}
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:27,代码来源:projectnode.copypaste.cs
示例4: AddItem
public virtual int AddItem(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, VSADDRESULT[] result)
{
Guid empty = Guid.Empty;
return AddItemWithSpecific(itemIdLoc, op, itemName, filesToOpen, files, dlgOwner, 0, ref empty, null, ref empty, result);
}
开发者ID:IntelliTect,项目名称:PowerStudio,代码行数:6,代码来源:ProjectNode.cs
示例5: AddItem
// (after dialog) Add existing item -> AdItemWithSpecific
public override int AddItem(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, VSADDRESULT[] result)
{
// Special MSBuild case: we invoked it directly instead of using the "add item" dialog.
if (itemName != null && itemName.Equals("SimResult"))
{
SimResultsNode resultsNode = null;
if (this.IsSimResultFilePresent())
resultsNode = this.FindChild("Results.sim") as SimResultsNode;
if (resultsNode == null)
{
resultsNode = CreateAndAddSimResultsFile(); //TODO: what about save on project unload/exit?
}
var simulationTimestamp = DateTime.Now;
bool filePresent = false;
bool renameOutput = true;
Boolean.TryParse(GetProjectProperty("RenameOutput"), out renameOutput);
string baseOutputName = GetProjectProperty("BaseOutputName");
if (String.IsNullOrEmpty(baseOutputName))
{
var msBuildProject = BlenXProjectPackage.MSBuildProjectFromIVsProject(this);
foreach (Microsoft.Build.BuildEngine.BuildItem item in msBuildProject.EvaluatedItems)
{
if (item.Name.Equals(SimFiles.Prog.ToString()))
{
baseOutputName = item.Include;
break;
}
}
if (String.IsNullOrEmpty(baseOutputName))
baseOutputName = Path.GetFileNameWithoutExtension(this.ProjectFile) + ".prog";
}
string newOutputName;
if (renameOutput)
{
newOutputName = baseOutputName + simulationTimestamp.ToString("yyyy'-'MM'-'dd'-'HH'-'mm'-'ss");
// TODO: try to move!
filePresent = TryCopy(baseOutputName, newOutputName, "spec");
TryCopy(baseOutputName, newOutputName, "E.out");
TryCopy(baseOutputName, newOutputName, "C.out");
TryCopy(baseOutputName, newOutputName, "V.out");
}
else
{
newOutputName = baseOutputName;
filePresent = File.Exists(this.ProjectFolder + Path.DirectorySeparatorChar + baseOutputName + ".spec");
}
if (filePresent)
{
resultsNode.AddEntry(newOutputName, this.ProjectFolder, simulationTimestamp);
}
return VSConstants.S_OK;
}
// Add existing item: itemIdLoc = 4294967294, VSADDITEMOP_OPENFILE, itemName = null, files (filename), null, VSADDRESULT 1 (init with ADDRESULT_Failure)
return base.AddItem(itemIdLoc, op, itemName, filesToOpen, files, dlgOwner, result);
}
开发者ID:ldematte,项目名称:BlenXVSP,代码行数:65,代码来源:BlenXProjectNode.cs
示例6: AddItem
/// <summary>
/// Adds an item to the project.
/// </summary>
/// <param name="path">The full path of the item to add.</param>
/// <param name="op">The <paramref name="VSADDITEMOPERATION"/> to use when adding the item.</param>
/// <returns>A ProjectItem object. </returns>
protected virtual EnvDTE.ProjectItem AddItem(string path, VSADDITEMOPERATION op) {
CheckProjectIsValid();
return Project.ProjectNode.Site.GetUIThread().Invoke<EnvDTE.ProjectItem>(() => {
ProjectNode proj = this.Project.ProjectNode;
EnvDTE.ProjectItem itemAdded = null;
using (AutomationScope scope = new AutomationScope(this.Project.ProjectNode.Site)) {
VSADDRESULT[] result = new VSADDRESULT[1];
ErrorHandler.ThrowOnFailure(proj.AddItem(this.NodeWithItems.ID, op, path, 0, new string[1] { path }, IntPtr.Zero, result));
string realPath = null;
if (op != VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE) {
string fileName = Path.GetFileName(path);
string fileDirectory = proj.GetBaseDirectoryForAddingFiles(this.NodeWithItems);
realPath = Path.Combine(fileDirectory, fileName);
} else {
realPath = path;
}
itemAdded = this.EvaluateAddResult(result[0], realPath);
}
return itemAdded;
});
}
开发者ID:bnavarma,项目名称:ScalaTools,代码行数:30,代码来源:OAProjectItems.cs
示例7: AddItem
/// <summary>
/// Adds an item to the project.
/// </summary>
/// <param name="path">The full path of the item to add.</param>
/// <param name="op">The <paramref name="VSADDITEMOPERATION"/> to use when adding the item.</param>
/// <returns>A ProjectItem object. </returns>
protected virtual EnvDTE.ProjectItem AddItem(string path, VSADDITEMOPERATION op)
{
if (this.Project == null || this.Project.Project == null || this.Project.Project.Site == null || this.Project.Project.IsClosed)
{
throw new InvalidOperationException();
}
ProjectNode proj = this.Project.Project;
IVsExtensibility3 extensibility = this.Project.Project.Site.GetService(typeof(IVsExtensibility)) as IVsExtensibility3;
if (extensibility == null)
{
throw new InvalidOperationException();
}
EnvDTE.ProjectItem itemAdded = null;
extensibility.EnterAutomationFunction();
try
{
VSADDRESULT[] result = new VSADDRESULT[1];
ErrorHandler.ThrowOnFailure(proj.AddItem(this.NodeWithItems.ID, op, path, 0, new string[1] { path }, IntPtr.Zero, result));
string fileName = System.IO.Path.GetFileName(path);
string fileDirectory = proj.GetBaseDirectoryForAddingFiles(this.NodeWithItems);
string filePathInProject = System.IO.Path.Combine(fileDirectory, fileName);
itemAdded = this.EvaluateAddResult(result[0], filePathInProject);
}
finally
{
extensibility.ExitAutomationFunction();
}
return itemAdded;
}
开发者ID:Xtremrules,项目名称:dot42,代码行数:43,代码来源:OAProjectItems.cs
示例8: AddItem
public int AddItem(uint itemidLoc, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, VSADDRESULT[] pResult) {
// Check if we are adding an item to a folder that consists of browser-side code.
// In this case, we will want to open the file with the default editor.
var isClientCode = false;
var project = _innerVsHierarchy.GetProject().GetNodejsProject();
var selectedItems = this.GetSelectedItems().GetEnumerator();
if (selectedItems.MoveNext()) {
var currentId = selectedItems.Current.itemid;
string name;
GetCanonicalName(currentId, out name);
var nodeFolderNode = project.FindNodeByFullPath(name) as NodejsFolderNode;
if (nodeFolderNode != null) {
if (nodeFolderNode.ContentType == FolderContentType.Browser) {
isClientCode = true;
}
}
}
if (!isClientCode && _innerProject3 != null && IsJavaScriptFile(pszItemName)) {
Guid ourEditor = IsES6IntellisensePreview() ? Guid.Empty : typeof(NodejsEditorFactory).GUID;
Guid view = Guid.Empty;
return _innerProject3.AddItemWithSpecific(
itemidLoc,
dwAddItemOperation,
pszItemName,
cFilesToOpen,
rgpszFilesToOpen,
hwndDlgOwner,
dwAddItemOperation == VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE ?
(uint)__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_DoOpen :
0,
ref ourEditor,
String.Empty,
ref view,
pResult
);
}
return _innerProject.AddItem(itemidLoc, dwAddItemOperation, pszItemName, cFilesToOpen, rgpszFilesToOpen, hwndDlgOwner, pResult);
}
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:41,代码来源:NodejsProject.cs
示例9: AddItemWithSpecificInternal
// TODO: Refactor me into something sane
internal int AddItemWithSpecificInternal(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, VSADDRESULT[] result, bool alwaysCopy = false, bool? promptOverwrite = null)
{
if (files == null || result == null || files.Length == 0 || result.Length == 0)
{
return VSConstants.E_INVALIDARG;
}
// Locate the node to be the container node for the file(s) being added
// only projectnode or foldernode and file nodes are valid container nodes
// We need to locate the parent since the item wizard expects the parent to be passed.
HierarchyNode n = this.NodeFromItemId(itemIdLoc);
if (n == null)
{
return VSConstants.E_INVALIDARG;
}
while (!n.CanAddFiles && (!this.CanFileNodesHaveChilds || !(n is FileNode)))
{
n = n.Parent;
}
Debug.Assert(n != null, "We should at this point have either a ProjectNode or FolderNode or a FileNode as a container for the new filenodes");
// handle link and runwizard operations at this point
bool isLink = false;
switch (op)
{
case VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE:
// we do not support this right now
isLink = true;
break;
case VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD:
result[0] = this.RunWizard(n, itemName, files[0], dlgOwner);
return VSConstants.S_OK;
}
string[] actualFiles = new string[files.Length];
VSQUERYADDFILEFLAGS[] flags = this.GetQueryAddFileFlags(files);
string baseDir = this.GetBaseDirectoryForAddingFiles(n);
// If we did not get a directory for node that is the parent of the item then fail.
if (String.IsNullOrEmpty(baseDir))
{
return VSConstants.E_FAIL;
}
// Pre-calculates some paths that we can use when calling CanAddItems
List<string> filesToAdd = new List<string>();
for (int index = 0; index < files.Length; index++)
{
string newFileName = String.Empty;
string file = files[index];
switch (op)
{
case VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE:
{
string fileName = Path.GetFileName(itemName ?? file);
newFileName = CommonUtils.GetAbsoluteFilePath(baseDir, fileName);
}
break;
case VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE:
case VSADDITEMOPERATION.VSADDITEMOP_OPENFILE:
{
string fileName = Path.GetFileName(file);
newFileName = CommonUtils.GetAbsoluteFilePath(baseDir, fileName);
var friendlyPath = CommonUtils.CreateFriendlyFilePath(ProjectFolder, file);
if (isLink && CommonUtils.IsSubpathOf(ProjectFolder, file))
{
// creating a link to a file that's actually in the project, it's not really a link.
isLink = false;
newFileName = file;
n = this.CreateFolderNodes(Path.GetDirectoryName(file));
}
}
break;
}
filesToAdd.Add(newFileName);
}
// Ask tracker objects if we can add files
if (!this.tracker.CanAddItems(filesToAdd.ToArray(), flags))
{
// We were not allowed to add the files
return VSConstants.E_FAIL;
}
if (!this.ProjectMgr.QueryEditProjectFile(false))
{
throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
}
// Add the files to the hierarchy
int actualFilesAddedIndex = 0;
for (int index = 0; index < filesToAdd.Count; index++)
//.........这里部分代码省略.........
开发者ID:happylancer,项目名称:node-tools,代码行数:101,代码来源:ProjectNode.cs
示例10: AddItem
/// <summary>
/// Adds an item to the project.
/// </summary>
/// <param name="path">The full path of the item to add.</param>
/// <param name="op">
/// The <paramref name="VSADDITEMOPERATION" /> to use when adding the item.
/// </param>
/// <returns>A ProjectItem object. </returns>
protected virtual ProjectItem AddItem(string path, VSADDITEMOPERATION op)
{
CheckProjectIsValid();
ProjectNode proj = Project.Project;
ProjectItem itemAdded = null;
using (var scope = new AutomationScope(Project.Project.Site))
{
var result = new VSADDRESULT[1];
ErrorHandler.ThrowOnFailure(proj.AddItem(NodeWithItems.ID, op, path, 0, new string[1] {path}, IntPtr.Zero, result));
string fileName = Path.GetFileName(path);
string fileDirectory = proj.GetBaseDirectoryForAddingFiles(NodeWithItems);
string filePathInProject = Path.Combine(fileDirectory, fileName);
itemAdded = EvaluateAddResult(result[0], filePathInProject);
}
return itemAdded;
}
开发者ID:happylancer,项目名称:node-tools,代码行数:29,代码来源:OAProjectItems.cs
示例11: AddItemWithSpecific
/// <include file='doc\Project.uex' path='docs/doc[@for="ImageNames.AddItemWithSpecific"]/*' />
public virtual int AddItemWithSpecific(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, VSADDRESULT[] result){
result[0] = VSADDRESULT.ADDRESULT_Failure;
//if (this.IsReadOnly) return; <-- bogus, the user can always change the project to non-readonly later when they choose to save it, or they can do saveas...
HierarchyNode n = NodeFromItemId(itemIdLoc);
if (n == null) return 0;
if (n.NodeType == HierarchyNodeType.Root || n.NodeType == HierarchyNodeType.Folder){
if (!this.projectMgr.Tracker.CanAddFiles(files)){
return 0;
}
foreach (string file in files){
HierarchyNode child;
bool fFileAdded = false;
bool fOverwrite = false;
string strBaseDir = Path.GetDirectoryName(this.filename);
string strNewFileName = "";
if (n.NodeType == HierarchyNodeType.Folder){
// add the folder to the path....
strBaseDir = Path.Combine(strBaseDir, n.XmlNode.GetAttribute("RelPath"));
}
switch (op){
case VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE:
// new item added. Need to copy template to new location and then add new location
strNewFileName = Path.Combine(strBaseDir, itemName);
break;
case VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE:// TODO: VSADDITEMOP_LINKTOFILE
// we do not support this right now
throw new NotImplementedException("VSADDITEMOP_LINKTOFILE");
case VSADDITEMOPERATION.VSADDITEMOP_OPENFILE:{
string strFileName = Path.GetFileName(file);
strNewFileName = Path.Combine(strBaseDir, strFileName);
}
break;
case VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD: // TODO: VSADDITEMOP_RUNWIZARD
throw new NotImplementedException("VSADDITEMOP_RUNWIZARD");
}
child = this.FindChild(strNewFileName);
if (child != null){
// file already exists in project... message box
string msg = SR.GetString(SR.FileAlreadyInProject);
string caption = SR.GetString(SR.FileAlreadyInProjectCaption);
if (MessageBox.Show(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes){
child = null;
fOverwrite = true;
}
}
if (child == null){
// the next will be equal if file is already in the project DIR
if (VsShell.IsSamePath(file, strNewFileName) == false){
// now copy file
FileInfo fiOrg = new FileInfo(file);
fiOrg.Attributes &= ~FileAttributes.ReadOnly;
try{
FileInfo fiNew = fiOrg.CopyTo(strNewFileName, fOverwrite);
} catch{
string msg = SR.GetString(SR.FileAlreadyExists);
string caption = SR.GetString(SR.FileAlreadyExistsCaption);
if (MessageBox.Show(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes){
FileInfo fiNew = fiOrg.CopyTo(strNewFileName, true);
}
}
}
fFileAdded = true;
}
if (fFileAdded && !fOverwrite){
// now add the new thing to the project
child = this.projectMgr.AddExistingFile(strNewFileName);
n.AddChild(child);
if (op == VSADDITEMOPERATION.VSADDITEMOP_OPENFILE){
IVsWindowFrame frame;
if (editorType == Guid.Empty){
Guid view = Guid.Empty;
this.OpenItem(child.ID, ref view, IntPtr.Zero, out frame);
} else{
this.OpenItemWithSpecific(child.ID, editorFlags, ref editorType, physicalView, ref logicalView, IntPtr.Zero, out frame);
}
}
this.projectMgr.Tracker.OnAddFile(strNewFileName);
}
}
n.OnItemsAppended(n);
result[0] = VSADDRESULT.ADDRESULT_Success;
}
result[0] = VSADDRESULT.ADDRESULT_Success;
return 0;
//.........这里部分代码省略.........
开发者ID:dbremner,项目名称:specsharp,代码行数:101,代码来源:Project.cs
示例12: NotImplementedException
int IVsProject.AddItem(uint itemidLoc, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, VSADDRESULT[] pResult)
{
throw new NotImplementedException();
}
开发者ID:SonarSource-VisualStudio,项目名称:sonarlint-visualstudio,代码行数:4,代码来源:ProjectMock.cs
示例13: AddItemWithSpecific
public int AddItemWithSpecific(uint itemidLoc, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, uint grfEditorFlags, ref Guid rguidEditorType, string pszPhysicalView, ref Guid rguidLogicalView, VSADDRESULT[] pResult)
{
throw new NotImplementedException();
}
开发者ID:DelBero,项目名称:XnaScrapEdit,代码行数:4,代码来源:XnaScrapProject.cs
示例14: AddItemWithSpecific
public int AddItemWithSpecific(uint itemid, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, uint grfEditorFlags, ref Guid rguidEditorType, string pszPhysicalView, ref Guid rguidLogicalView, VSADDRESULT[] pResult) {
_logger.LogHierarchy("AddItemWithSpecific({0})", (int)itemid);
return VSConstants.E_NOTIMPL;
}
开发者ID:mbbill,项目名称:vs-chromium,代码行数:4,代码来源:VsHierarchy.cs
示例15: AddItemWithSpecific
/// <include file='doc\Project.uex' path='docs/doc[@for="Project.IVsProject3.AddItemWithSpecific"]/*' />
public virtual int AddItemWithSpecific(uint itemIdLoc, VSADDITEMOPERATION op, string itemName, uint filesToOpen, string[] files, IntPtr dlgOwner, uint editorFlags, ref Guid editorType, string physicalView, ref Guid logicalView, VSADDRESULT[] result)
{
CCITracing.TraceCall();
result[0] = VSADDRESULT.ADDRESULT_Failure;
//if (this.IsReadOnly) return; <-- bogus, the user can always change the project to non-readonly later when they choose to save it, or they can do saveas...
HierarchyNode n = NodeFromItemId(itemIdLoc);
if (n == null) return NativeMethods.E_INVALIDARG;
string[] actualFiles = files;
if (n.NodeType == HierarchyNodeType.Root || n.NodeType == HierarchyNodeType.Folder)
{
if (!this.projectMgr.Tracker.CanAddFiles(files))
{
return NativeMethods.E_FAIL;
}
int index = 0;
foreach (string file in files)
{
HierarchyNode child;
bool fFileAdded = false;
bool fOverwrite = false;
string strBaseDir = Path.GetDirectoryName(this.filename);
string strNewFileName = "";
if (n.NodeType == HierarchyNodeType.Folder)
{
// add the folder to the path....
strBaseDir = n.Url;
}
switch (op)
{
case VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE:
// new item added. Need to copy template to new location and then add new location
strNewFileName = Path.Combine(strBaseDir, itemName);
break;
case VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE:// TODO: VSADDITEMOP_LINKTOFILE
// we do not support this right now
throw new NotImplementedException("VSADDITEMOP_LINKTOFILE");
case VSADDITEMOPERATION.VSADDITEMOP_OPENFILE: {
string strFileName = Path.GetFileName(file);
strNewFileName = Path.Combine(strBaseDir, strFileName);
}
break;
case VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD: // TODO: VSADDITEMOP_RUNWIZARD
throw new NotImplementedException("VSADDITEMOP_RUNWIZARD");
}
child = this.FindChild(strNewFileName);
if (child != null)
{
// file already exists in project... message box
actualFiles[index] = strNewFileName;
string msg = SR.GetString(SR.FileAlreadyInProject);
string caption = SR.GetString(SR.FileAlreadyInProjectCaption);
if (RTLAwareMessageBox.Show(null, msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 0) == DialogResult.Yes)
{
child = null;
fOverwrite = true;
}
}
if (child == null)
{
// the next will be equal if file is already in the project DIR
if (NativeMethods.IsSamePath(file, strNewFileName) == false)
{
if (!fOverwrite && File.Exists(strNewFileName))
{
string msg = String.Format(SR.GetString(SR.FileAlreadyExists), strNewFileName);
string caption = SR.GetString(SR.FileAlreadyExistsCaption);
if (RTLAwareMessageBox.Show(null, msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 0) != DialogResult.Yes)
{
return NativeMethods.S_OK;
}
}
try {
this.CopyUrlToLocal(file, strNewFileName, op == VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE);
actualFiles[index] = strNewFileName;
}
catch (Exception e)
{
string caption = SR.GetString(SR.FileCopyError);
RTLAwareMessageBox.Show(null, e.Message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
return NativeMethods.S_OK;
}
}
fFileAdded = true;
}
if (fFileAdded && !fOverwrite)
{
// now add the new thing to the project
//.........这里部分代码省略.........
开发者ID:hesam,项目名称:SketchSharp,代码行数:101,代码来源:Project.cs
示例16: AddItem
/// <summary>
/// Adds an item to the project.
/// </summary>
/// <param name="path">The full path of the item to add.</param>
/// <param name="op">The <paramref name="VSADDITEMOPERATION"/> to use when adding the item.</param>
/// <returns>A ProjectItem object. </returns>
protected virtual EnvDTE.ProjectItem AddItem(string path, VSADDITEMOPERATION op) {
CheckProjectIsValid();
return UIThread.Instance.RunSync<EnvDTE.ProjectItem>(() => {
string ext = Path.GetExtension(path);
foreach (var extension in this.Project.ProjectNode.CodeFileExtensions) {
// http://pytools.codeplex.com/workitem/617
// We are currently in create project from existing code mode. The wizard walks all of the top-level
// files and adds them. It then lets us handle any subdirectories by calling AddFromDirectory.
// But we want to filter the files for both top-level and subdirectories. Therefore we derive from
// PageManager and track when we're running the wizard and adding files for the wizard. If we are
// currently adding them ignore anything other than a .py/.pyw files - returnning null is fine
// here, the wizard doesn't care about the result.
if (String.Compare(ext, extension, StringComparison.OrdinalIgnoreCase) == 0) {
ProjectNode proj = this.Project.ProjectNode;
EnvDTE.ProjectItem itemAdded = null;
using (AutomationScope scope = new AutomationScope(this.Project.ProjectNode.Site)) {
VSADDRESULT[] result = new VSADDRESULT[1];
ErrorHandler.ThrowOnFailure(proj.AddItem(this.NodeWithItems.ID, op, path, 0, new string[1] { path }, IntPtr.Zero, result));
string fileName = System.IO.Path.GetFileName(path);
string fileDirectory = proj.GetBaseDirectoryForAddingFiles(this.NodeWithItems);
string filePathInProject = System.IO.Path.Combine(fileDirectory, fileName);
itemAdded = this.EvaluateAddResult(result[0], filePathInProject);
}
return itemAdded;
}
}
return null;
});
}
开发者ID:vairam-svs,项目名称:poshtools,代码行数:40,代码来源:OAProjectItems.cs
示例17: AddProject
int IVsProject.AddItem(uint itemidLoc, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, VSADDRESULT[] pResult)
{
if (Directory.Exists(rgpszFilesToOpen[0]))
{
AddProject(new MockVSHierarchy(rgpszFilesToOpen[0], this));
}
else
{
children.Add(rgpszFilesToOpen[0]);
if (project != null)
{
FileInfo itemFileInfo = new FileInfo(rgpszFilesToOpen[0]);
project.Save(fileName);
FileInfo projectFileInfo = new FileInfo(project.FullFileName);
string itemName = itemFileInfo.FullName.Substring(projectFileInfo.Directory.FullName.Length + 1);
project.AddNewItem("Compile", itemName);
project.Save(fileName);
}
}
return VSConstants.S_OK;
}
开发者ID:attilah,项目名称:ProjectLinker,代码行数:21,代码来源:MockVsHierarchy.cs
示例18: AddManyItemsHelper
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;
}
开发者ID:vestild,项目名称:nemerle,代码行数:31,代码来源:NemerleProjectNode.cs
示例19: AddItem
/// <summary>
/// Adds an item to the project.
/// </summary>
/// <param name="path">The full path of the item to add.</param>
/// <param name="op">The <paramref name="VSADDITEMOPERATION" /> to use when adding the item.</param>
/// <returns>A ProjectItem object. </returns>
protected virtual ProjectItem AddItem(string path, VSADDITEMOPERATION op)
{
if (Project == null || Project.Project == null || Project.Project.Site == null || Project.Project.IsClosed)
{
throw new InvalidOperationException();
}
return UIThread.DoOnUIThread(delegate
{
var proj = Project.Project;
ProjectItem itemAdded = null;
using (var scope = new AutomationScope(Project.Project.Site))
{
var result = new VSADDRESULT[1];
ErrorHandler.ThrowOnFailure(proj.AddItem(NodeWithItems.ID, op, path, 0, new string[1] {path},
IntPtr.Zero, result));
var fileName = Path.GetFileName(path);
var fileDirectory = proj.GetBaseDirectoryForAddingFiles(NodeWithItems);
var filePathInProject = Path.Combine(fileDirectory, fileName);
itemAdded = EvaluateAddResult(result[0], filePathInProject);
}
return itemAdded;
});
}
开发者ID:mimura1133,项目名称:vstex,代码行数:34,代码来源:OAProjectItems.cs
示例20: AddItem
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);
}
开发者ID:vestild,项目名称:nemerle,代码行数:4,代码来源:NemerleProjectNode.cs
注:本文中的VSADDITEMOPERATION类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论