Create() public method

public Create ( QbItemType type ) : void
type QbItemType
return void
Beispiel #1
0
        /// <summary>
        /// Deep clones this item and all children.  Positions and lengths are not cloned.  When inserted in to another item they should be calculated.
        /// </summary>
        /// <returns></returns>
        public override QbItemBase Clone()
        {
            QbItemArray a = new QbItemArray(this.Root);
            a.Create(this.QbItemType);

            if (this.ItemQbKey != null)
                a.ItemQbKey = this.ItemQbKey.Clone();

            foreach (QbItemBase qib in this.Items)
                a.Items.Add(qib.Clone());

            a.ItemCount = this.ItemCount;

            return a;
        }
Beispiel #2
0
        /// <summary>
        /// Deep clones this item and all children.  Positions and lengths are not cloned.  When inserted in to another item they should be calculated.
        /// </summary>
        /// <returns></returns>
        public override QbItemBase Clone()
        {
            QbItemArray a = new QbItemArray(this.Root);

            a.Create(this.QbItemType);

            if (this.ItemQbKey != null)
            {
                a.ItemQbKey = this.ItemQbKey.Clone();
            }

            foreach (QbItemBase qib in this.Items)
            {
                a.Items.Add(qib.Clone());
            }

            a.ItemCount = this.ItemCount;

            return(a);
        }
Beispiel #3
0
        private void replaceQbItems(QbItemArray a, int[] items, bool split, int splitBy)
        {
            a.Items.Clear();

            //no items to add
            if (items.Length == 0)
            {
                QbItemFloats f = new QbItemFloats(a.Root);
                f.Create(QbItemType.Floats);
                a.AddItem(f);
                a.Root.AlignPointers();
            }
            else
            {
                if (!split)
                {
                    //add array to parent as one large array
                    QbItemInteger qi = new QbItemInteger(a.Root);
                    qi.Create(QbItemType.ArrayInteger);
                    qi.Values = convertIntArrayToUIntArray(items);
                    a.AddItem(qi);
                    a.Root.AlignPointers();
                }
                else
                {
                    //split array down in to blocks of <splitBy>
                    QbItemInteger qi;
                    QbItemArray aa = new QbItemArray(a.Root);
                    aa.Create(QbItemType.ArrayArray);
                    uint[] uints;
                    a.AddItem(aa);
                    a.Root.AlignPointers();

                    for (int i = 0; i < items.Length; i += splitBy)
                    {
                        qi = new QbItemInteger(a.Root);
                        qi.Create(QbItemType.ArrayInteger);
                        uints = new uint[splitBy];
                        for (int j = 0; j < splitBy; j++)
                            uints[j] = (uint)items[i + j];
                        qi.Values = uints;
                        aa.AddItem(qi);
                        a.Root.AlignPointers();
                    }

                }
            }
        }