コード例 #1
0
ファイル: ITreeNode.cs プロジェクト: sjvannTMU/Sage
        /// <summary>
        /// Adds a child to this object. If the TreeNodeHelper is set to autoIndex, the new child
        /// must be an implementer of IHasIdentity, and will be indexed into the list of children.
        /// </summary>
        /// <param name="newChild">The child to be added to this parent.</param>
        /// <returns>The TreeNodeHelper that wraps the new child.</returns>
        public ITreeNode AddChild(object newChild)
        {
            ITreeNode node = CreateNodeWrapper(newChild);

            if (!IsReadOnly)
            {
                OnAboutToGainChild?.Invoke(this, node);
                if (m_children == null)
                {
                    m_children = new ArrayList();
                }
                m_children.Add(node);
                node.Parent = this;
                if (m_autoIndex)
                {
                    if (m_childFinder == null)
                    {
                        m_childFinder = new Hashtable();
                    }
                    ITreeNodeProxy       tnp = (ITreeNodeProxy)node;
                    SimCore.IHasIdentity ihi = (SimCore.IHasIdentity)tnp.Ward;

                    //if ( m_childFinder.Contains(ihi.Guid) ) Console.WriteLine();

                    m_childFinder.Add(ihi.Guid, tnp);
                }
                OnGainedChild?.Invoke(this, node);
            }
            else
            {
                ReadOnlyAccessViolation("AddChild");
            }
            return(node);
        }
コード例 #2
0
ファイル: ITreeNode.cs プロジェクト: sjvannTMU/Sage
 protected void _OnAboutToGainChild(TreeNodeHelper newChild)
 {
     OnAboutToGainChild?.Invoke(this, newChild);
 }