示例#1
0
        public virtual void RemoveChild(Sprite a_sp)
        {
            if (m_bLooping)
            {
                m_aChildrenToRemove.Add(a_sp);
                return;
            }
            if (ChildListChangedBefore != null)
            {
                ChildListChangedBefore(this, a_sp, false);
            }

            //DataRow[] rows = m_dtChildren.Select("Name = '"+a_sp.Name+"'");
            DataRow[] rows = m_dtChildren.Select("Hash = '" + a_sp.GetHashCode() + "'");
            if (rows.GetLength(0) > 0)
            {
                m_dtChildren.Rows.Remove(rows[0]);
            }

            int index = this._slChildrenLocZSorted.IndexOfValue(a_sp);

            if (index >= 0)             //TODO: how can it not be..?
            {
                this._slChildrenLocZSorted.RemoveAt(index);
            }
            m_plChildrenByHash.Remove(a_sp.GetHashCode());

            if (ChildListChangedAfter != null)
            {
                ChildListChangedAfter(this, a_sp, false);
            }
        }
示例#2
0
        public bool AddChild(Sprite a_sp)
        {
            if (ChildListChangedBefore != null)
            {
                if (ChildListChangedBefore(this, a_sp, true) == false)
                {
                    return(false);
                }
            }

            //TODO: I need a sorted list class that allows duplicate keys! DataTables are slooow
            DataRow row = m_dtChildren.NewRow();

            row["Name"] = a_sp.Name;
            row["LocZ"] = a_sp.LocZ;
            row["Hash"] = a_sp.GetHashCode();
            m_dtChildren.Rows.Add(row);

            this._slChildrenLocZSorted.Add(a_sp.LocZ, a_sp);

            m_plChildrenByHash[a_sp.GetHashCode()] = a_sp;

            if (ChildListChangedAfter != null)
            {
                ChildListChangedAfter(this, a_sp, true);
            }

            return(true);
        }
示例#3
0
        protected void UpdateChildTableForChild(Sprite a_sp)
        {
            //Use when changing any one of the properties in the sprite that are used in m_dtChildren
            int index = this._slChildrenLocZSorted.IndexOfValue(a_sp);

            if (index >= 0)
            {
                this._slChildrenLocZSorted.RemoveAt(index);
                this._slChildrenLocZSorted.Add(a_sp.LocZ, a_sp);
            }
            DataRow[] rows = m_dtChildren.Select("Hash = '" + a_sp.GetHashCode() + "'");
            if (rows.GetLength(0) > 0)
            {
                rows[0]["Name"] = a_sp.Name;
                rows[0]["LocZ"] = a_sp.LocZ;
            }
        }
示例#4
0
        public bool AddChild(Sprite a_sp)
        {
            if (ChildListChangedBefore!=null)
            {
                if (ChildListChangedBefore(this, a_sp, true) == false)
                    return false;
            }

            //TODO: I need a sorted list class that allows duplicate keys! DataTables are slooow
            DataRow row = m_dtChildren.NewRow();
            row["Name"] = a_sp.Name;
            row["LocZ"] = a_sp.LocZ;
            row["Hash"] = a_sp.GetHashCode();
            m_dtChildren.Rows.Add(row);

            this._slChildrenLocZSorted.Add(a_sp.LocZ, a_sp);

            m_plChildrenByHash[a_sp.GetHashCode()] = a_sp;

            if (ChildListChangedAfter!=null)
                ChildListChangedAfter(this, a_sp, true);

            return true;
        }
示例#5
0
 protected void UpdateChildTableForChild(Sprite a_sp)
 {
     //Use when changing any one of the properties in the sprite that are used in m_dtChildren
     int index = this._slChildrenLocZSorted.IndexOfValue(a_sp);
     if (index >= 0)
     {
         this._slChildrenLocZSorted.RemoveAt(index);
         this._slChildrenLocZSorted.Add(a_sp.LocZ, a_sp);
     }
     DataRow[] rows = m_dtChildren.Select("Hash = '"+a_sp.GetHashCode()+"'");
     if (rows.GetLength(0) > 0)
     {
         rows[0]["Name"] = a_sp.Name;
         rows[0]["LocZ"] = a_sp.LocZ;
     }
 }
示例#6
0
        public virtual void RemoveChild(Sprite a_sp)
        {
            if (m_bLooping)
            {
                m_aChildrenToRemove.Add(a_sp);
                return;
            }
            if (ChildListChangedBefore!=null)
                ChildListChangedBefore(this, a_sp, false);

            //DataRow[] rows = m_dtChildren.Select("Name = '"+a_sp.Name+"'");
            DataRow[] rows = m_dtChildren.Select("Hash = '"+a_sp.GetHashCode()+"'");
            if (rows.GetLength(0) > 0)
                m_dtChildren.Rows.Remove(rows[0]);

            int index = this._slChildrenLocZSorted.IndexOfValue(a_sp);
            if (index >= 0) //TODO: how can it not be..?
                this._slChildrenLocZSorted.RemoveAt(index);
            m_plChildrenByHash.Remove(a_sp.GetHashCode());

            if (ChildListChangedAfter!=null)
                ChildListChangedAfter(this, a_sp, false);
        }