internal static void WriteToStream(BinaryWriter output, Escher.DrawingGroupContainer dggContainer)
        {
            if (dggContainer == null)
            {
                return;
            }
            int  numberOfContinues = 0;
            uint num  = dggContainer.Length + 8;
            uint num2 = 0u;
            int  size;

            if (num > 8224)
            {
                size = 8224;
                numberOfContinues = (int)num / 8224;
                num2 = (uint)(num - numberOfContinues * 8224);
            }
            else
            {
                size = (ushort)num;
            }
            RecordFactory.WriteHeader(output, 235, size);
            byte[] drawingGroupContainerData = dggContainer.DrawingGroupContainerData;
            int    currentLength             = 0;

            WriteDGHeader(output, drawingGroupContainerData, ref currentLength, ref numberOfContinues, num2);
            drawingGroupContainerData = dggContainer.DrawingGroupData;
            WriteDGHeader(output, drawingGroupContainerData, ref currentLength, ref numberOfContinues, num2);
            drawingGroupContainerData = dggContainer.BStoreContainerData;
            WriteDGHeader(output, drawingGroupContainerData, ref currentLength, ref numberOfContinues, num2);
            Hashtable bSEList              = dggContainer.BSEList;
            ArrayList blipList             = dggContainer.BlipList;
            int       currentBlip          = 0;
            Stream    currentImageStream   = null;
            int       shapePropertiesIndex = 0;

            byte[] array = FillRecordWithBlips(dggContainer, blipList, bSEList, output.BaseStream, ref currentBlip, ref currentLength, ref currentImageStream);
            if (array == null && currentLength < 8224 && numberOfContinues == 1)
            {
                WriteShapeProperties(dggContainer, output.BaseStream, ref shapePropertiesIndex, currentLength);
            }
            for (int i = 0; i < numberOfContinues; i++)
            {
                int size2 = (i != numberOfContinues - 1) ? 8224 : ((ushort)num2);
                RecordFactory.WriteHeader(output, 60, size2);
                currentLength = 0;
                if (array != null)
                {
                    output.BaseStream.Write(array, 0, array.Length);
                    currentLength += array.Length;
                    array          = null;
                }
                if (currentImageStream == null)
                {
                    array = FillRecordWithBlips(dggContainer, blipList, bSEList, output.BaseStream, ref currentBlip, ref currentLength, ref currentImageStream);
                    if (currentLength < 8224)
                    {
                        WriteShapeProperties(dggContainer, output.BaseStream, ref shapePropertiesIndex, currentLength);
                    }
                    continue;
                }
                int num3 = 8224 - currentLength;
                int num4 = (int)(currentImageStream.Length - currentImageStream.Position);
                if (num4 <= num3)
                {
                    if (num4 > 0)
                    {
                        byte[] array2 = new byte[num4];
                        currentImageStream.Read(array2, 0, array2.Length);
                        output.BaseStream.Write(array2, 0, array2.Length);
                        currentLength += array2.Length;
                    }
                    dggContainer.StreamList[currentBlip].Offset = -1;
                    currentImageStream.Close();
                    currentImageStream = null;
                    currentBlip++;
                    array = FillRecordWithBlips(dggContainer, blipList, bSEList, output.BaseStream, ref currentBlip, ref currentLength, ref currentImageStream);
                    if (currentLength < 8224)
                    {
                        WriteShapeProperties(dggContainer, output.BaseStream, ref shapePropertiesIndex, currentLength);
                    }
                }
                else
                {
                    byte[] buffer = new byte[num3];
                    currentImageStream.Read(buffer, 0, num3);
                    output.BaseStream.Write(buffer, 0, num3);
                    dggContainer.StreamList[currentBlip].Offset = (int)currentImageStream.Position;
                }
            }
            output.BaseStream.Write(dggContainer.ShapePropertyData, shapePropertiesIndex, 50 - shapePropertiesIndex);
        }
Example #2
0
            internal void WriteToStream(BinaryWriter output)
            {
                if (m_shapeContainer == null)
                {
                    return;
                }
                long position = output.BaseStream.Position;

                RecordFactory.WriteHeader(output, 236, 0);
                int  num       = 0;
                long position2 = output.BaseStream.Position;

                byte[] data = base.GetData();
                output.BaseStream.Write(data, 0, data.Length);
                num += data.Length;
                data = m_drawing.GetData();
                output.BaseStream.Write(data, 0, data.Length);
                num += data.Length;
                long position3 = output.BaseStream.Position + 4;

                data = m_shapeGroupContainer.GetData();
                output.BaseStream.Write(data, 0, data.Length);
                num += data.Length;
                int    num2 = 0;
                int    num3 = num;
                ushort num4 = 1;

                for (int i = 0; i < m_shapeContainer.Count; i++)
                {
                    data = ((ShapeContainer)m_shapeContainer[i]).GetData();
                    if (i < 2)
                    {
                        num += data.Length;
                    }
                    else
                    {
                        num4 = (ushort)(num4 + 1);
                        RecordFactory.WriteHeader(output, 236, data.Length);
                    }
                    output.BaseStream.Write(data, 0, data.Length);
                    num2 += data.Length;
                    num3 += data.Length;
                    if (i > 0)
                    {
                        RecordFactory.OBJ(output, num4);
                    }
                }
                long position4 = output.BaseStream.Position;
                int  value     = num3 - 8;

                output.BaseStream.Position = position2 + 4;
                byte[] bytes = BitConverter.GetBytes((uint)value);
                output.BaseStream.Write(bytes, 0, bytes.Length);
                output.BaseStream.Position = position3;
                bytes = BitConverter.GetBytes((uint)num2);
                output.BaseStream.Write(bytes, 0, bytes.Length);
                bytes = BitConverter.GetBytes((ushort)num);
                output.BaseStream.Position = position + 2;
                output.BaseStream.Write(bytes, 0, bytes.Length);
                output.BaseStream.Position = position4;
            }