예제 #1
0
        public static ClipActionRecord ReadClipActionRecord(this ISwfStreamReader reader, byte swfVersion)
        {
            var record = new ClipActionRecord();

            record.Flags = reader.ReadClipEventFlags(swfVersion);
            if (record.Flags.IsEmpty)
            {
                return(record);
            }

            var offset = reader.ReadUInt32();

            if (record.Flags.ClipEventKeyPress)
            {
                record.KeyCode = reader.ReadByte();
            }

            ActionBase action;
            var        ar = new ActionReader(reader);

            do
            {
                action = ar.ReadAction();
                record.Actions.Add(action);
            } while (!(action is ActionEnd));

            return(record);
        }
예제 #2
0
        public static ClipActionRecord FromXml(XElement xClipAction)
        {
            var res = new ClipActionRecord();
            var xActions = xClipAction.Element("actions");
            if (xActions != null) {
                foreach (var xAction in xActions.Elements()) {
                    res.Actions.Add(XAction.FromXml(xAction));
                }
            }
            XClipEventFlags.SetFlags1(ref res.Flags, int.Parse(xClipAction.Attribute("flags1").Value));
            XClipEventFlags.SetFlags2(ref res.Flags, int.Parse(xClipAction.Attribute("flags2").Value));

            res.KeyCode = byte.Parse(xClipAction.Attribute("keyCode").Value);
            return res;
        }
예제 #3
0
        public static XElement ToXml(ClipActionRecord clipAction)
        {
            var res = new XElement("Event");

            if (clipAction.Actions.Count > 0) {
                var xActions = new XElement("actions");
                foreach (var action in clipAction.Actions) {
                    xActions.Add(XAction.ToXml(action));
                }
                res.Add(xActions);
            }

            res.Add(new XAttribute("flags1", XClipEventFlags.GetFlags1(clipAction.Flags)));
            res.Add(new XAttribute("flags2", XClipEventFlags.GetFlags2(clipAction.Flags)));

            res.Add(new XAttribute("keyCode", clipAction.KeyCode));
            return res;
        }
예제 #4
0
        public static void WriteClipActionRecord(this ISwfStreamWriter writer, byte swfVersion, ClipActionRecord record)
        {
            writer.WriteClipEventFlags(swfVersion, record.Flags);
            if (record.Flags.IsEmpty) return;

            var awmem = new MemoryStream();
            var aw = new ActionWriter(new SwfStreamWriter(awmem));
            foreach (var action in record.Actions) {
                aw.WriteAction(action);
            }

            var size = awmem.Length + (record.Flags.ClipEventKeyPress ? 1 : 0);
            writer.WriteUInt32((uint)size);

            if (record.Flags.ClipEventKeyPress) {
                writer.WriteByte(record.KeyCode);
            }

            writer.WriteBytes(awmem.ToArray());
        }
예제 #5
0
        public static ClipActionRecord ReadClipActionRecord(this ISwfStreamReader reader, byte swfVersion)
        {
            var record = new ClipActionRecord();
            record.Flags = reader.ReadClipEventFlags(swfVersion);
            if (record.Flags.IsEmpty) return record;

            var offset = reader.ReadUInt32();
            if (record.Flags.ClipEventKeyPress) {
                record.KeyCode = reader.ReadByte();
            }

            ActionBase action;
            var ar = new ActionReader(reader);
            do {
                action = ar.ReadAction();
                record.Actions.Add(action);
            } while (!(action is ActionEnd));

            return record;
        }
예제 #6
0
        public static void WriteClipActionRecord(this ISwfStreamWriter writer, byte swfVersion, ClipActionRecord record)
        {
            writer.WriteClipEventFlags(swfVersion, record.Flags);
            if (record.Flags.IsEmpty)
            {
                return;
            }

            var awmem = new MemoryStream();
            var aw    = new ActionWriter(new SwfStreamWriter(awmem));

            foreach (var action in record.Actions)
            {
                aw.WriteAction(action);
            }

            var size = awmem.Length + (record.Flags.ClipEventKeyPress ? 1 : 0);

            writer.WriteUInt32((uint)size);

            if (record.Flags.ClipEventKeyPress)
            {
                writer.WriteByte(record.KeyCode);
            }

            writer.WriteBytes(awmem.ToArray());
        }