當前位置: 首頁>>代碼示例>>C#>>正文


C# TreeNode.Root方法代碼示例

本文整理匯總了C#中System.Windows.Forms.TreeNode.Root方法的典型用法代碼示例。如果您正苦於以下問題:C# TreeNode.Root方法的具體用法?C# TreeNode.Root怎麽用?C# TreeNode.Root使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.TreeNode的用法示例。


在下文中一共展示了TreeNode.Root方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddDirectoryNodes

        internal static void AddDirectoryNodes(string parentDirectory, TreeNode parentTreeNode)
        {
            if (Directory.Exists(parentDirectory))
            {
                string[] directories = Directory.GetDirectories(parentDirectory);

                foreach (string directory in directories)
                {
                    string relativePath = FileManager.MakeRelative(directory, parentDirectory);

                    string nameOfNewNode = relativePath;

                    if (relativePath.Contains('/'))
                    {
                        nameOfNewNode = relativePath.Substring(0, relativePath.IndexOf('/'));
                    }

                    if (!mDirectoriesToIgnore.Contains(nameOfNewNode))
                    {

                        TreeNode treeNode = GlueState.Self.Find.TreeNodeForDirectoryOrEntityNode(relativePath, parentTreeNode);

                        if (treeNode == null)
                        {
                            treeNode = parentTreeNode.Nodes.Add(FileManager.RemovePath(directory));
                        }

                        if (BaseElementTreeNode.UseIcons)
                        {
                            treeNode.ImageKey = "folder.png";
                            treeNode.SelectedImageKey = "folder.png";
                        }

                        treeNode.ForeColor = ElementViewWindow.FolderColor;

                        AddDirectoryNodes(parentDirectory + relativePath + "/", treeNode);
                    }
                }

                // Now see if there are any directory tree nodes that don't have a matching directory

                // Let's make the directories lower case
                for (int i = 0; i < directories.Length; i++)
                {
                    directories[i] = FileManager.Standardize(directories[i]).ToLower();

                    if (!directories[i].EndsWith("/") && !directories[i].EndsWith("\\"))
                    {
                        directories[i] = directories[i] + "/";
                    }
                }

                bool isGlobalContent = parentTreeNode.Root().IsGlobalContentContainerNode();


                for (int i = parentTreeNode.Nodes.Count - 1; i > -1; i--)
                {
                    TreeNode treeNode = parentTreeNode.Nodes[i];

                    if (treeNode.IsDirectoryNode())
                    {

                        string directory = ProjectManager.MakeAbsolute(treeNode.GetRelativePath(), isGlobalContent);

                        directory = FileManager.Standardize(directory.ToLower());

                        if (!directories.Contains(directory))
                        {
                            parentTreeNode.Nodes.RemoveAt(i);
                        }
                    }
                }
            }
        }
開發者ID:GorillaOne,項目名稱:FlatRedBall,代碼行數:74,代碼來源:ElementViewWindow.cs

示例2: PopulateRightClickItems

        ///////////////////////////////////////////////////////////
        public static void PopulateRightClickItems(TreeNode node, MenuShowingAction menuShowingAction = MenuShowingAction.RegularRightClick)
        {

            MainGlueWindow.Self.ElementTreeView.SelectedNode = node;
            MainGlueWindow form = MainGlueWindow.Self;

            ContextMenuStrip menu = MainGlueWindow.Self.mElementContextMenu;

            menu.Items.Clear();


            #region IsScreenNode

            if (node.IsScreenNode())
            {
                if (menuShowingAction == MenuShowingAction.RightButtonDrag)
                {
                    menu.Items.Add(mAddEntityInstance);
                    menu.Items.Add(mAddEntityList);
                }
                else
                {
                    menu.Items.Add(form.setAsStartUpScreenToolStripMenuItem);
                    menu.Items.Add(mMakeRequiredAtStartup);
                    mExportElement.Text = "Export Screen";
                    menu.Items.Add(mExportElement);

                    AddRemoveFromProjectItems(form, menu);

                    if (EditorLogic.CurrentScreenSave.IsRequiredAtStartup)
                    {
                        mMakeRequiredAtStartup.Text = "Remove StartUp Requirement";
                    }
                    else
                    {
                        mMakeRequiredAtStartup.Text = "Make Required at StartUp";
                    }


                    menu.Items.Add("-");
                    menu.Items.Add(mFindAllReferences);
                    menu.Items.Add(mRefreshTreeNodesMenuItem);
                }
            }

            #endregion

            #region IsEntityNode

            else if (node.IsEntityNode())
            {
                if (menuShowingAction == MenuShowingAction.RightButtonDrag)
                {
                    menu.Items.Add(mAddEntityInstance);
                    menu.Items.Add(mAddEntityList);
                }
                else
                {
                    AddRemoveFromProjectItems(form, menu);

                    menu.Items.Add("-");
                    mExportElement.Text = "Export Entity";
                    menu.Items.Add(mExportElement);
                    menu.Items.Add(mFindAllReferences);

                    EntitySave entitySave = ((EntityTreeNode)node).EntitySave;

                    if (entitySave.PooledByFactory)
                    {
                        menu.Items.Add(mAddResetVariablesForPooling);
                    }
                    menu.Items.Add(mRefreshTreeNodesMenuItem);
                }
            }

            #endregion

            #region IsFileContainerNode OR IsFolderInFilesContainerNode

            else if (node.IsFilesContainerNode() || node.IsFolderInFilesContainerNode())
            {
                menu.Items.Add(form.addFileToolStripMenuItem);
                menu.Items.Add(form.addFolderToolStripMenuItem);
                menu.Items.Add("-");
                menu.Items.Add(form.viewInExplorerToolStripMenuItem);
                if (node.IsFolderInFilesContainerNode())
                {
                    menu.Items.Add(mDeleteFolder);
                }
            }

            #endregion

            #region IsScreenObjectContainerNode

            else if (node.IsRootObjectNode())
            {
                if (menuShowingAction == MenuShowingAction.RightButtonDrag)
                {
//.........這裏部分代碼省略.........
開發者ID:gitter-badger,項目名稱:FlatRedBall,代碼行數:101,代碼來源:RightClickHelper.cs


注:本文中的System.Windows.Forms.TreeNode.Root方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。