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); }
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; }
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; }
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()); }
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; }
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()); }