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


C# TreeNode.Remove方法代码示例

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


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

示例1: TestRemoveExistingNodeThatIsNotRoot

        public void TestRemoveExistingNodeThatIsNotRoot()
        {
            var root = new TreeNode<int>(1);
            root.Add(2);
            root.Add(3);
            root.Add(4);
            root.Children.ElementAt(0).Add(5);
            root.Children.ElementAt(1).Add(6);
            root.Children.ElementAt(2).Add(7);
            bool removalResult = root.Remove(6);
            int[] expected = { 1, 2, 3, 4, 5, 7 };
            var bfEnumerator = root.GetEnumerator(VisitType.BreadthFirst);
            var elements = new List<int>();

            while (bfEnumerator.MoveNext())
            {
                elements.Add(bfEnumerator.Current);
            }

            var actual = elements.ToArray();

            Assert.IsTrue(removalResult);
            Assert.AreEqual(expected.Length, actual.Length);
            Assert.AreEqual(expected.Length, root.Count);

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
开发者ID:gentian-kasa,项目名称:Wall-AI,代码行数:30,代码来源:TreeNodeTest.cs

示例2: TestRemoveExistingNodeThatIsRoot

        public void TestRemoveExistingNodeThatIsRoot()
        {
            var root = new TreeNode<int>(1);
            root.Add(2);
            root.Add(3);
            root.Add(4);
            root.Children.ElementAt(0).Add(5);
            root.Children.ElementAt(1).Add(6);
            root.Children.ElementAt(2).Add(7);
            bool removeResult = root.Remove(1);

            // the removal of the root element is not allowed
            Assert.IsFalse(removeResult);
        }
开发者ID:gentian-kasa,项目名称:Wall-AI,代码行数:14,代码来源:TreeNodeTest.cs

示例3: LoadFromSQL

            private void LoadFromSQL()
            {
                try
                {
                    Runtime.IsConnectionsFileLoaded = false;

                    if (_SQLUsername != "")
                    {
                        sqlCon =
                            new SqlConnection(
                                (string)
                                ("Data Source=" + _SQLHost + ";Initial Catalog=" + _SQLDatabaseName + ";User Id=" +
                                 _SQLUsername + ";Password=" + _SQLPassword));
                    }
                    else
                    {
                        sqlCon =
                            new SqlConnection("Data Source=" + _SQLHost + ";Initial Catalog=" + _SQLDatabaseName +
                                              ";Integrated Security=True");
                    }

                    sqlCon.Open();

                    sqlQuery = new SqlCommand("SELECT * FROM tblRoot", sqlCon);
                    sqlRd = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);

                    sqlRd.Read();

                    if (sqlRd.HasRows == false)
                    {
                        Runtime.SaveConnections();

                        sqlQuery = new SqlCommand("SELECT * FROM tblRoot", sqlCon);
                        sqlRd = sqlQuery.ExecuteReader(CommandBehavior.CloseConnection);

                        sqlRd.Read();
                    }

                    this.confVersion = Convert.ToDouble(sqlRd["confVersion"], CultureInfo.InvariantCulture);

                    TreeNode rootNode;
                    rootNode = new TreeNode((string)(sqlRd["Name"]));

                    Root.Info rInfo = new Root.Info(Root.Info.RootType.Connection);
                    rInfo.Name = rootNode.Text;
                    rInfo.TreeNode = rootNode;

                    rootNode.Tag = rInfo;
                    rootNode.ImageIndex = System.Convert.ToInt32(Images.Enums.TreeImage.Root);
                    rootNode.SelectedImageIndex = System.Convert.ToInt32(Images.Enums.TreeImage.Root);

                    if (Security.Crypt.Decrypt((string)(sqlRd["Protected"]), pW) != "ThisIsNotProtected")
                    {
                        if (Authenticate((string)(sqlRd["Protected"]), false, rInfo) == false)
                        {
                            Settings.Default.LoadConsFromCustomLocation = false;
                            Settings.Default.CustomConsPath = "";
                            rootNode.Remove();
                            return;
                        }
                    }

                    //Me._RootTreeNode.Text = rootNode.Text
                    //Me._RootTreeNode.Tag = rootNode.Tag
                    //Me._RootTreeNode.ImageIndex = Images.Enums.TreeImage.Root
                    //Me._RootTreeNode.SelectedImageIndex = Images.Enums.TreeImage.Root

                    sqlRd.Close();

                    // SECTION 3. Populate the TreeView with the DOM nodes.
                    AddNodesFromSQL(rootNode);
                    //AddNodeFromXml(xDom.DocumentElement, Me._RootTreeNode)

                    rootNode.Expand();

                    //expand containers
                    foreach (Container.Info contI in this._ContainerList)
                    {
                        if (contI.IsExpanded == true)
                        {
                            contI.TreeNode.Expand();
                        }
                    }

                    //open connections from last mremote session
                    if (Settings.Default.OpenConsFromLastSession == true && Settings.Default.NoReconnect == false)
                    {
                        foreach (Connection.Info conI in this._ConnectionList)
                        {
                            if (conI.PleaseConnect == true)
                            {
                                Runtime.OpenConnection(conI);
                            }
                        }
                    }

                    //Tree.Node.TreeView.Nodes.Clear()
                    //Tree.Node.TreeView.Nodes.Add(rootNode)

                    AddNodeToTree(rootNode);
//.........这里部分代码省略.........
开发者ID:jpmarques,项目名称:mRemoteNC,代码行数:101,代码来源:Config.Connections.Load.cs


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