Exemplo n.º 1
0
        private XElement GetSwfHeaderXml(SwfFile file)
        {
            var header = file.Header;

            return(new XElement("Header",
                                new XAttribute("framerate", header.FrameRate),
                                new XAttribute("frames", header.FrameCount),
                                new XElement("size", XRect.ToXml(header.FrameSize)),
                                GetTagsXml(file.Tags)));
        }
Exemplo n.º 2
0
        protected sealed override void FormatTagElement(T tag, XElement xTag)
        {
            xTag.Add(new XElement("bounds", XRect.ToXml(tag.TextBounds)));
            xTag.Add(new XElement("transform", XMatrix.ToXml(tag.TextMatrix)));
            var xRecords = new XElement("records");

            xTag.Add(xRecords);
            FormatRecords(tag, xRecords);
            //TODO: remove unnessary nested nodes. Swfmill requires them
        }
Exemplo n.º 3
0
        protected override void FormatTagElement(DefineEditTextTag tag, XElement xTag)
        {
            xTag.Add(new XElement(SIZE_ELEM, XRect.ToXml(tag.Bounds)));

            xTag.Add(new XAttribute(WORD_WRAP_ATTRIB, SwfMillPrimitives.GetStringValue(tag.WordWrap)));
            xTag.Add(new XAttribute(MULTILINE_ATTRIB, SwfMillPrimitives.GetStringValue(tag.Multiline)));
            xTag.Add(new XAttribute(PASSWORD_ATTRIB, SwfMillPrimitives.GetStringValue(tag.Password)));
            xTag.Add(new XAttribute(READONLY_ATTRIB, SwfMillPrimitives.GetStringValue(tag.ReadOnly)));

            xTag.Add(new XAttribute(AUTOSIZE_ATTRIB, SwfMillPrimitives.GetStringValue(tag.AutoSize)));
            xTag.Add(new XAttribute(HAS_LAYOUT_ATTRIB, CommonFormatter.Format(tag.HasLayout)));
            xTag.Add(new XAttribute(NOT_SELECTABLE_ATTRIB, CommonFormatter.Format(tag.NoSelect)));
            xTag.Add(new XAttribute(BORDER_ATTRIB, CommonFormatter.Format(tag.Border)));
            xTag.Add(new XAttribute("static", CommonFormatter.Format(tag.WasStatic)));
            xTag.Add(new XAttribute(IS_HTML_ATTRIB, CommonFormatter.Format(tag.HTML)));
            xTag.Add(new XAttribute(USE_OUTLINES_ATTRIB, CommonFormatter.Format(tag.UseOutlines)));

            if (tag.HasFont)
            {
                xTag.Add(new XAttribute(FONT_REF_ATTRIB, tag.FontID));
            }
            if (tag.FontClass != null)
            {
                xTag.Add(new XAttribute("fontClass", tag.FontClass));
            }
            if (tag.HasFont)
            {
                xTag.Add(new XAttribute(FONT_HEIGHT_ATTRIB, tag.FontHeight));
            }
            if (tag.TextColor.HasValue)
            {
                xTag.Add(new XElement("color", XColorRGBA.ToXml(tag.TextColor.Value)));
            }
            if (tag.MaxLength.HasValue)
            {
                xTag.Add(new XAttribute(MAX_LENGTH_ATTRIB, tag.MaxLength.Value));
            }
            if (tag.HasLayout)
            {
                xTag.Add(new XAttribute(ALIGN_ATTRIB, tag.Align));
                xTag.Add(new XAttribute(LEFT_MARGIN_ATTRIB, tag.LeftMargin));
                xTag.Add(new XAttribute(RIGHT_MARGIN_ATTRIB, tag.RightMargin));
                xTag.Add(new XAttribute(INDENT_ATTRIB, tag.Indent));
                xTag.Add(new XAttribute(LEADING_ATTRIB, tag.Leading));
            }
            xTag.Add(new XAttribute(VARIABLE_NAME_ATTRIB, tag.VariableName));
            if (tag.InitialText != null)
            {
                xTag.Add(new XAttribute(INITIAL_TEXT_ATTRIB, tag.InitialText));
            }
        }
Exemplo n.º 4
0
        protected override void FormatTagElement(DefineFont3Tag tag, XElement xTag)
        {
            xTag.Add(new XAttribute(LANGUAGE_ATTRIB, tag.Language));
            xTag.Add(new XAttribute(SHIFT_JIS_ATTRIB, CommonFormatter.Format(tag.ShiftJIS)));
            xTag.Add(new XAttribute(UNICODE_ATTRIB, CommonFormatter.Format(tag.SmallText)));
            xTag.Add(new XAttribute(ANSI_ATTRIB, CommonFormatter.Format(tag.ANSI)));
            xTag.Add(new XAttribute(WIDE_GLYPH_OFFSETS_ATTRIB, CommonFormatter.Format(tag.WideOffsets)));
            xTag.Add(new XAttribute("wideCodes", CommonFormatter.Format(tag.WideCodes)));
            xTag.Add(new XAttribute(ITALIC_ATTRIB, CommonFormatter.Format(tag.Italic)));
            xTag.Add(new XAttribute(BOLD_ATTRIB, CommonFormatter.Format(tag.Bold)));
            xTag.Add(new XAttribute(NAME_ATTRIB, tag.FontName.TrimEnd('\0')));

            var xGlyphs = new XElement("glyphs");

            foreach (var glyph in tag.Glyphs)
            {
                var xGlyph = XGlyph.ToXml(glyph);
                xGlyphs.Add(xGlyph);
            }
            xTag.Add(xGlyphs);

            if (tag.HasLayout)
            {
                xTag.Add(new XAttribute("ascent", tag.Ascent));
                xTag.Add(new XAttribute("descent", tag.Descent));
                xTag.Add(new XAttribute("leading", tag.Leading));

                var xAdvance = new XElement("advance");
                foreach (var glyph in tag.Glyphs)
                {
                    var xGlyph = new XElement("Short");
                    xGlyph.Add(new XAttribute("value", glyph.Advance));
                    xAdvance.Add(xGlyph);
                }
                xTag.Add(xAdvance);

                var xBounds = new XElement("bounds");
                foreach (var glyph in tag.Glyphs)
                {
                    xBounds.Add(XRect.ToXml(glyph.Bounds));
                }
                xTag.Add(xBounds);

                var xKerningRecords = new XElement("wideKerning");
                foreach (var kerningRecord in tag.KerningRecords)
                {
                    xKerningRecords.Add(XKerningRecord.ToXml(kerningRecord));
                }
                xTag.Add(xKerningRecords);
            }
        }
Exemplo n.º 5
0
        protected sealed override void FormatTagElement(T tag, XElement xTag)
        {
            FormatAdditionalAttributes(tag, xTag);

            xTag.Add(new XElement(BOUNDS_ELEM, XRect.ToXml(tag.ShapeBounds)));

            FormatAdditionalBounds(tag, xTag);

            var xStyles = new XElement(STYLES_ELEM, FormatStyles(tag));

            xTag.Add(xStyles);

            var xShapes = new XElement(SHAPES_ELEM, FormatShape(tag));

            xTag.Add(xShapes);
        }
Exemplo n.º 6
0
 protected override void FormatAdditionalBounds(DefineShape4Tag tag, XElement elem)
 {
     elem.Add(new XElement(EDGE_BOUNDS_ELEM, XRect.ToXml(tag.EdgeBounds)));
 }