private void saveToolStripMenuItem_Click(object sender, EventArgs e) { using (FileStream input = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open, FileAccess.ReadWrite, FileShare.Read)) { m_vStorageObject.Save(input); } }
public MovieClip(MovieClip mv) { m_vStorageObject = mv.GetStorageObject(); m_vDataType = mv.GetMovieClipDataType(); m_vShapes = new List <ScObject>(); this.SetOffset(-Math.Abs(mv.GetOffset())); //Duplicate MovieClip using (FileStream input = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open)) { input.Seek(Math.Abs(mv.GetOffset()) + 5, SeekOrigin.Begin); using (var br = new BinaryReader(input)) { this.ParseData(br); } } //Set new clip id short maxMovieClipId = this.GetId(); foreach (MovieClip clip in m_vStorageObject.GetMovieClips()) { if (clip.GetId() > maxMovieClipId) { maxMovieClipId = clip.GetId(); } } maxMovieClipId++; this.SetId(maxMovieClipId); //Get max shape id short maxShapeId = 20000;//avoid collision with other objects in MovieClips foreach (Shape shape in m_vStorageObject.GetShapes()) { if (shape.GetId() > maxShapeId) { maxShapeId = shape.GetId(); } } maxShapeId++; //Duplicate shapes associated to clip List <ScObject> newShapes = new List <ScObject>(); foreach (Shape s in m_vShapes) { Shape newShape = new Shape(s); newShape.SetId(maxShapeId); maxShapeId++; newShapes.Add(newShape); m_vStorageObject.AddShape(newShape);//Add to global shapelist m_vStorageObject.AddChange(newShape); } this.m_vShapes = newShapes; }
public MovieClip(MovieClip mv) { m_vStorageObject = mv.GetStorageObject(); m_vDataType = mv.GetMovieClipDataType(); m_vShapes = new List<ScObject>(); this.SetOffset(-Math.Abs(mv.GetOffset())); //Duplicate MovieClip using (FileStream input = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open)) { input.Seek(Math.Abs(mv.GetOffset()) + 5, SeekOrigin.Begin); using (var br = new BinaryReader(input)) { this.ParseData(br); } } //Set new clip id short maxMovieClipId = this.GetId(); foreach(MovieClip clip in m_vStorageObject.GetMovieClips()) { if (clip.GetId() > maxMovieClipId) maxMovieClipId = clip.GetId(); } maxMovieClipId++; this.SetId(maxMovieClipId); //Get max shape id short maxShapeId = 20000;//avoid collision with other objects in MovieClips foreach(Shape shape in m_vStorageObject.GetShapes()) { if (shape.GetId() > maxShapeId) maxShapeId = shape.GetId(); } maxShapeId++; //Duplicate shapes associated to clip List<ScObject> newShapes = new List<ScObject>(); foreach(Shape s in m_vShapes) { Shape newShape = new Shape(s); newShape.SetId(maxShapeId); maxShapeId++; newShapes.Add(newShape); m_vStorageObject.AddShape(newShape);//Add to global shapelist m_vStorageObject.AddChange(newShape); } this.m_vShapes = newShapes; }
public Shape(Shape s) { m_vStorageObject = s.GetStorageObject(); m_vChunks = new List <ScObject>(); this.SetOffset(-Math.Abs(s.GetOffset())); //Duplicate Shape using (FileStream input = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open)) { input.Seek(Math.Abs(s.GetOffset()) + 5, SeekOrigin.Begin); using (var br = new BinaryReader(input)) { this.ParseData(br); } } foreach (ShapeChunk chunk in this.m_vChunks) { chunk.SetOffset(-Math.Abs(chunk.GetOffset())); } }
public Shape(Shape s) { m_vStorageObject = s.GetStorageObject(); m_vChunks = new List<ScObject>(); this.SetOffset(-Math.Abs(s.GetOffset())); //Duplicate Shape using (FileStream input = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open)) { input.Seek(Math.Abs(s.GetOffset()) + 5, SeekOrigin.Begin); using (var br = new BinaryReader(input)) { this.ParseData(br); } } foreach(ShapeChunk chunk in this.m_vChunks) { chunk.SetOffset(-Math.Abs(chunk.GetOffset())); } }
public override void Save(FileStream input) { if (m_vOffset < 0)//new { using (FileStream readInput = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { //Positionnement des curseurs readInput.Seek(Math.Abs(m_vOffset), SeekOrigin.Begin); input.Seek(m_vStorageObject.GetEofOffset(), SeekOrigin.Begin); //type and length byte[] dataType = new byte[1]; readInput.Read(dataType, 0, 1); byte[] dataLength = new byte[4]; readInput.Read(dataLength, 0, 4); input.Write(dataType, 0, 1); input.Write(dataLength, 0, 4); //movieclip readInput.Seek(2, SeekOrigin.Current); input.Write(BitConverter.GetBytes(m_vClipId), 0, 2); input.WriteByte((byte)readInput.ReadByte()); readInput.Seek(2, SeekOrigin.Current); input.Write(BitConverter.GetBytes(m_vFrameCount), 0, 2); if (m_vDataType == 14) { } else { //int cnt1 = br.ReadInt32(); byte[] cnt1 = new byte[4]; readInput.Read(cnt1, 0, 4); input.Write(cnt1, 0, 4); for (int i = 0; i < BitConverter.ToInt32(cnt1, 0); i++) { byte[] uk1 = new byte[2]; readInput.Read(uk1, 0, 2); input.Write(uk1, 0, 2); byte[] uk2 = new byte[2]; readInput.Read(uk2, 0, 2); input.Write(uk2, 0, 2); byte[] uk3 = new byte[2]; readInput.Read(uk3, 0, 2); input.Write(uk3, 0, 2); } } //int cnt2 = br.ReadInt16(); byte[] cnt2 = new byte[2]; readInput.Read(cnt2, 0, 2); input.Write(cnt2, 0, 2); int cptShape = 0; for (int i = 0; i < BitConverter.ToInt16(cnt2, 0); i++) { byte[] id = new byte[2]; readInput.Read(id, 0, 2); int index = m_vStorageObject.GetShapes().FindIndex(shape => shape.GetId() == BitConverter.ToInt16(id, 0)); if (index != -1) { input.Write(BitConverter.GetBytes(m_vShapes[cptShape].GetId()), 0, 2); cptShape++; } else { input.Write(id, 0, 2); } } if (m_vDataType == 12) { for (int i = 0; i < BitConverter.ToInt16(cnt2, 0); i++) { input.WriteByte((byte)readInput.ReadByte()); } } //read ascii for (int i = 0; i < BitConverter.ToInt16(cnt2, 0); i++) { byte stringLength = (byte)readInput.ReadByte(); input.WriteByte(stringLength); if (stringLength < 255) { for (int j = 0; j < stringLength; j++) { input.WriteByte((byte)readInput.ReadByte()); } } } byte v26; while (true) { while (true) { while (true) { v26 = (byte)readInput.ReadByte(); input.WriteByte(v26); //br.ReadInt32(); byte[] uk4 = new byte[4]; readInput.Read(uk4, 0, 4); input.Write(uk4, 0, 4); if (v26 != 5) { break; } } if (v26 == 11) { //short frameId = br.ReadInt16(); byte[] frameId = new byte[2]; readInput.Read(frameId, 0, 2); input.Write(frameId, 0, 2); byte frameNameLength = (byte)readInput.ReadByte(); input.WriteByte(frameNameLength); if (frameNameLength < 255) { for (int i = 0; i < frameNameLength; i++) { input.WriteByte((byte)readInput.ReadByte()); } } } else { break; } } if (v26 == 0) { break; } Debug.WriteLine("Unknown tag " + v26.ToString()); } } m_vOffset = m_vStorageObject.GetEofOffset(); m_vStorageObject.SetEofOffset(input.Position); input.Write(new byte[] { 0, 0, 0, 0, 0 }, 0, 5); } }
public override void Save(FileStream input) { if (m_vOffset < 0)//new { using (FileStream readInput = new FileStream(m_vStorageObject.GetFileName(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { //Positionnement des curseurs readInput.Seek(Math.Abs(m_vOffset), SeekOrigin.Begin); input.Seek(m_vStorageObject.GetEofOffset(), SeekOrigin.Begin); //type and length byte[] dataType = new byte[1]; readInput.Read(dataType, 0, 1); byte[] dataLength = new byte[4]; readInput.Read(dataLength, 0, 4); input.Write(dataType, 0, 1); input.Write(dataLength, 0, 4); //shape readInput.Seek(2, SeekOrigin.Current); input.Write(BitConverter.GetBytes(m_vShapeId), 0, 2); byte[] unknown1 = new byte[2]; readInput.Read(unknown1, 0, 2);//0100 input.Write(unknown1, 0, 2); byte[] unknown2 = new byte[2]; readInput.Read(unknown2, 0, 2);//0400 input.Write(unknown2, 0, 2); int chunkCounter = 0; while (true) { byte shapeType; byte[] length = new byte[4]; while (true) { shapeType = (byte)readInput.ReadByte();//11 input.WriteByte(shapeType); readInput.Read(length, 0, 4);//32000000 input.Write(length, 0, 4); if (shapeType == 17) { m_vChunks[chunkCounter].Save(input); chunkCounter++; readInput.Seek(BitConverter.ToInt32(length, 0), SeekOrigin.Current); } else { break; } } if (shapeType == 0) { break; } Log("Unmanaged shape type " + shapeType); for (int i = 0; i < BitConverter.ToInt32(length, 0); i++) { input.WriteByte((byte)readInput.ReadByte()); } } } m_vOffset = m_vStorageObject.GetEofOffset(); m_vStorageObject.SetEofOffset(input.Position); input.Write(new byte[] { 0, 0, 0, 0, 0 }, 0, 5); } }