本文整理汇总了C#中Connector.GetChild方法的典型用法代码示例。如果您正苦于以下问题:C# Connector.GetChild方法的具体用法?C# Connector.GetChild怎么用?C# Connector.GetChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connector
的用法示例。
在下文中一共展示了Connector.GetChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandNode
/// <summary>
/// Exapnds and collapses the referenced node.
/// </summary>
/// <param name="nvdrb">The view data for this node.</param>
public void ExpandNode(NodeViewDataReferencedBehavior nvdrb)
{
// if the referenced behaviours was not yet loaded, try so
if(_referencedBehavior ==null)
{
LoadReferencedBehavior();
// if we could not load it, skip
if(_referencedBehavior ==null)
return;
}
// this code can be called without a change of IsExpanded so you cannot assume that the current children were from the other state
if(nvdrb.IsExpanded)
{
// clear the generated sub-reference graph
_genericChildrenLocal.ClearChildren();
// remove any remaining subitems because of minimum count
for(int i= 0; i <_subItems.Count; ++i)
{
SubItemConnector subconn= _subItems[i] as SubItemConnector;
if(subconn !=null && subconn.Connector ==_genericChildren)
{
RemoveSubItem(subconn);
--i;
}
}
// assign the connector of the behaviour
_genericChildren= _referencedBehavior.GenericChildren;
_children.SetConnector(_genericChildren);
// add all the subitems needed
int count= Math.Max(_genericChildren.ChildCount, _genericChildren.MinCount);
for(int i= 0; i <count; ++i)
{
Node child= i <_genericChildren.ChildCount ? _genericChildren.GetChild(i) : null;
AddSubItem(new SubItemConnector(_genericChildren, child, i));
}
}
else
{
// remove all subitems of the behaviour
for(int i= 0; i <_subItems.Count; ++i)
{
SubItemConnector subconn= _subItems[i] as SubItemConnector;
if(subconn !=null && subconn.Connector ==_genericChildren)
{
RemoveSubItem(subconn);
--i;
}
}
// assign the connector for the sub-reference graph
_genericChildren= _genericChildrenLocal;
_children.SetConnector(_genericChildren);
// make the connector writable to edit it
_genericChildren.IsReadOnly= false;
// add all the subitems needed
int count= Math.Max(_genericChildren.ChildCount, _genericChildren.MinCount);
for(int i= 0; i <count; ++i)
{
Node child= i <_genericChildren.ChildCount ? _genericChildren.GetChild(i) : null;
AddSubItem(new SubItemConnector(_genericChildren, child, i));
}
// clear the generated sub-reference graph
_genericChildren.ClearChildren();
// generate the dummy nodes for the sub-referenced behaviours
foreach(Node child in ((Node)_referencedBehavior).Children)
GenerateReferencedBehaviorsTree(nvdrb.RootBehavior, this, child);
// make the connector read-only so the user cannot modify it
_genericChildren.IsReadOnly= true;
}
}
示例2: AcceptsChildren
/// <summary>
/// Convenience method to check if all connected children are accepted.
/// </summary>
/// <param name="children">The children we want to adopt.</param>
/// <returns>Returns if the connector will accept the children.</returns>
public bool AcceptsChildren(Connector conn)
{
List<Type> children = new List<Type>(conn.ChildCount);
for (int i = 0; i < conn.ChildCount; ++i)
{
BaseNode node = conn.GetChild(i);
// if the owner itself is part of the list we ignore him
if (node == Owner)
{
continue;
}
children.Add(node.GetType());
}
return AcceptsChildren(children);
}
示例3: AcceptsChildren
/// <summary>
/// Convenience method to check if all connected children are accepted.
/// </summary>
/// <param name="children">The children we want to adopt.</param>
/// <returns>Returns if the connector will accept the children.</returns>
public bool AcceptsChildren(Connector conn) {
List<BaseNode> children = new List<BaseNode>(conn.ChildCount);
for (int i = 0; i < conn.ChildCount; ++i) {
BaseNode node = conn.GetChild(i);
// if the owner itself is part of the list we ignore him
if (node == Owner) {
continue;
}
//one child can't be as child of Owner
if (!node.CanBeAdoptedBy(Owner)) {
return false;
}
children.Add(node);
}
return AcceptsChildren(children);
}