当前位置: 首页>>代码示例>>C#>>正文


C# Package.HierarchyNode类代码示例

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


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


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