Base class for swf tag objects
Inheritance: IEnumerable, ISwfSerializer
Ejemplo n.º 1
0
 /// <summary>
 /// constructor. internal, since only used by BaseTag class
 /// </summary>
 /// <param name="tag">the BaseTag, who´s bytecode is being held</param>
 internal BytecodeEnumerator(BaseTag tag)
 {
     this.tag = tag;
     this.index = -1;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// constructor. internal, since only used by BaseTag class
 /// </summary>
 /// <param name="t">the BaseTag, who´s bytecode is being held</param>
 internal BytecodeHolder(BaseTag t)
 {
     tag = t;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the specified tag to the Swf tag collection.
 /// This methods is the same as swf.Tags.Add method, used
 /// only to simplify the writing process.
 /// </summary>
 /// <param name="tag">Tag.</param>
 public void Add(BaseTag tag)
 {
     this.Tags.Add(tag);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// A new tag was added to the tag collection
        /// </summary>
        /// <param name="tagAdded">Tag added.</param>
        private void tagList_TagAdded(BaseTag tagAdded)
        {
            if (tagAdded is DefineTag)
                dictionnary.Add((DefineTag)tagAdded);

            if (tagAdded is ShowFrameTag)
                this.header.Frames++;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Convert collection to array
        /// </summary>
        /// <returns>Base tags array</returns>
        public BaseTag[] ToArray()
        {
            BaseTag[] res = null;

            if (this.Count > 0)
            {
                res = new BaseTag[this.Count];
                for (int i = 0; i < this.Count; i++)
                    res[i] = this[i];
            }
            return res;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Add a base tag
        /// </summary>
        /// <param name="value">base tag to add</param>
        /// <returns>base tag added</returns>
        public BaseTag Add(BaseTag value)
        {
            List.Add(value as object);

            try
            {
                this.TagAdded(value);
            }
            catch (Exception) { }

            return value;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Insert a base tag at
        /// </summary>
        /// <param name="index">index</param>
        /// <param name="value">base tag</param>
        public void Insert(int index, BaseTag value)
        {
            List.Insert(index, value as object);

            try
            {
                this.TagAdded(value);
            }
            catch (Exception) { }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Remove a base tag
 /// </summary>
 /// <param name="value"></param>
 public void Remove(BaseTag value)
 {
     if (List.Contains(value))
         List.Remove(value as object);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Get index of a base tag
 /// </summary>
 /// <param name="value">base tag</param>
 /// <returns>base tag index if is contain, -1 else.</returns>
 public int IndexOf(BaseTag value)
 {
     return List.IndexOf(value);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Test if list contain a base tag
 /// </summary>
 /// <param name="value">base tag</param>
 /// <returns>contain result</returns>
 public bool Contains(BaseTag value)
 {
     return List.Contains(value as object);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Add an array of base tag
 /// </summary>
 /// <param name="values">base tag array</param>
 public void AddRange(BaseTag[] values)
 {
     IEnumerator enums = values.GetEnumerator();
     while (enums.MoveNext())
         Add((BaseTag)enums.Current);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Read next tag from swf input stream.
        /// </summary>
        /// <param name="version">Version.</param>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="tagList">Tag list.</param>
        /// <returns></returns>
        internal static BaseTag ReadTag(byte version, BufferedBinaryReader binaryReader, BaseTagCollection tagList)
        {
            long posBefore = binaryReader.BaseStream.Position;
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            int offset = (int)(binaryReader.BaseStream.Position - posBefore);
            binaryReader.BaseStream.Position = posBefore;

            BaseTag resTag = null;

            switch (rh.TagCode)
            {
                case (int)TagCodeEnum.DefineBits: resTag = new DefineBitsTag(); break;
                case (int)TagCodeEnum.DefineBitsJpeg2: resTag = new DefineBitsJpeg2Tag(); break;
                case (int)TagCodeEnum.DefineBitsJpeg3: resTag = new DefineBitsJpeg3Tag(); break;
                case (int)TagCodeEnum.DefineBitsLossLess: resTag = new DefineBitsLossLessTag(); break;
                case (int)TagCodeEnum.DefineBitsLossLess2: resTag = new DefineBitsLossLess2Tag(); break;
                case (int)TagCodeEnum.DefineButton: resTag = new DefineButtonTag(); break;
                case (int)TagCodeEnum.DefineButton2: resTag = new DefineButton2Tag(); break;
                case (int)TagCodeEnum.DefineButtonCxForm: resTag = new DefineButtonCxFormTag(); break;
                case (int)TagCodeEnum.DefineButtonSound: resTag = new DefineButtonSoundTag(); break;
                case (int)TagCodeEnum.DefineEditText: resTag = new DefineEditTextTag(); break;
                case (int)TagCodeEnum.DefineFont: resTag = new DefineFontTag(); break;
                case (int)TagCodeEnum.DefineFont2: resTag = new DefineFont2Tag(); break;
                case (int)TagCodeEnum.DefineFontInfo: resTag = new DefineFontInfoTag(); break;
                case (int)TagCodeEnum.DefineFontInfo2: resTag = new DefineFontInfo2Tag(); break;
                case (int)TagCodeEnum.DefineMorphShape: resTag = new DefineMorphShapeTag(); break;
                case (int)TagCodeEnum.DefineShape: resTag = new DefineShapeTag(); break;
                case (int)TagCodeEnum.DefineShape2: resTag = new DefineShape2Tag(); break;
                case (int)TagCodeEnum.DefineShape3: resTag = new DefineShape3Tag(); break;
                case (int)TagCodeEnum.DefineSound: resTag = new DefineSoundTag(); break;
                case (int)TagCodeEnum.DefineSprite: resTag = new DefineSpriteTag(); break;
                case (int)TagCodeEnum.DefineText: resTag = new DefineTextTag(); break;
                case (int)TagCodeEnum.DefineText2: resTag = new DefineText2Tag(); break;
                case (int)TagCodeEnum.DefineVideoStream: resTag = new DefineVideoStreamTag(); break;
                case (int)TagCodeEnum.DoAction: resTag = new DoActionTag(); break;
                case (int)TagCodeEnum.EnableDebugger: resTag = new EnableDebuggerTag(); break;
                case (int)TagCodeEnum.EnableDebugger2: resTag = new EnableDebugger2Tag(); break;
                case (int)TagCodeEnum.End: resTag = new EndTag(); break;
                case (int)TagCodeEnum.ExportAssets: resTag = new ExportAssetsTag(); break;
                case (int)TagCodeEnum.FrameLabel: resTag = new FrameLabelTag(); break;
                case (int)TagCodeEnum.ImportAssets: resTag = new ImportAssetsTag(); break;
                case (int)TagCodeEnum.InitAction: resTag = new InitActionTag(); break;
                case (int)TagCodeEnum.JpegTable: resTag = new JpegTableTag(); break;
                case (int)TagCodeEnum.PlaceObject: resTag = new PlaceObjectTag(); break;
                case (int)TagCodeEnum.PlaceObject2:	resTag = new PlaceObject2Tag(); break;
                case (int)TagCodeEnum.Protect: resTag = new ProtectTag(); break;
                case (int)TagCodeEnum.RemoveObject: resTag = new RemoveObjectTag(); break;
                case (int)TagCodeEnum.RemoveObject2: resTag = new RemoveObject2Tag(); break;
                case (int)TagCodeEnum.ScriptLimit: resTag = new ScriptLimitTag(); break;
                case (int)TagCodeEnum.SetBackgroundColor: resTag = new SetBackgroundColorTag(); break;
                case (int)TagCodeEnum.SetTabIndex: resTag = new SetTabIndexTag(); break;
                case (int)TagCodeEnum.ShowFrame: resTag = new ShowFrameTag(); break;
                case (int)TagCodeEnum.SoundStreamBlock: resTag = new SoundStreamBlockTag(); break;
                case (int)TagCodeEnum.SoundStreamHead: resTag = new SoundStreamHeadTag(); break;
                case (int)TagCodeEnum.SoundStreamHead2: resTag = new SoundStreamHead2Tag(); break;
                case (int)TagCodeEnum.StartSound: resTag = new StartSoundTag(); break;
                //TODO: Sorenson Codec
                case (int)TagCodeEnum.VideoFrame: resTag = ReadVideoFrameTag(binaryReader, tagList); break;
                default: resTag = new BaseTag(binaryReader.ReadBytes(System.Convert.ToInt32(rh.TagLength + offset))); break;
            }

            //Read the data of the current tag
            resTag.ReadData(version, binaryReader);

            //LOG
            long mustRead = rh.TagLength + offset;
            if (posBefore + mustRead != binaryReader.BaseStream.Position)
            {
                binaryReader.BaseStream.Position = posBefore + rh.TagLength + offset;
                if (log.IsErrorEnabled)
                    log.Error(Enum.GetName(TagCodeEnum.DefineBits.GetType(), rh.TagCode) + "....KO");
            }
            else if (log.IsInfoEnabled)
                log.Info(Enum.GetName(TagCodeEnum.DefineBits.GetType(), rh.TagCode) + "....OK (" + mustRead + ")");

            return resTag;
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Adds the specified child tag.
 /// </summary>
 /// <param name="childTag">Child tag.</param>
 public void Add(BaseTag childTag)
 {
     this.Tags.Add(childTag);
 }