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

C# Package.HierarchyNode类代码示例

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

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



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

示例1: IsNodeNonMemberItem

        private static bool IsNodeNonMemberItem(HierarchyNode node, object criteria)
        {
            bool isNonMemberItem = false;
            if (node != null)
            {
                object propObj = node.GetProperty((int) __VSHPROPID.VSHPROPID_IsNonMemberItem);
                if (propObj != null)
                {
                    Boolean.TryParse(propObj.ToString(), out isNonMemberItem);
                }
            }

            return isNonMemberItem;
        }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:14,代码来源:WixProjectMembers.cs


示例2: 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)
        {
            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);
            }

            if (dropDataType != DropDataType.None && filesDropped.Count > 0)
            {
                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))
                    {
                        return dropDataType;
                    }
                }
            }

            // 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:einaregilsson,项目名称:Process-Language-Runtime,代码行数:55,代码来源:ProjectNode.CopyPaste.cs


示例3: NodeProperties

 public NodeProperties(HierarchyNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     this.node = node;
 }
开发者ID:zooba,项目名称:wix3,代码行数:8,代码来源:nodeproperties.cs


示例4: FolderNodeProperties

 public FolderNodeProperties(HierarchyNode node)
     : base(node)
 {
 }
开发者ID:zooba,项目名称:wix3,代码行数:4,代码来源:nodeproperties.cs


示例5: SingleFileGeneratorNodeProperties

 public SingleFileGeneratorNodeProperties(HierarchyNode node)
     : base(node)
 {
 }
开发者ID:zooba,项目名称:wix3,代码行数:4,代码来源:nodeproperties.cs


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


示例7: PasteFromClipboard

 /// <summary>
 /// Handle the Paste operation to a targetNode
 /// </summary>
 protected internal override int PasteFromClipboard(HierarchyNode targetNode)
 {
     int returnValue;
     try
     {
         this.isInPasteOrDrop = true;
         this.dropAsCopy = !this.dataWasCut;
         returnValue = PasteFromClipboardCore(targetNode);
     }
     finally
     {
         this.isInPasteOrDrop = false;
         this.dropAsCopy = false;
         this.pasteAsNonMemberItem = false;
     }
     return returnValue;
 }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:20,代码来源:projectnode.copypaste.cs


示例8: WalkSourceProjectAndAdd

        /// <summary>
        /// Recursive method that walk a hierarchy and add items it find to our project.
        /// Note that this is meant as an helper to the Copy&Paste/Drag&Drop functionality.
        /// </summary>
        /// <param name="sourceHierarchy">Hierarchy to walk</param>
        /// <param name="itemId">Item ID where to start walking the hierarchy</param>
        /// <param name="targetNode">Node to start adding to</param>
        /// <param name="name">Folder name to use</param>
        /// <param name="addSiblings">Typically false on first call and true after that</param>
        /// <remarks>Use this method when the folder name to add items to is not
        /// the same as the source.</remarks>
        protected virtual void WalkSourceProjectAndAdd(IVsHierarchy sourceHierarchy, uint itemId, HierarchyNode targetNode, string name, bool addSiblings)
        {
            // Before we start the walk, add the current node
            object variant = null;
            HierarchyNode newNode = targetNode;
            if (itemId != VSConstants.VSITEMID_NIL)
            {
                // Calculate the corresponding path in our project
                string targetPath = Path.Combine(GetBaseDirectoryForAddingFiles(targetNode), name);

                // See if this is a linked item (file can be linked, not folders)
                VSADDITEMOPERATION addItemOp = VSADDITEMOPERATION.VSADDITEMOP_OPENFILE;
                ErrorHandler.ThrowOnFailure(sourceHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_BrowseObject, out variant), VSConstants.E_NOTIMPL);
                VSLangProj.FileProperties fileProperties = variant as VSLangProj.FileProperties;
                if (fileProperties != null && fileProperties.IsLink)
                {
                    addItemOp = VSADDITEMOPERATION.VSADDITEMOP_LINKTOFILE;
                    targetPath = fileProperties.FullPath;
                }

                ErrorHandler.ThrowOnFailure(sourceHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, out variant), VSConstants.E_NOTIMPL);
                bool oldPasteAsNonMemberItem = this.PasteAsNonMemberItem;
                try
                {
                    this.pasteAsNonMemberItem = variant != null && (bool)variant;
                    newNode = AddNodeIfTargetExistInStorage(targetNode, name, targetPath, addItemOp);
                }
                finally
                {
                    this.pasteAsNonMemberItem = oldPasteAsNonMemberItem;
                }

                // Start with child nodes (depth first)
                variant = null;
                ErrorHandler.ThrowOnFailure(sourceHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_FirstVisibleChild, out variant));

                uint currentItemID;
                if (variant is int)
                {
                    currentItemID = (uint)System.BitConverter.ToUInt32(System.BitConverter.GetBytes((int)variant), 0);
                }
                else
                {
                    currentItemID = (uint)variant;
                }
                WalkSourceProjectAndAdd(sourceHierarchy, currentItemID, newNode, true);

                if (addSiblings)
                {
                    // Then look at siblings
                    currentItemID = itemId;
                    while (currentItemID != VSConstants.VSITEMID_NIL)
                    {
                        variant = null;
                        ErrorHandler.ThrowOnFailure(sourceHierarchy.GetProperty(currentItemID, (int)__VSHPROPID.VSHPROPID_NextVisibleSibling, out variant));
                        if (variant is int)
                        {
                            currentItemID = (uint)System.BitConverter.ToUInt32(System.BitConverter.GetBytes((int)variant), 0);
                        }
                        else
                        {
                            currentItemID = (uint)variant;
                        }
                        WalkSourceProjectAndAdd(sourceHierarchy, currentItemID, targetNode, false);
                    }
                }
            }
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:79,代码来源:projectnode.copypaste.cs


示例9: OnItemsAppended

 /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.OnItemsAppended"]/*' />
 public void OnItemsAppended(HierarchyNode parent){
     HierarchyNode foo;
     foo = this.projectMgr == null ? this : this.projectMgr;
     try{
         foreach (IVsHierarchyEvents sink in foo.hierarchyEventSinks){
             sink.OnItemsAppended(parent.hierarchyId);
         }
     } catch{
     }
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:11,代码来源:Hierarchy.cs


示例10: OnItemAdded

 /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.OnItemAdded"]/*' />
 public void OnItemAdded(HierarchyNode parent, HierarchyNode child){
     HierarchyNode foo;
     foo = this.projectMgr == null ? this : this.projectMgr;
     HierarchyNode prev = child.PreviousSibling;
     uint prevId = (prev != null) ? prev.hierarchyId : VsConstants.VSITEMID_NIL;
     try{
         foreach (IVsHierarchyEvents sink in foo.hierarchyEventSinks){
             sink.OnItemAdded(parent.hierarchyId, prevId, child.hierarchyId);
         }
     } catch{
     }
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:13,代码来源:Hierarchy.cs


示例11: AddNewFolder

        /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.AddNewFolder"]/*' />
        /// <summary>
        /// Get's called to a add a new Folder to the project hierarchy. Opens the dialog to do so and
        /// creates the physical representation
        /// </summary>
        /// <returns></returns>
        public int AddNewFolder(){
            // first generate a new folder name...
            try{
                string relFolder;
                object dummy = null;
                IVsProject3 project = (IVsProject3)this.projectMgr;
                IVsUIHierarchyWindow uiWindow = this.projectMgr.GetIVsUIHierarchyWindow(VsConstants.Guid_SolutionExplorer);

                project.GenerateUniqueItemName(this.hierarchyId, "", "", out relFolder);

                if (this != this.projectMgr){
                    // add this guys relpath to it...
                    relFolder = this.xmlNode.GetAttribute("RelPath") + relFolder;
                }
                // create the project part of it, the xml in the xsproj file
                XmlElement e = this.projectMgr.AddFolderNodeToProject(relFolder);
                HierarchyNode child = new HierarchyNode(this.projectMgr, HierarchyNodeType.Folder, e);
                this.AddChild(child);

                child.CreateDirectory();
                // we need to get into label edit mode now...
                // so first select the new guy...
                uiWindow.ExpandItem(this.projectMgr, child.hierarchyId, EXPANDFLAGS.EXPF_SelectItem);
                // them post the rename command to the shell. Folder verification and creation will
                // happen in the setlabel code...
                this.projectMgr.UIShell.PostExecCommand(ref VsConstants.guidStandardCommandSet97, (uint)VsCommands.Rename, 0, ref dummy);
            } catch{
            }

            return 0;
        }
开发者ID:hesam,项目名称:SketchSharp,代码行数:37,代码来源:Hierarchy.cs


示例12: RemoveChild

        /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.RemoveChild"]/*' />
        public virtual void RemoveChild(HierarchyNode node){
            this.projectMgr.ItemIdMap.Remove(node);

            HierarchyNode last = null;
            for (HierarchyNode n = this.firstChild; n != null; n = n.nextSibling){
                if (n == node){
                    if (last != null){
                        last.nextSibling = n.nextSibling;
                    }
                    if (n == this.lastChild){
                        if (last == this.lastChild){
                            this.lastChild = null;
                        } else{
                            this.lastChild = last;
                        }
                    }
                    if (n == this.firstChild){
                        this.firstChild = n.nextSibling;
                    }
                    return;
                }
                last = n;
            }
            throw new InvalidOperationException("Node not found");
        }
开发者ID:hesam,项目名称:SketchSharp,代码行数:26,代码来源:Hierarchy.cs


示例13: Set

 public void Set(HierarchyNode node) {
   selection.Clear();
   selection.Add(new NodeProperties(node));
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:4,代码来源:selection.cs


示例14: Add

 public void Add(HierarchyNode node) {
   selection.Add(new NodeProperties(node));
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:3,代码来源:selection.cs


示例15: SelectionContainer

 public SelectionContainer(HierarchyNode node) {
   selection = new ArrayList();
   selection.Add(new NodeProperties(node));
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:4,代码来源:selection.cs


示例16: AddFolderFromOtherProject

        /// <summary>
        /// This is used to recursively add a folder from an other project.
        /// Note that while we copy the folder content completely, we only
        /// add to the project items which are part of the source project.
        /// </summary>
        /// <param name="folderToAdd">Project reference (from data object) using the format: {Guid}|project|folderPath</param>
        /// <param name="targetNode">Node to add the new folder to</param>
        /// <param name="dropEffect">The drop effect</param>
        /// <param name="validateOnly">If true, no action is actually taken. Only checks for error cases.</param>
        protected internal virtual void AddFolderFromOtherProject(string folderToAdd, HierarchyNode targetNode, uint dropEffect, bool validateOnly)
        {
            if (String.IsNullOrEmpty(folderToAdd))
                throw new ArgumentNullException("folderToAdd");
            if (targetNode == null)
                throw new ArgumentNullException("targetNode");

            // get the source path
            Guid projectInstanceGuid;
            string folder = GetSourceFromFolderReference(folderToAdd, out projectInstanceGuid);
            string folderNoTrailingSlash = folder.Substring(0, folder.Length - 1);

            // Get the target path
            string folderName = Path.GetFileName(Path.GetDirectoryName(folder));
            string newFolderBaseDir = GetBaseDirectoryForAddingFiles(targetNode);
            string targetPath = Path.Combine(newFolderBaseDir, folderName);

            bool bPathsSame = NativeMethods.IsSamePath(folderNoTrailingSlash, targetPath);

            if (!bPathsSame && targetPath.StartsWith(folder, StringComparison.Ordinal))
            {
                throw new DestionPathSubfolderOfSourceException(folderName);
            }

            // If these paths are the same, allow it and prepend "Copy of" only
            // if it was copied to clipboard or dragged with copy effect
            if (bPathsSame && (!this.SourceDragged && !this.dataWasCut) || (this.SourceDragged && dropEffect == (uint)DropEffect.Copy))
            {
                // When validating, do not find a free directory
                // Validation is finished at this point.
                if (validateOnly)
                    return;

                int copyNumber = 0;
                string originalFolderName = folderName;
                while (Directory.Exists(targetPath))
                {
                    copyNumber++;
                    if (copyNumber == 1)
                    {
                        folderName = SR.GetString(SR.CopyOfFile, originalFolderName);
                    }
                    else
                    {
                        folderName = SR.GetString(SR.CopyNOfFile, copyNumber, originalFolderName);
                    }
                    targetPath = Path.Combine(newFolderBaseDir, folderName);
                }
            }

            // Do not perform copy if paths are still the same.
            if (NativeMethods.IsSamePath(folderNoTrailingSlash, targetPath))
            {
                throw new DestionPathSameAsSourceException(folderName);
            }

            if (Directory.Exists(targetPath))
            {
                throw new DestinationFolderAlreadyExists(folderName);
            }

            if (validateOnly)
                return;

            // Recursively copy the directory to the new location
            Utilities.RecursivelyCopyDirectory(folder, targetPath);

            // Retrieve the project from which the items are being copied
            IVsHierarchy sourceHierarchy;
            IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));
            ErrorHandler.ThrowOnFailure(solution.GetProjectOfGuid(ref projectInstanceGuid, out sourceHierarchy));

            // Then retrieve the item ID of the item to copy
            uint itemID = VSConstants.VSITEMID_ROOT;
            ErrorHandler.ThrowOnFailure(sourceHierarchy.ParseCanonicalName(folder, out itemID));

            // Ensure we don't end up in an endless recursion
            if (Utilities.IsSameComObject(this, sourceHierarchy))
            {
                HierarchyNode cursorNode = targetNode;
                while (cursorNode != null)
                {
                    if (String.Compare(folder, cursorNode.GetMkDocument(), StringComparison.OrdinalIgnoreCase) == 0)
                        throw new ApplicationException();
                    cursorNode = cursorNode.Parent;
                }
            }

            // Now walk the source project hierarchy to see which node needs to be added.
            WalkSourceProjectAndAdd(sourceHierarchy, itemID, targetNode, folderName, false);
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:100,代码来源:projectnode.copypaste.cs


示例17: OnPropertyChanged

 /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.OnPropertyChanged"]/*' />
 public void OnPropertyChanged(HierarchyNode node, int propid, uint flags){
     HierarchyNode foo;
     foo = this.projectMgr == null ? this : this.projectMgr;
     foreach (IVsHierarchyEvents sink in foo.hierarchyEventSinks){
         sink.OnPropertyChanged(node.hierarchyId, propid, flags);
     }
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:8,代码来源:Hierarchy.cs


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


示例19: OnInvalidateItems

 /// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.OnInvalidateItems"]/*' />
 public void OnInvalidateItems(HierarchyNode parent){
     HierarchyNode foo;
     foo = this.projectMgr == null ? this : this.projectMgr;
     foreach (IVsHierarchyEvents sink in foo.hierarchyEventSinks){
         sink.OnInvalidateItems(parent.hierarchyId);
     }
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:8,代码来源:Hierarchy.cs


示例20: PasteFromClipboardCore

        /// <summary>
        /// Handle the Paste operation to a targetNode. Do not call directly
        /// outside of PasteFromClipboard.
        /// </summary>
        private int PasteFromClipboardCore(HierarchyNode targetNode)
        {
            int returnValue = (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;

            //Get the clipboardhelper service and use it after processing dataobject
            IVsUIHierWinClipboardHelper clipboardHelper = (IVsUIHierWinClipboardHelper)GetService(typeof(SVsUIHierWinClipboardHelper));
            if (clipboardHelper == null)
            {
                return VSConstants.E_FAIL;
            }

            try
            {
                //Get dataobject from clipboard
                IOleDataObject dataObject = null;
                ErrorHandler.ThrowOnFailure(UnsafeNativeMethods.OleGetClipboard(out dataObject));
                if (dataObject == null)
                {
                    return VSConstants.E_UNEXPECTED;
                }

                DropEffect dropEffect = DropEffect.None;
                DropDataType dropDataType = DropDataType.None;
                try
                {
                    this.SourceDraggedOrCutOrCopied = this.dataWasCut;
                    dropDataType = this.ProcessSelectionDataObject(dataObject, targetNode.GetDragTargetHandlerNode(), 0);
                    dropEffect = this.QueryDropEffect(dropDataType, 0);
                }
                catch (ExternalException e)
                {
                    Trace.WriteLine("Exception : " + e.Message);

                    // If it is a drop from windows and we get any kind of error ignore it. This
                    // prevents bogus messages from the shell from being displayed
                    if (dropDataType != DropDataType.Shell)
                    {
                        throw e;
                    }
                }
                finally
                {
                    // Inform VS (UiHierarchyWindow) of the paste
                    returnValue = clipboardHelper.Paste(dataObject, (uint)dropEffect);
                }
            }
            catch (COMException e)
            {
                Trace.WriteLine("Exception : " + e.Message);

                returnValue = e.ErrorCode;
            }

            return returnValue;
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:59,代码来源:projectnode.copypaste.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Package.ParseRequest类代码示例发布时间:2022-05-26
下一篇:
C# Interop.IDataObject类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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