GetSizeOf() public method

Gets the size of.
public GetSizeOf ( ) : int
return int
Example #1
0
        /// <summary>
        /// Gets the size of.
        /// </summary>
        /// <returns>Size of this object.</returns>
        public int GetSizeOf()
        {
            int res = 0;

            if (fillStyleArray != null)
            {
                res += fillStyleArray.GetSizeOf();
            }
            if (lineStyleArray != null)
            {
                res += lineStyleArray.GetSizeOf();
            }
            if (shapes != null)
            {
                ShapeWithStyle.NumFillBits = 0;
                ShapeWithStyle.NumLineBits = 0;
                if (fillStyleArray != null && fillStyleArray.Count != 0)
                {
                    ShapeWithStyle.NumFillBits = BufferedBinaryWriter.GetNumBits((uint)fillStyleArray.Count);
                }
                if (lineStyleArray != null && lineStyleArray.Count != 0)
                {
                    ShapeWithStyle.NumLineBits = BufferedBinaryWriter.GetNumBits((uint)lineStyleArray.Count);
                }
                res += shapes.GetSizeOf();
                ShapeWithStyle.NumFillBits = 0;
                ShapeWithStyle.NumLineBits = 0;
            }
            return(res);
        }
Example #2
0
        /// <summary>
        /// see <see cref="ShapeRecord.GetBitSizeOf"/>
        /// </summary>
        public override int GetBitSizeOf(int currentLength)
        {
            int res = base.GetBitSizeOf(currentLength);

            res += 5;

            if (HasMoveTo())
            {
                uint moveBitsNum = GetMoveNumBits();
                res += Convert.ToInt32(5 + (2 * moveBitsNum));
            }
            if (HasFillStyle0())
            {
                res += (int)ShapeWithStyle.NumFillBits;
            }
            if (HasFillStyle1())
            {
                res += (int)ShapeWithStyle.NumFillBits;
            }
            if (HasLineStyle())
            {
                res += (int)ShapeWithStyle.NumLineBits;
            }
            if (HasNewStyle())
            {
                if ((res + currentLength) % 8 != 0)
                {
                    res += 8 - ((res + currentLength) % 8);
                }
                ShapeWithStyle.NumFillBits = BufferedBinaryWriter.GetNumBits((uint)fillStyles.Count);
                ShapeWithStyle.NumLineBits = BufferedBinaryWriter.GetNumBits((uint)lineStyles.Count);
                res += fillStyles.GetSizeOf() * 8;
                res += lineStyles.GetSizeOf() * 8;
                res += 8;
            }
            return(res);
        }