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


C# Connector.GetChild方法代码示例

本文整理汇总了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;
			}
		}
开发者ID:drzo,项目名称:opensim4opencog,代码行数:84,代码来源:ReferencedBehavior.cs

示例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);
            }
开发者ID:KeyleXiao,项目名称:behaviac,代码行数:24,代码来源:BaseNode.Connector.cs

示例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);
            }
开发者ID:675492062,项目名称:behaviac,代码行数:26,代码来源:BaseNode.Connector.cs


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