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


C# TreeNode.IsDirectoryNode方法代码示例

本文整理汇总了C#中System.Windows.Forms.TreeNode.IsDirectoryNode方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.IsDirectoryNode方法的具体用法?C# TreeNode.IsDirectoryNode怎么用?C# TreeNode.IsDirectoryNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TreeNode的用法示例。


在下文中一共展示了TreeNode.IsDirectoryNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TreeNodeComparer

        private static int TreeNodeComparer(TreeNode first, TreeNode second)
        {
            bool isFirstDirectory = first.IsDirectoryNode();
            bool isSecondDirectory = second.IsDirectoryNode();

            if (isFirstDirectory && !isSecondDirectory)
            {
                return -1;
            }
            else if (!isFirstDirectory && isSecondDirectory)
            {
                return 1;
            }
            else
            {
                return first.Text.CompareTo(second.Text);
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:18,代码来源:TreeNodeCollectionExtensions.cs

示例2: AddDirectory

        public void AddDirectory(string folderName, TreeNode treeNodeToAddTo)
        {

            if (treeNodeToAddTo.IsGlobalContentContainerNode())
            {
                string rootDirectory = FileManager.RelativeDirectory;
                if (ProjectManager.ContentProject != null)
                {
                    rootDirectory = ProjectManager.ContentProject.Directory;
                }

                string directory = rootDirectory + "GlobalContent/" + folderName;

                Directory.CreateDirectory(directory);
            }
            else if (treeNodeToAddTo.IsRootEntityNode())
            {
                string directory = FileManager.RelativeDirectory + "Entities/" +
                    folderName;

                Directory.CreateDirectory(directory);
            }
            else if (treeNodeToAddTo.IsDirectoryNode())
            {
                // This used to use RelativeDirectory, but
                // I think we want this to be content, so not
                // sure why it uses RelativeDirectory...
                //string directory = FileManager.RelativeDirectory +
                //    currentTreeNode.GetRelativePath() +
                //    tiw.Result;
                // Update October 16, 2011
                // An Enity has both folders
                // in the code folder (represented
                // by RelativeDirectory) as well as
                // in the Content project.  An Entity
                // may not have files in the Content folder,
                // but it must have code files.  Therefore, we
                // create folders in the code directory tree and
                // we worry about content when NamedObjectSaves are
                // added to a given Entity later.
                //string directory = currentTreeNode.GetRelativePath() +
                //    tiw.Result;
                // Update February 17, 2012
                // But...when we add a new folder
                // to an Entity, we want that folder
                // to show up in the tree view in Glue.
                // Glue only scans the content folder, so
                // we want to make sure this folder exists
                // so it shows up okay.

                string directory = FileManager.RelativeDirectory +
                        treeNodeToAddTo.GetRelativePath() +
                        folderName;
                directory = ProjectManager.MakeAbsolute(directory, true);

                Directory.CreateDirectory(directory);

                directory = ProjectManager.ContentDirectory +
                        treeNodeToAddTo.GetRelativePath() +
                        folderName;
                directory = ProjectManager.MakeAbsolute(directory, true);

                Directory.CreateDirectory(directory);

            }
            else if (treeNodeToAddTo.IsFilesContainerNode() || treeNodeToAddTo.IsFolderInFilesContainerNode())
            {
                string directory =
                    treeNodeToAddTo.GetRelativePath() + folderName;

                Directory.CreateDirectory(ProjectManager.MakeAbsolute(directory, true));

                if (EditorLogic.CurrentEntityTreeNode != null)
                {
                    EditorLogic.CurrentEntityTreeNode.UpdateReferencedTreeNodes();
                }
                else if (EditorLogic.CurrentScreenTreeNode != null)
                {
                    EditorLogic.CurrentScreenTreeNode.UpdateReferencedTreeNodes();
                }
            }
            else if (treeNodeToAddTo.IsFolderInFilesContainerNode())
            {

                throw new NotImplementedException();
            }

            var containingElementNode = treeNodeToAddTo.GetContainingElementTreeNode();

            IElement element = null;
            if (containingElementNode != null)
            {
                element = containingElementNode.Tag as IElement;
            }

            if (containingElementNode == null)
            {
                GlueCommands.Self.RefreshCommands.RefreshGlobalContent();
            }
            else
//.........这里部分代码省略.........
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:101,代码来源:ProjectCommands.cs

示例3: RemoveGlobalContentTreeNodesIfNecessary

        private static void RemoveGlobalContentTreeNodesIfNecessary(TreeNode treeNode)
        {
            if (treeNode.IsDirectoryNode())
            {
                string directory = treeNode.GetRelativePath();

                directory = ProjectManager.MakeAbsolute(directory, true);


                if (!Directory.Exists(directory))
                {
                    // The directory isn't here anymore, so kill it!
                    treeNode.Parent.Nodes.Remove(treeNode);

                }
                else
                {
                    // The directory is valid, but let's check subdirectories
                    for (int i = treeNode.Nodes.Count - 1; i > -1; i--)
                    {
                        RemoveGlobalContentTreeNodesIfNecessary(treeNode.Nodes[i]);
                    }
                }
            }
            else // assume content for now
            {

                ReferencedFileSave referencedFileSave = treeNode.Tag as ReferencedFileSave;

                if (!ProjectManager.GlueProjectSave.GlobalFiles.Contains(referencedFileSave))
                {
                    treeNode.Parent.Nodes.Remove(treeNode);
                }
                else
                {
                    // The RFS may be contained, but see if the file names match
                    string rfsName = FileManager.Standardize(referencedFileSave.Name, null, false).ToLower();
                    string treeNodeFile = FileManager.Standardize(treeNode.GetRelativePath(), null, false).ToLower();

                    // We first need to make sure that the file is part of GlobalContentFiles.
                    // If it is, then we may have tree node in the wrong folder, so let's get rid
                    // of it.  If it doesn't start with globalcontent/ then we shouldn't remove it here.
                    if (rfsName.StartsWith("globalcontent/") &&  rfsName != treeNodeFile)
                    {
                        treeNode.Parent.Nodes.Remove(treeNode);
                    }
                }
            }
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:49,代码来源:ElementViewWindow.cs

示例4: PopulateRightClickItems


//.........这里部分代码省略.........
            #endregion

            #region IsBehaviorNode
            else if (node.IsBehaviorNode())
            {

                AddRemoveFromProjectItems(form, menu);

            }

            #endregion

            #region IsCodeNode
            else if (node.IsCodeNode())
            {

                menu.Items.Add(form.viewInExplorerToolStripMenuItem);
                menu.Items.Add(form.reGenerateCodeToolStripMenuItem);
            }

            #endregion

            #region IsRootCodeNode

            else if (node.IsRootCodeNode())
            {
                menu.Items.Add(form.reGenerateCodeToolStripMenuItem);
            }


            #endregion

            #region IsDirectoryNode
            else if (node.IsDirectoryNode())
            {
                //menu.Items.Add(form.viewInExplorerToolStripMenuItem);
                menu.Items.Add(mViewContentFilesInExplorer);
                menu.Items.Add(mViewCodeFolderInExplorer);
                menu.Items.Add("-");


                menu.Items.Add(form.addFolderToolStripMenuItem);

                if (node.Root().IsRootEntityNode())
                {
                    menu.Items.Add(form.addEntityToolStripMenuItem);


                    mImportElement.Text = "Import Entity";
                    menu.Items.Add(mImportElement);
                }
                else
                {
                    // If not in the Entities tree structure, assume global content
                    menu.Items.Add(form.addFileToolStripMenuItem);
                }

                menu.Items.Add("-");

                menu.Items.Add(mDeleteFolder);

            }

            #endregion

            #region IsStateListNode
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:67,代码来源:RightClickHelper.cs

示例5: MoveEntityOn

        public static TreeNode MoveEntityOn(EntityTreeNode treeNodeMoving, TreeNode targetNode)
        {
            TreeNode newTreeNode = null;

            #region Moving the Entity into (or out of) a directory
            if (targetNode.IsDirectoryNode() || targetNode.IsRootEntityNode())
            {
                MoveEntityToDirectory(treeNodeMoving, targetNode);
            }

            #endregion

            #region Moving an Entity onto another element to create an instance

            else if (targetNode.IsEntityNode() || targetNode.IsScreenNode() || targetNode.IsRootNamedObjectNode())
            {
                bool isValidDrop = true;
                // Make sure that we don't drop an Entity into its own Objects
                if (targetNode.IsRootNamedObjectNode())
                {
                    if(treeNodeMoving == targetNode.GetContainingElementTreeNode())
                    {

                        isValidDrop = false;
                    }
                }
                if (isValidDrop)
                {
                    newTreeNode = MoveEntityOntoElement(treeNodeMoving, targetNode, newTreeNode);
                }
            }

            #endregion

            #region Moving an Entity onto a NamedObject (currently supports only Lists)

            else if (targetNode.IsNamedObjectNode())
            {
                // Allow drop only if it's a list or Layer
                NamedObjectSave targetNamedObjectSave = targetNode.Tag as NamedObjectSave;

                if (!targetNamedObjectSave.IsList && !targetNamedObjectSave.IsLayer)
                {
                    MessageBox.Show("The target is not a List or Layer so we can't add an Object to it.", "Target not valid");
                }
                if (targetNamedObjectSave.IsLayer)
                {
                    TreeNode parent = targetNode.Parent;

                    newTreeNode = MoveEntityOn(treeNodeMoving, parent);

                    // this created a new NamedObjectSave.  Let's put that on the Layer
                    MoveNamedObject(newTreeNode, targetNode);
                }
                else
                {
                    // Make sure that the two types match
                    string listType = targetNamedObjectSave.SourceClassGenericType;

                    if (listType != treeNodeMoving.EntitySave.Name)
                    {
                        MessageBox.Show("The target list type is of type\n\n" +
                            listType +
                            "\n\nBut the Entity is of type\n\n" +
                            treeNodeMoving.EntitySave.Name +
                            "\n\nCould not add an instance to the list", "Could not add instance");
                    }
                    else
                    {
                        NamedObjectSave namedObject = new NamedObjectSave();
                        namedObject.InstanceName =
                            FileManager.RemovePath(listType) + "1";

                        StringFunctions.MakeNameUnique<NamedObjectSave>(
                            namedObject, targetNamedObjectSave.ContainedObjects);

                        // Not sure if we need to set this or not, but I think 
                        // any instance added to a list will not be defined by base
                        namedObject.DefinedByBase = false;

                        NamedObjectSaveExtensionMethodsGlue.AddNamedObjectToCurrentNamedObjectList(namedObject);

                        ElementViewWindow.GenerateSelectedElementCode();
                        // Don't save the Glux, the caller of this method will take care of it
                        // GluxCommands.Self.SaveGlux();
                    }

                }
            }

            #endregion

            else if (targetNode.IsGlobalContentContainerNode())
            {
                AskAndAddAllContainedRfsToGlobalContent(treeNodeMoving.SaveObjectAsElement);
            }

            return newTreeNode;
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:99,代码来源:ElementViewWindow.DragDrop.cs


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