本文整理汇总了C#中TreeNode.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.AddChild方法的具体用法?C# TreeNode.AddChild怎么用?C# TreeNode.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode.AddChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SplitTree
//===================================================================//
// Constructors //
//===================================================================//
/// <summary>
/// Create a new SplitTree.
/// </summary>
/// <param name="maxValue">the maximum value of a node in the tree</param>
/// <param name="minValue">the minimum value of a node in the tree</param>
/// <param name="points">the grid points from which to construct the tree</param>
public SplitTree(float maxValue, float minValue, List<GridPoint> points)
: base(maxValue, minValue)
{
// reverse th points list
points.Reverse();
// create a list to store all the blobs in
List<BlobOfNodes> blobList = new List<BlobOfNodes>();
// Turn each point into a tree node.
foreach (GridPoint point in points)
{
// Turn the next point into a node.
TreeNode newNode = new TreeNode(point);
// Make a list of all the blobs to which the node is adjacent.
List<BlobOfNodes> adjacentBlobs = new List<BlobOfNodes>();
// Check each blob in the list.
foreach (BlobOfNodes blob in blobList) {
// If it is adjacent...
if (blob.IsAdjacentTo(newNode)) {
// ...add it to the list of adjacent blobs.
adjacentBlobs.Add(blob); } }
// If the node is not adjacent to any blobs,
// create a new blob for it.
if (adjacentBlobs.Count == 0) {
BlobOfNodes newBlob = new BlobOfNodes(newNode);
blobList.Add(newBlob);
this.childless.Add(newNode); }
// If the node is adjacent to exactly one blob,
// add it to that blob.
else if (adjacentBlobs.Count == 1) {
adjacentBlobs[0].GetMostRecentlyAddedNode().AddParent(newNode);
newNode.AddChild(adjacentBlobs[0].GetMostRecentlyAddedNode());
adjacentBlobs[0].Add(newNode); }
// If the node is adjacent to more than one blob,
// merge the blobs.
else {
foreach (BlobOfNodes blob in adjacentBlobs) {
blob.GetMostRecentlyAddedNode().AddParent(newNode);
newNode.AddChild(blob.GetMostRecentlyAddedNode());
blobList.Remove(blob); }
this.merging.Add(newNode);
blobList.Add(new BlobOfNodes(newNode, adjacentBlobs)); }
} // end of adding all the gridpoints
// At this point, there will be exactly one blob. Its most recently
// added node is the bottom of the split tree.
this.parentless.Add(blobList[0].GetMostRecentlyAddedNode());
}
示例2: Main
public static void Main()
{
TreeNode<int> node = new TreeNode<int>(2);
TreeNode<int> node1 = new TreeNode<int>(4);
node1.HasParent = true;
node.AddChild(node1);
Tree<int> tr = new Tree<int>(2);
}
示例3: Start
void Start()
{
_mainView = this.GetComponent<UIPanel>().ui;
_folderURL1 = UIPackage.GetItemURL("TreeView", "folder_closed");
_folderURL2 = UIPackage.GetItemURL("TreeView", "folder_opened");
_fileURL = UIPackage.GetItemURL("TreeView", "file");
_treeView = new TreeView(_mainView.GetChild("tree").asList);
_treeView.onClickNode.Add(__clickNode);
_treeView.treeNodeRender = RenderTreeNode;
TreeNode topNode = new TreeNode(true);
topNode.data = "I'm a top node";
_treeView.root.AddChild(topNode);
for (int i = 0; i < 5; i++)
{
TreeNode node = new TreeNode(false);
node.data = "Hello " + i;
topNode.AddChild(node);
}
TreeNode aFolderNode = new TreeNode(true);
aFolderNode.data = "A folder node";
topNode.AddChild(aFolderNode);
for (int i = 0; i < 5; i++)
{
TreeNode node = new TreeNode(false);
node.data = "Good " + i;
aFolderNode.AddChild(node);
}
for (int i = 0; i < 3; i++)
{
TreeNode node = new TreeNode(false);
node.data = "World " + i;
topNode.AddChild(node);
}
TreeNode anotherTopNode = new TreeNode(false);
anotherTopNode.data = new string[] { "I'm a top node too", UIPackage.GetItemURL("TreeView", "heart") };
_treeView.root.AddChild(anotherTopNode);
}
示例4: Create
/// <summary>
/// Creates <see cref="Common.UI.MenuItems.MenuSeparatorItem"/> instance that representing separator and adds it to
/// <see cref="Common.TreeNode`1"/> instance.
/// </summary>
/// <param name="owner"><see cref="Common.TreeNode`1"/> instance.</param>
public static TreeNode<CustomMenuItem> Create(TreeNode<CustomMenuItem> owner)
{
DebugEx.VerboseFormat("MenuSeparatorItem.Create(owner = {0})", owner);
MenuSeparatorItem item = new MenuSeparatorItem();
TreeNode<CustomMenuItem> node = owner.AddChild(item);
item.mNode = node;
return node;
}
示例5: BuildTree
public static void BuildTree(TreeNode<Device> dev, IEnumerable<Device> list)
{
var devices = list as IList<Device> ?? list.ToList();
var childrens =
devices.Where(
d => d.Name.Level == dev.Value.Name.Level + 1
&& d.Name.Path.Contains(dev.Value.Name.Path));
foreach (var child in childrens)
{
BuildTree(dev.AddChild(child), devices);
}
}
示例6: GetSet1
public static TreeNode<string> GetSet1()
{
TreeNode<string> root = new TreeNode<string>("root");
{
TreeNode<string> node0 = root.AddChild("node0");
TreeNode<string> node1 = root.AddChild("node1");
TreeNode<string> node2 = root.AddChild("node2");
{
TreeNode<string> node20 = node2.AddChild(null);
TreeNode<string> node21 = node2.AddChild("node21");
{
TreeNode<string> node210 = node21.AddChild("node210");
TreeNode<string> node211 = node21.AddChild("node211");
}
}
TreeNode<string> node3 = root.AddChild("node3");
{
TreeNode<string> node30 = node3.AddChild("node30");
}
}
return root;
}
示例7: MakeTree
public void MakeTree(string namafile, TreeNode<string> T)
{
//membentuk pohon status dari file dan direktori dari direktori tertentu
if (Directory.Exists(namafile))
{
string[] listdirektori = {};
try{
listdirektori = Directory.GetDirectories(namafile);
} catch (Exception e){
}
if (listdirektori.Length > 0)
{
foreach (var directori in listdirektori)
{
string dirr = directori;
TreeNode<string> nodee = T.AddChild(dirr,"folder");
countTotal++;
MakeTree(dirr, nodee);
}
}
string[] listfile={};
try
{
listfile = Directory.GetFiles(namafile);
}
catch (Exception e)
{
}
if (listfile.Length > 0)
{
foreach (var directori in listfile)
{
countTotal++;
string filee = directori;
TreeNode<string> nodef = T.AddChild(filee,"file");
}
}
}
}
示例8: FillTree
} //Main()
public static void FillTree(TreeNode InputNode)
{
//Fill the tree with all the types in the BCL assembly in inheritence hierarchy.
Type [] types = typeof(object).Module.Assembly.GetExportedTypes();
InputNode.AddChild(new TreeNode(typeof(object).FullName));
//Go through the types and for each base type add any new derived types.
//Since Find returns a reference to a node within InputNode, the original
//node is modified when n is modified.
//AddChild checks for existence and only adds if new.
foreach (Type t in types)
{
if (t.BaseType != null && t.BaseType.FullName != null)
{
TreeNode n = InputNode.Find(t.BaseType.FullName);
if (n != null)
{
n.AddChild(new TreeNode(t));
} //if
} //if
} //foreach
} //FillTree()
示例9: loadChildren
private void loadChildren(TreeNode<SitemapItem> root)
{
List<SitemapItem> items =
_articleDbContext.SitemapItems.Where(i => i.ParentCode == root.Data.Code)
.OrderBy(i => i.SortOrder)
.ThenBy(i => i.Code).ToList();
foreach (SitemapItem sitemapItem in items)
{
var child = new SitemapItem(sitemapItem);
loadChildren(root.AddChild(child));
}
}
示例10: AddChildren
private void AddChildren(TreeNode<Comment> parentNode)
{
foreach(Comment child in parentNode.Data.Replies.Comments)
{
TreeNode<Comment> childNode = parentNode.AddChild(child);
AddChildren(childNode);
}
}
示例11: GetHAminSkeleton
/// <summary>
/// Constructur returns a skeleton in standrad ISO/IEC FCD 19774 specification
/// http://h-anim.org/Specifications/H-Anim200x/ISO_IEC_FCD_19774/
/// </summary>
/// <returns></returns>
public static TreeNode<Bone> GetHAminSkeleton()
{
TreeNode<Bone> root = new TreeNode<Bone>(new Bone(Joint.PELVIS,
HAminStandard.pelvisPos, Quaternion.Identity));
#region bone structure
{
#region upper body
#region spine and head
TreeNode<Bone> spine0 = root.AddChild(new Bone(Joint.SPINE0,
HAminStandard.spine0Pos,
HAminStandard.spine0Rot));
{
TreeNode<Bone> spine1 = spine0.AddChild(new Bone(Joint.SPINE1,
HAminStandard.spine1Pos,
HAminStandard.spine1Rot));
{
TreeNode<Bone> spine3 = spine1.AddChild(new Bone(Joint.SPINE3,
HAminStandard.spine3Pos,
HAminStandard.spine3Rot));
{
TreeNode<Bone> neck = spine3.AddChild(new Bone(Joint.NECK,
HAminStandard.neckPos,
HAminStandard.neckRot));
{
TreeNode<Bone> head = neck.AddChild(new Bone(Joint.HEAD,
HAminStandard.headPos,
HAminStandard.headRot));
{
head.AddChild(new Bone(Joint.HEADTOP, HAminStandard.headTopPos, QuaternionHelper2.Zero));
}
}
#endregion
#region arm left
TreeNode<Bone> clavicleLeft = spine3.AddChild(new Bone(Joint.CLAVICLE_L,
HAminStandard.spine3Pos,
HAminStandard.clavicleLeftRot));
{
TreeNode<Bone> shoulderLeft = clavicleLeft.AddChild(new Bone(Joint.SHOULDER_L,
HAminStandard.shoulderLeftPos,
HAminStandard.shoulderLeftRot));
{
TreeNode<Bone> elbowLeft = shoulderLeft.AddChild(new Bone(Joint.ELBOW_L,
HAminStandard.elbowLeftPos,
HAminStandard.elbowLeftRot));
{
TreeNode<Bone> wristLeft = elbowLeft.AddChild(new Bone(Joint.WRIST_L,
HAminStandard.wristLeftPos,
HAminStandard.wristLeftRot));
{
TreeNode<Bone> handLeft = wristLeft.AddChild(new Bone(Joint.HAND_L,
HAminStandard.handLeftPos,
HAminStandard.handLeftRot));
{
handLeft.AddChild(new Bone(Joint.INDEX_L,
HAminStandard.indexLeftPos,
QuaternionHelper2.Zero));
}
TreeNode<Bone> trapezoidLeft = wristLeft.AddChild(new Bone(Joint.TRAP_L,
HAminStandard.wristLeftPos,
HAminStandard.trapezoidLeftRot));
{
trapezoidLeft.AddChild(new Bone(Joint.THUMB_L,
HAminStandard.thumbLeftPos,
QuaternionHelper2.Zero));
}
}
}
}
}
#endregion
#region arm right
TreeNode<Bone> clavicleRight =
spine3.AddChild(new Bone(Joint.CLAVICLE_R,
HAminStandard.spine3Pos,
HAminStandard.clavicleRightRot));
{
TreeNode<Bone> shoulderRight =
clavicleRight.AddChild(new Bone(Joint.SHOULDER_R,
HAminStandard.shoulderRightPos,
HAminStandard.shoulderRightRot));
{
TreeNode<Bone> elbowRight =
shoulderRight.AddChild(new Bone(Joint.ELBOW_R,
HAminStandard.elbowRightPos,
HAminStandard.elbowRightRot));
{
TreeNode<Bone> wristRight =
elbowRight.AddChild(new Bone(Joint.WRIST_R,
HAminStandard.wristRightPos,
HAminStandard.wristRightRot));
{
TreeNode<Bone> handRight =
wristRight.AddChild(new Bone(Joint.HAND_R,
HAminStandard.handRightPos,
HAminStandard.handRightRot));
//.........这里部分代码省略.........
示例12: BuildTree
#pragma warning restore 1998
private TreeNode<NavigationNode> BuildTree()
{
NavigationNode home = new NavigationNode();
home.Key = "Home";
home.ParentKey = "RootNode";
home.Controller = "Home";
home.Action = "Index";
home.Text = "Home";
home.Url = home.ResolveUrl();
home.IsRootNode = true;
TreeNode<NavigationNode> treeRoot = new TreeNode<NavigationNode>(home);
NavigationNode about = new NavigationNode();
about.Key = "About";
about.ParentKey = "RootNode";
about.Controller = "Home";
about.Action = "About";
about.Text = "About";
about.Url = about.ResolveUrl();
treeRoot.AddChild(about);
NavigationNode contact = new NavigationNode();
contact.Key = "Contact";
contact.ParentKey = "RootNode";
contact.Controller = "Home";
contact.Action = "Contact";
contact.Text = "Contact";
contact.Url = contact.ResolveUrl();
treeRoot.AddChild(contact);
NavigationNode siteAdmin = new NavigationNode();
siteAdmin.Key = "SiteAdmin";
siteAdmin.ParentKey = "RootNode";
siteAdmin.Controller = "SiteAdmin";
siteAdmin.Action = "Index";
siteAdmin.Text = "Administration";
siteAdmin.ViewRoles = "Admins,Content Administrators";
siteAdmin.Url = siteAdmin.ResolveUrl();
TreeNode<NavigationNode> adminRoot = treeRoot.AddChild(siteAdmin);
NavigationNode siteSettings = new NavigationNode();
siteSettings.Key = "BasicSettings";
siteSettings.ParentKey = "SiteAdmin";
siteSettings.Controller = "SiteAdmin";
siteSettings.Action = "SiteInfo";
siteSettings.Text = "Site Settings";
siteSettings.ViewRoles = "Admins,Content Administrators";
siteSettings.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree;
siteSettings.PreservedRouteParameters = "siteGuid";
siteSettings.Url = siteSettings.ResolveUrl();
TreeNode<NavigationNode> siteT = adminRoot.AddChild(siteSettings);
NavigationNode hosts = new NavigationNode();
hosts.Key = "SiteHostMappings";
hosts.ParentKey = "BasicSettings";
hosts.Controller = "SiteAdmin";
hosts.Action = "SiteHostMappings";
hosts.Text = "Domain Mappings";
hosts.ViewRoles = "Admins,Content Administrators";
hosts.ComponentVisibility = NamedNavigationFilters.Breadcrumbs;
hosts.PreservedRouteParameters = "siteGuid";
hosts.Url = hosts.ResolveUrl();
TreeNode<NavigationNode> hostsT = siteT.AddChild(hosts);
NavigationNode siteList = new NavigationNode();
siteList.Key = "SiteList";
siteList.ParentKey = "SiteAdmin";
siteList.Controller = "SiteAdmin";
siteList.Action = "SiteList";
siteList.Text = "SiteList";
siteList.ViewRoles = "ServerAdmins";
siteList.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree;
siteList.Url = siteList.ResolveUrl();
TreeNode<NavigationNode> siteListT = adminRoot.AddChild(siteList);
NavigationNode newSite = new NavigationNode();
newSite.Key = "NewSite";
newSite.ParentKey = "SiteList";
newSite.Controller = "SiteAdmin";
newSite.Action = "NewSite";
newSite.Text = "NewSite";
newSite.ViewRoles = "ServerAdmins";
newSite.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree;
newSite.Url = newSite.ResolveUrl();
TreeNode<NavigationNode> newSiteT = siteListT.AddChild(newSite);
NavigationNode userAdmin = new NavigationNode();
userAdmin.Key = "UserAdmin";
userAdmin.ParentKey = "SiteAdmin";
userAdmin.Controller = "UserAdmin";
userAdmin.Action = "Index";
userAdmin.Text = "UserManagement";
userAdmin.ViewRoles = "ServerAdmins";
userAdmin.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree;
userAdmin.Url = userAdmin.ResolveUrl();
//.........这里部分代码省略.........
示例13: IterateProjectTree
void IterateProjectTree(PBXGroupBase parentGroup, TreeNode<Tuple<string, IPBXElement>> parentNode)
{
if (parentGroup.Children.Count == 0)
return;
foreach (var childElementId in parentGroup.Children) {
var childElement = GetElementById (childElementId);
var childNode = parentNode.AddChild (new Tuple<string, IPBXElement> (childElementId, childElement));
if (childElement.GetType ().BaseType == typeof(PBXGroupBase))
IterateProjectTree ((PBXGroupBase)childElement, childNode);
}
}
示例14: Create
/// <summary>
/// Initializes a new instance of the <see cref="Common.UI.MenuItems.MenuItem"/> class with given text and with
/// assigning to specified <see cref="Common.TreeNode`1"/> instance.
/// </summary>
/// <param name="owner"><see cref="Common.TreeNode`1"/> instance.</param>
/// <param name="text">Menu item text.</param>
/// <param name="onClick">Click event handler.</param>
/// <param name="enabled">Is this menu item enabled or not.</param>
/// <param name="shortcutHandler">Shortcut handler.</param>
/// <param name="shortcut">Shortcut.</param>
/// <param name="radioGroup">Menu radio group.</param>
public static TreeNode<CustomMenuItem> Create(
TreeNode<CustomMenuItem> owner
, string text
, UnityAction onClick = null
, bool enabled = true
, IShortcutHandler shortcutHandler = null
, string shortcut = null
, MenuRadioGroup radioGroup = null
)
{
DebugEx.VerboseFormat("MenuItem.Create(owner = {0}, text = {1}, onClick = {2}, enabled = {3}, shortcutHandler = {4}, shortcut = {5}, radioGroup = {6})"
, owner
, text
, onClick
, enabled
, shortcutHandler
, shortcut
, radioGroup);
MenuItem item = new MenuItem(
R.sections.MenuItems.strings.Count // Token ID
, null // Token arguments
, text // Text
, enabled // Enabled
, onClick // Click event handler
, shortcutHandler // Shortcut handler
, KeyboardInput.FromString(shortcut) // Shortcut
, radioGroup // Menu radio group
);
TreeNode<CustomMenuItem> node = owner.AddChild(item);
item.mNode = node;
return node;
}
示例15: Clone
//===================================================================//
// Actions //
//===================================================================//
/// <summary>
/// Clones all of the nodes in the tree and duplicates their connections.
/// </summary>
/// <param name="parentlessParam">the list in which to store the parentless nodes of the new tree</param>
/// <param name="mergingParam">the list in which to store the merging nodes of the new tree</param>
/// <param name="childlessParam">the list in which to store the childless nodes of the new tree</param>
private void Clone(List<TreeNode> parentlessParam, List<TreeNode> mergingParam, List<TreeNode> childlessParam)
{
// Copy the tree root and place it in the new tree's list.
TreeNode newTreeRoot = new TreeNode(this.GetChildless()[0]);
childlessParam.Add(newTreeRoot);
// Create the current "level" of nodes in the original tree.
List<TreeNode> currentLevel = new List<TreeNode>();
currentLevel.Add(this.GetChildless()[0]);
// Create the current "level" of nodes in the clone tree.
List<TreeNode> currentCloneLevel = new List<TreeNode>();
currentCloneLevel.Add(newTreeRoot);
// Loop through the levels of the original tree.
while (currentLevel.Count > 0) {
// Construct the next level of the original and clone trees.
List<TreeNode> nextLevel = new List<TreeNode>();
List<TreeNode> nextCloneLevel = new List<TreeNode>();
// Put all of the children of the nodes in the current level of
// the original tree into the next level.
for (int id = 0; id < currentLevel.Count; id++) {
foreach (TreeNode parent in currentLevel[id].GetParents()) {
// Copy each parent and set its relations.
TreeNode newNode = new TreeNode(parent);
newNode.AddChild(currentCloneLevel[id]);
currentCloneLevel[id].AddParent(newNode);
nextLevel.Add(parent);
nextCloneLevel.Add(newNode);
if (this.merging.Contains(parent)) {
mergingParam.Add(newNode); }
if (this.parentless.Contains(parent)) {
parentlessParam.Add(newNode); }
}
}
currentLevel = nextLevel;
currentCloneLevel = nextCloneLevel;
}
}