• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# VSADDRESULT类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中VSADDRESULT的典型用法代码示例。如果您正苦于以下问题:C# VSADDRESULT类的具体用法?C# VSADDRESULT怎么用?C# VSADDRESULT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VSADDRESULT类属于命名空间,在下文中一共展示了VSADDRESULT类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddFromTemplate

		/// <summary>
		/// Creates a new project item from an existing item template file and adds it to the project. 
		/// </summary>
		/// <param name="fileName">The full path and file name of the template project file.</param>
		/// <param name="name">The file name to use for the new project item.</param>
		/// <returns>A ProjectItem object. </returns>
		public override EnvDTE.ProjectItem AddFromTemplate(string fileName, string name)
		{

			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
			{
				// Determine the operation based on the extension of the filename.
				// We should run the wizard only if the extension is vstemplate
				// otherwise it's a clone operation
				VSADDITEMOPERATION op;

				if (Utilities.IsTemplateFile(fileName))
				{
					op = VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD;
				}
				else
				{
					op = VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE;
				}

				VSADDRESULT[] result = new VSADDRESULT[1];

				// It is not a very good idea to throw since the AddItem might return Cancel or Abort.
				// The problem is that up in the call stack the wizard code does not check whether it has received a ProjectItem or not and will crash.
				// The other problem is that we cannot get add wizard dialog back if a cancel or abort was returned because we throw and that code will never be executed. Typical catch 22.
				ErrorHandler.ThrowOnFailure(proj.AddItem(this.NodeWithItems.ID, op, name, 0, new string[1] { fileName }, IntPtr.Zero, result));

				string fileDirectory = proj.GetBaseDirectoryForAddingFiles(this.NodeWithItems);
				string templateFilePath = System.IO.Path.Combine(fileDirectory, name);
				itemAdded = this.EvaluateAddResult(result[0], templateFilePath);
			}
			finally
			{
				extensibility.ExitAutomationFunction();
			}

			return itemAdded;
		}
开发者ID:Jeremiahf,项目名称:wix3,代码行数:60,代码来源:oaprojectitems.cs


示例2: 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


示例3: CreateNewFile

        private static void CreateNewFile(NodejsProjectNode projectNode, uint containerId, string fileType) {
            using (var dialog = new NewFileNameForm(GetInitialName(fileType))) {
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                    string itemName = dialog.TextBox.Text;

                    VSADDRESULT[] pResult = new VSADDRESULT[1];
                    projectNode.AddItem(
                        containerId,                                 // Identifier of the container folder. 
                        VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE,    // Indicate that we want to create this new file by cloning a template file.
                        itemName,
                        1,                                           // Number of templates in the next parameter. Must be 1 if using VSADDITEMOP_CLONEFILE.
                        new string[] { GetTemplateFile(fileType) },  // Array contains the template file path.
                        IntPtr.Zero,                                 // Handle to the Add Item dialog box. Must be Zero if using VSADDITEMOP_CLONEFILE.
                        pResult
                    );

                    // TODO: Do we need to check if result[0] = VSADDRESULT.ADDRESULT_Success here?
                }
            }
        }
开发者ID:munyirik,项目名称:nodejstools,代码行数:20,代码来源:NewFileUtilities.cs


示例4: 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, but public for FSharp.Project.dll*/
 public virtual HierarchyNode AddNodeIfTargetExistInStorage(HierarchyNode parentNode, string name, string targetPath)
 {
     HierarchyNode newNode = parentNode;
     // If the file/directory exist, add a node for it
     if (FSSafe.File.SafeExists(targetPath))
     {
         VSADDRESULT[] result = new VSADDRESULT[1];
         ErrorHandler.ThrowOnFailure(this.AddItem(parentNode.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, 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:svick,项目名称:visualfsharp,代码行数:28,代码来源:ProjectNode.CopyPaste.cs


示例5: CreateNewFile

        internal static void CreateNewFile(NodejsProjectNode projectNode, uint containerId) {
            using (var dialog = new NewFileNameForm("")) {
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                    string itemName = dialog.TextBox.Text;
                    if (string.IsNullOrWhiteSpace(itemName)) {
                        return;
                    }
                    itemName = itemName.Trim();

                    VSADDRESULT[] pResult = new VSADDRESULT[1];
                    projectNode.AddItem(
                        containerId,                                 // Identifier of the container folder. 
                        VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE,    // Indicate that we want to create this new file by cloning a template file.
                        itemName,
                        1,                                           // Number of templates in the next parameter. Must be 1 if using VSADDITEMOP_CLONEFILE.
                        new string[] { Path.GetTempFileName() },     // Array contains the template file path.
                        IntPtr.Zero,                                 // Handle to the Add Item dialog box. Must be Zero if using VSADDITEMOP_CLONEFILE.
                        pResult);
                }
            }
        }
开发者ID:paladique,项目名称:nodejstools,代码行数:21,代码来源:NewFileUtilities.cs


示例6:

 int IVsProject.AddItem(uint itemidLoc, VSADDITEMOPERATION dwAddItemOperation, string pszItemName, uint cFilesToOpen, string[] rgpszFilesToOpen, IntPtr hwndDlgOwner, VSADDRESULT[] pResult) {
     return _innerProject.AddItem(itemidLoc, dwAddItemOperation, pszItemName, cFilesToOpen, rgpszFilesToOpen, hwndDlgOwner, pResult);
 }
开发者ID:zooba,项目名称:PTVS,代码行数:3,代码来源:PythonWebProject.cs


示例7: 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


示例8: EvaluateAddResult

        /// <summary>
        /// Evaluates the result of an add operation.
        /// </summary>
        /// <param name="result">The <paramref name="VSADDRESULT"/> returned by the Add methods</param>
        /// <param name="path">The full path of the item added.</param>
        /// <returns>A ProjectItem object.</returns>
        private EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path) {
            return Project.ProjectNode.Site.GetUIThread().Invoke<EnvDTE.ProjectItem>(() => {
                if (result != VSADDRESULT.ADDRESULT_Failure) {
                    if (Directory.Exists(path)) {
                        path = CommonUtils.EnsureEndSeparator(path);
                    }
                    HierarchyNode nodeAdded = this.NodeWithItems.ProjectMgr.FindNodeByFullPath(path);
                    Debug.Assert(nodeAdded != null, "We should have been able to find the new element in the hierarchy");
                    if (nodeAdded != null) {
                        EnvDTE.ProjectItem item = null;
                        var fileNode = nodeAdded as FileNode;
                        if (fileNode != null) {
                            item = new OAFileItem(this.Project, fileNode);
                        } else {
                            item = new OAProjectItem(this.Project, nodeAdded);
                        }

                        return item;
                    }
                }
                return null;
            });
        }
开发者ID:bnavarma,项目名称:ScalaTools,代码行数:29,代码来源:OAProjectItems.cs


示例9: AddFromTemplate

        /// <summary>
        /// Creates a new project item from an existing item template file and adds it to the project. 
        /// </summary>
        /// <param name="fileName">The full path and file name of the template project file.</param>
        /// <param name="name">The file name to use for the new project item.</param>
        /// <returns>A ProjectItem object. </returns>
        public override EnvDTE.ProjectItem AddFromTemplate(string fileName, string name) {
            CheckProjectIsValid();

            ProjectNode proj = this.Project.ProjectNode;
            EnvDTE.ProjectItem itemAdded = null;

            using (AutomationScope scope = new AutomationScope(this.Project.ProjectNode.Site)) {
                // Determine the operation based on the extension of the filename.
                // We should run the wizard only if the extension is vstemplate
                // otherwise it's a clone operation
                VSADDITEMOPERATION op;
                Project.ProjectNode.Site.GetUIThread().Invoke(() => {
                    if (Utilities.IsTemplateFile(fileName)) {
                        op = VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD;
                    } else {
                        op = VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE;
                    }

                    VSADDRESULT[] result = new VSADDRESULT[1];

                    // It is not a very good idea to throw since the AddItem might return Cancel or Abort.
                    // The problem is that up in the call stack the wizard code does not check whether it has received a ProjectItem or not and will crash.
                    // The other problem is that we cannot get add wizard dialog back if a cancel or abort was returned because we throw and that code will never be executed. Typical catch 22.
                    ErrorHandler.ThrowOnFailure(proj.AddItem(this.NodeWithItems.ID, op, name, 0, new string[1] { fileName }, IntPtr.Zero, result));

                    string fileDirectory = proj.GetBaseDirectoryForAddingFiles(this.NodeWithItems);
                    string templateFilePath = System.IO.Path.Combine(fileDirectory, name);
                    itemAdded = this.EvaluateAddResult(result[0], templateFilePath);
                });
            }

            return itemAdded;
        }
开发者ID:bnavarma,项目名称:ScalaTools,代码行数:39,代码来源:OAProjectItems.cs


示例10: EvaluateAddResult

        protected virtual EnvDTE.ProjectItem EvaluateAddResult(VSADDRESULT result, string path)
        {
            return UIThread.DoOnUIThread(delegate()
            {
                if (result == VSADDRESULT.ADDRESULT_Success)
            {
                HierarchyNode nodeAdded = this.NodeWithItems.FindChild(path);
                Debug.Assert(nodeAdded != null, "We should have been able to find the new element in the hierarchy");
                    if (nodeAdded != null)
                {
                    EnvDTE.ProjectItem item = null;
                        if (nodeAdded is FileNode)
                    {
                        item = new OAFileItem(this.Project, nodeAdded as FileNode);
                    }
                        else if (nodeAdded is NestedProjectNode)
                    {
                        item = new OANestedProjectItem(this.Project, nodeAdded as NestedProjectNode);
                    }
                    else
                    {
                        item = new OAProjectItem<HierarchyNode>(this.Project, nodeAdded);
                    }

                    this.Items.Add(item);
                    return item;
                }
            }
            return null;
            });
        }
开发者ID:zooba,项目名称:wix3,代码行数:31,代码来源:OAProjectItems.cs


示例11: 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


示例12: AddFileToNodeFromProjectReference

        /// <summary>
        /// Adds an item from a project refererence to target node.
        /// </summary>
        /// <param name="projectRef"></param>
        /// <param name="targetNode"></param>
        private bool AddFileToNodeFromProjectReference(string projectRef, HierarchyNode targetNode)
        {
            if (String.IsNullOrEmpty(projectRef))
            {
                throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "projectRef");
            }

            if (targetNode == null)
            {
                throw new ArgumentNullException("targetNode");
            }

            IVsSolution solution = this.GetService(typeof(IVsSolution)) as IVsSolution;
            if (solution == null)
            {
                throw new InvalidOperationException();
            }

            uint itemidLoc;
            IVsHierarchy hierarchy;
            string str;
            VSUPDATEPROJREFREASON[] reason = new VSUPDATEPROJREFREASON[1];
            ErrorHandler.ThrowOnFailure(solution.GetItemOfProjref(projectRef, out hierarchy, out itemidLoc, out str, reason));
            if (hierarchy == null)
            {
                throw new InvalidOperationException();
            }

            // This will throw invalid cast exception if the hierrachy is not a project.
            IVsProject project = (IVsProject)hierarchy;

            string moniker;
            ErrorHandler.ThrowOnFailure(project.GetMkDocument(itemidLoc, out moniker));
            string[] files = new String[1] { moniker };
            VSADDRESULT[] vsaddresult = new VSADDRESULT[1];
            vsaddresult[0] = VSADDRESULT.ADDRESULT_Failure;
            int addResult = targetNode.ProjectMgr.DoAddItem(targetNode.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, 0, files, IntPtr.Zero, vsaddresult, AddItemContext.Paste);
            if (addResult != VSConstants.S_OK && addResult != VSConstants.S_FALSE && addResult != (int)OleConstants.OLECMDERR_E_CANCELED)
            {
                ErrorHandler.ThrowOnFailure(addResult);
                return false;
            }
            return (vsaddresult[0] == VSADDRESULT.ADDRESULT_Success);
        }
开发者ID:CaptainHayashi,项目名称:visualfsharp,代码行数:49,代码来源:ProjectNode.CopyPaste.cs


示例13: 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)
        {
            if (parentNode == null)
            {
                return null;
            }

            var newNode = parentNode;
            // If the file/directory exist, add a node for it
            if (File.Exists(targetPath))
            {
                var result = new VSADDRESULT[1];
                ErrorHandler.ThrowOnFailure(AddItem(parentNode.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, name, 1,
                    new[] {targetPath}, IntPtr.Zero, result));
                if (result[0] != VSADDRESULT.ADDRESULT_Success)
                    throw new Exception();
                newNode = FindChild(targetPath);
                if (newNode == null)
                    throw new Exception();
            }
            else if (Directory.Exists(targetPath))
            {
                newNode = CreateFolderNodes(targetPath);
            }
            return newNode;
        }
开发者ID:mimura1133,项目名称:vstex,代码行数:34,代码来源:ProjectNode.CopyPaste.cs


示例14: AddFiles

        // This is for moving files from one part of our project to another.
        /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.AddFiles"]/*' />
        public void AddFiles(string[] rgSrcFiles){
            if (rgSrcFiles == null || rgSrcFiles.Length == 0)
                return;
            IVsSolution srpIVsSolution = this.GetService(typeof(IVsSolution)) as IVsSolution;
            if (srpIVsSolution == null)
                return;

            IVsProject ourProj = (IVsProject)this.projectMgr;

            foreach (string file in rgSrcFiles){
                uint itemidLoc;
                IVsHierarchy srpIVsHierarchy;
                string str;
                VSUPDATEPROJREFREASON[] reason = new VSUPDATEPROJREFREASON[1];
                srpIVsSolution.GetItemOfProjref(file, out srpIVsHierarchy, out itemidLoc, out str, reason);
                if (srpIVsHierarchy == null){
                    throw new InvalidOperationException();//E_UNEXPECTED;
                }

                IVsProject srpIVsProject = (IVsProject)srpIVsHierarchy;
                if (srpIVsProject == null){
                    continue;
                }

                string cbstrMoniker;
                srpIVsProject.GetMkDocument(itemidLoc, out cbstrMoniker);
                if (File.Exists(cbstrMoniker)){
                    string[] files = new String[1]{ cbstrMoniker };
                    VSADDRESULT[] vsaddresult = new VSADDRESULT[1];
                    vsaddresult[0] = VSADDRESULT.ADDRESULT_Failure;
                    // bugbug: support dropping into subfolder.
                    ourProj.AddItem(this.projectMgr.hierarchyId, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, 1, files, IntPtr.Zero, vsaddresult);
                    if (vsaddresult[0] == VSADDRESULT.ADDRESULT_Cancel){
                        break;
                    }
                }
            }
        }
开发者ID:hesam,项目名称:SketchSharp,代码行数:40,代码来源:Hierarchy.cs


示例15: 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


示例16: ProcessSelectionDataObject

        // ================= Drag/Drop/Cut/Copy/Paste ========================
        // Ported from HeirUtil7\PrjHeir.cpp
        void ProcessSelectionDataObject(Microsoft.VisualStudio.OLE.Interop.IDataObject pDataObject, uint grfKeyState, out DropDataType pddt){
            pddt = DropDataType.None;
            // try HDROP
            FORMATETC fmtetc = DragDropHelper.CreateFormatEtc(CF_HDROP);

            bool hasData = false;
            try{
                DragDropHelper.QueryGetData(pDataObject, ref fmtetc);
                hasData = true;
            } catch (Exception){
            }

            if (hasData){
                try{
                    STGMEDIUM stgmedium = DragDropHelper.GetData(pDataObject, ref fmtetc);
                    if (stgmedium.tymed == (uint)TYMED.TYMED_HGLOBAL){
                        IntPtr hDropInfo = stgmedium.unionmember;
                        if (hDropInfo != IntPtr.Zero){
                            pddt = DropDataType.Shell;
                            try{
                                uint numFiles = DragQueryFile(hDropInfo, 0xFFFFFFFF, null, 0);
                                char[] szMoniker = new char[MAX_PATH + 1];
                                IVsProject vsProj = (IVsProject)this.projectMgr;
                                for (uint iFile = 0; iFile < numFiles; iFile++){
                                    uint len = DragQueryFile(hDropInfo, iFile, szMoniker, MAX_PATH);
                                    string filename = new String(szMoniker, 0, (int)len);
                                    // Is full path returned
                                    if (File.Exists(filename)){
                                        VSADDRESULT[] vsaddresult = new VSADDRESULT[1];
                                        vsaddresult[0] = VSADDRESULT.ADDRESULT_Failure;
                                        string[] files = new String[1]{ filename };
                                        // TODO: support dropping into subfolders...
                                        vsProj.AddItem(this.projectMgr.hierarchyId, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, 1, files, IntPtr.Zero, vsaddresult);
                                    }
                                }
                                Marshal.FreeHGlobal(hDropInfo);
                            } catch (Exception e){
                                Marshal.FreeHGlobal(hDropInfo);
                                throw e;
                            }
                        }
                    }
                    return;
                } catch (Exception){
                    hasData = false;
                }
            }

            if (DragDropHelper.AttemptVsFormat(this, DragDropHelper.CF_VSREFPROJECTITEMS, pDataObject, grfKeyState, out pddt))
                return;

            if (DragDropHelper.AttemptVsFormat(this, DragDropHelper.CF_VSSTGPROJECTITEMS, pDataObject, grfKeyState, out pddt))
                return;
        }
开发者ID:hesam,项目名称:SketchSharp,代码行数:56,代码来源:Hierarchy.cs


示例17: AddFromTemplate

        /// <summary>
        ///     Creates a new project item from an existing item template file and adds it to the project.
        /// </summary>
        /// <param name="fileName">The full path and file name of the template project file.</param>
        /// <param name="name">The file name to use for the new project item.</param>
        /// <returns>A ProjectItem object. </returns>
        public override ProjectItem AddFromTemplate(string fileName, string name)
        {
            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 fixedFileName = fileName;

                    if (!File.Exists(fileName))
                    {
                        var tempFileName = GetTemplateNoZip(fileName);
                        if (File.Exists(tempFileName))
                        {
                            fixedFileName = tempFileName;
                        }
                    }

                    // Determine the operation based on the extension of the filename.
                    // We should run the wizard only if the extension is vstemplate
                    // otherwise it's a clone operation
                    VSADDITEMOPERATION op;

                    if (Utilities.IsTemplateFile(fixedFileName))
                    {
                        op = VSADDITEMOPERATION.VSADDITEMOP_RUNWIZARD;
                    }
                    else
                    {
                        op = VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE;
                    }

                    var result = new VSADDRESULT[1];

                    // It is not a very good idea to throw since the AddItem might return Cancel or Abort.
                    // The problem is that up in the call stack the wizard code does not check whether it has received a ProjectItem or not and will crash.
                    // The other problem is that we cannot get add wizard dialog back if a cancel or abort was returned because we throw and that code will never be executed. Typical catch 22.
                    ErrorHandler.ThrowOnFailure(proj.AddItem(NodeWithItems.ID, op, name, 0,
                        new string[1] {fixedFileName}, IntPtr.Zero, result));

                    var fileDirectory = proj.GetBaseDirectoryForAddingFiles(NodeWithItems);
                    var templateFilePath = Path.Combine(fileDirectory, name);
                    itemAdded = EvaluateAddResult(result[0], templateFilePath);
                }

                return itemAdded;
            });
        }
开发者ID:mimura1133,项目名称:vstex,代码行数:61,代码来源:OAProjectItems.cs


示例18: 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


示例19: AddItemWithSpecific

 public override 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)
 {
     //editor type?
       return base.AddItemWithSpecific(itemIdLoc, op, itemName, filesToOpen, files, dlgOwner, editorFlags, ref editorType, physicalView, ref logicalView, result);
 }
开发者ID:ldematte,项目名称:BlenXVSP,代码行数:5,代码来源:BlenXProjectNode.cs


示例20: ProcessSelectionDataObject

        /// <summary>
        /// Process dataobject from Drag/Drop/Cut/Copy/Paste operation
        /// </summary>
        /// <remarks>The targetNode is set if the method is called from a drop operation, otherwise it is null</remarks>
        internal DropDataType ProcessSelectionDataObject(IOleDataObject dataObject, HierarchyNode targetNode, uint grfKeyState)
        {
            DropDataType dropDataType = DropDataType.None;
            bool isWindowsFormat = false;

            // Try to get it as a directory based project.
            List<string> filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSSTGPROJECTITEMS, dataObject, out dropDataType);
            if (filesDropped.Count == 0)
            {
                filesDropped = DragDropHelper.GetDroppedFiles(DragDropHelper.CF_VSREFPROJECTITEMS, dataObject, out dropDataType);
            }
            if (filesDropped.Count == 0)
            {
                filesDropped = DragDropHelper.GetDroppedFiles(NativeMethods.CF_HDROP, dataObject, out dropDataType);
                isWindowsFormat = (filesDropped.Count > 0);
            }

            dropItems.Clear();

            if (dropDataType != DropDataType.None && filesDropped.Count > 0)
            {
                bool saveAllowDuplicateLinks = this.AllowDuplicateLinks;
                try
                {
                    DropEffect dropEffect = this.QueryDropEffect(dropDataType, grfKeyState);
                    this.dropAsCopy = dropEffect == DropEffect.Copy;
                    if (dropEffect == DropEffect.Move && this.SourceDraggedOrCutOrCopied)
                    {
                        // Temporarily allow duplicate links to enable cut-paste or drag-move of links within the project.
                        // This won't happen when the source is another project because this.SourceDraggedOrCutOrCopied won't get set.
                        this.AllowDuplicateLinks = true;
                    }

                    string[] filesDroppedAsArray = filesDropped.ToArray();

                    HierarchyNode node = (targetNode == null) ? this : targetNode;

                    // For directory based projects the content of the clipboard is a double-NULL terminated list of Projref strings.
                    if (isWindowsFormat)
                    {
                        // This is the code path when source is windows explorer
                        VSADDRESULT[] vsaddresults = new VSADDRESULT[1];
                        vsaddresults[0] = VSADDRESULT.ADDRESULT_Failure;
                        int addResult = AddItem(node.ID, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, null, (uint)filesDropped.Count, filesDroppedAsArray, IntPtr.Zero, vsaddresults);
                        if (addResult != VSConstants.S_OK && addResult != VSConstants.S_FALSE && addResult != (int)OleConstants.OLECMDERR_E_CANCELED
                            && vsaddresults[0] != VSADDRESULT.ADDRESULT_Success)
                        {
                            ErrorHandler.ThrowOnFailure(addResult);
                        }

                        return dropDataType;
                    }
                    else
                    {
                        if (AddFilesFromProjectReferences(node, filesDroppedAsArray, (uint)dropEffect))
                        {
                            return dropDataType;
                        }
                    }
                }
                finally
                {
                    this.AllowDuplicateLinks = saveAllowDuplicateLinks;
                }
            }

            this.dataWasCut = false;

            // If we reached this point then the drop data must be set to None.
            // Otherwise the OnPaste will be called with a valid DropData and that would actually delete the item.
            return DropDataType.None;
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:76,代码来源:projectnode.copypaste.cs



注:本文中的VSADDRESULT类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VSCOMPONENTSELECTORDATA类代码示例发布时间:2022-05-24
下一篇:
C# VSADDITEMOPERATION类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap