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


C# Connector.ClearChildren方法代码示例

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


在下文中一共展示了Connector.ClearChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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