Exemplo n.º 1
0
        public static XElement ToXml(LineStyleEx lineStyle)
        {
            var res = new XElement("LineStyle",
                                   new XAttribute("width", lineStyle.Width),
                                   new XAttribute("startCapStyle", (byte)lineStyle.StartCapStyle),
                                   new XAttribute("jointStyle", (byte)lineStyle.JoinStyle),
                                   new XAttribute("hasFill", lineStyle.HasFill ? "1" : "0"),
                                   new XAttribute("noHScale", lineStyle.NoHScale ? "1" : "0"),
                                   new XAttribute("noVScale", lineStyle.NoVScale ? "1" : "0"),
                                   new XAttribute("pixelHinting", lineStyle.PixelHinting ? "1" : "0"),
                                   new XAttribute("noClose", lineStyle.NoClose ? "1" : "0"),
                                   new XAttribute("endCapStyle", (byte)lineStyle.EndCapStyle)
                                   );

            if (lineStyle.Reserved != 0)
            {
                res.Add(new XAttribute("reserved", lineStyle.Reserved));
            }
            if (lineStyle.JoinStyle == JoinStyle.Miter)
            {
                res.Add(new XAttribute("miterFactor", CommonFormatter.Format(lineStyle.MilterLimitFactor)));
            }
            if (lineStyle.HasFill)
            {
                res.Add(new XElement("fillStyle", XFillStyle.ToXml(lineStyle.FillStyle)));
            }
            else
            {
                res.Add(new XElement("fillColor", XColorRGBA.ToXml(lineStyle.Color)));
            }
            return(res);
        }
Exemplo n.º 2
0
 protected override void FormatPlaceElement(PlaceObject2Tag tag, XElement elem)
 {
     if (tag.HasName)
     {
         elem.Add(new XAttribute(NAME_ATTRIB, tag.Name));
     }
     if (tag.HasClipActions)
     {
         var flags1 = XClipEventFlags.GetFlags1(tag.ClipActions.Flags);
         var flags2 = XClipEventFlags.GetFlags2(tag.ClipActions.Flags);
         elem.Add(new XAttribute("allflags1", flags1));
         elem.Add(new XAttribute("allflags2", flags2));
     }
     if (tag.HasColorTransform)
     {
         elem.Add(new XElement(COLOR_TRANSFORM_ELEM, XColorTransformRGBA.ToXml(tag.ColorTransform)));
     }
     if (tag.HasClipDepth)
     {
         elem.Add(new XAttribute(CLIP_DEPTH, tag.ClipDepth));
     }
     if (tag.HasClipActions)
     {
         elem.Add(XClipActionsList.ToXml(tag.ClipActions));
     }
     if (tag.HasRatio)
     {
         elem.Add(new XAttribute(MORPH_ATTRIB, tag.Ratio));
     }
     elem.Add(new XAttribute(REPLACE_ATTRIB, CommonFormatter.Format(tag.Move)));
 }
Exemplo n.º 3
0
        public static XElement ToXml(ConvolutionFilter filter)
        {
            var res = new XElement(TAG_NAME,
                                   new XAttribute("divisor", CommonFormatter.Format(filter.Divisor)),
                                   new XAttribute("bias", CommonFormatter.Format(filter.Bias))
                                   );

            var xMatrix = new XElement("matrix");

            for (var y = 0; y < filter.MatrixY; y++)
            {
                var xRow = new XElement("r");
                for (var x = 0; x < filter.MatrixX; x++)
                {
                    var xCol = new XElement("c")
                    {
                        Value = CommonFormatter.Format(filter.Matrix[y, x])
                    };
                    xRow.Add(xCol);
                }
                xMatrix.Add(xRow);
            }
            res.Add(xMatrix);

            res.Add(new XElement("color", XColorRGBA.ToXml(filter.DefaultColor)));
            if (filter.Reserved != 0)
            {
                res.Add(new XAttribute("reserved", filter.Reserved));
            }
            res.Add(new XAttribute("clamp", CommonFormatter.Format(filter.Clamp)));
            res.Add(new XAttribute("preserveAlpha", CommonFormatter.Format(filter.PreserveAlpha)));
            return(res);
        }
Exemplo n.º 4
0
 public static XElement ToXml(ZoneData data)
 {
     return(new XElement("ZoneData",
                         new XAttribute("position", CommonFormatter.Format(data.Position)),
                         new XAttribute("size", CommonFormatter.Format(data.Size))
                         ));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Formats color matrix to xml representation.
        /// </summary>
        /// <param name="filter">Filter to format.</param>
        /// <returns>Filter xml representation.</returns>
        public static XElement ToXml(ColorMatrixFilter filter)
        {
            return(new XElement(TAG_NAME,
                                new XAttribute("r0", CommonFormatter.Format(filter.R0)),
                                new XAttribute("r1", CommonFormatter.Format(filter.R1)),
                                new XAttribute("r2", CommonFormatter.Format(filter.R2)),
                                new XAttribute("r3", CommonFormatter.Format(filter.R3)),
                                new XAttribute("r4", CommonFormatter.Format(filter.R4)),

                                new XAttribute("g0", CommonFormatter.Format(filter.G0)),
                                new XAttribute("g1", CommonFormatter.Format(filter.G1)),
                                new XAttribute("g2", CommonFormatter.Format(filter.G2)),
                                new XAttribute("g3", CommonFormatter.Format(filter.G3)),
                                new XAttribute("g4", CommonFormatter.Format(filter.G4)),

                                new XAttribute("b0", CommonFormatter.Format(filter.B0)),
                                new XAttribute("b1", CommonFormatter.Format(filter.B1)),
                                new XAttribute("b2", CommonFormatter.Format(filter.B2)),
                                new XAttribute("b3", CommonFormatter.Format(filter.B3)),
                                new XAttribute("b4", CommonFormatter.Format(filter.B4)),

                                new XAttribute("a0", CommonFormatter.Format(filter.A0)),
                                new XAttribute("a1", CommonFormatter.Format(filter.A1)),
                                new XAttribute("a2", CommonFormatter.Format(filter.A2)),
                                new XAttribute("a3", CommonFormatter.Format(filter.A3)),
                                new XAttribute("a4", CommonFormatter.Format(filter.A4))
                                ));
        }
Exemplo n.º 6
0
        public static XElement ToXml(ZoneRecord zoneRecord)
        {
            var res = new XElement("ZoneArray",
                                   new XAttribute("zoneX", CommonFormatter.Format(zoneRecord.ZoneX)),
                                   new XAttribute("zoneY", CommonFormatter.Format(zoneRecord.ZoneY))
                                   );

            if (zoneRecord.Reserved != 0)
            {
                res.Add(new XAttribute("reserved", zoneRecord.Reserved));
            }

            var xZones = new XElement("zones");

            foreach (var data in zoneRecord.Data)
            {
                xZones.Add(XZoneData.ToXml(data));
            }
            res.Add(xZones);

            if (zoneRecord.Reserved > 0)
            {
                res.Add(new XAttribute("reserved", zoneRecord.Reserved));
            }
            return(res);
        }
Exemplo n.º 7
0
        public static XElement ToXml(this AbcMethod method)
        {
            var res = new XElement("method");

            if (!string.IsNullOrWhiteSpace(method.Name))
            {
                res.Add(new XAttribute("name", method.Name));
            }

            var retType = method.ReturnType.ToXml();

            if (!string.IsNullOrWhiteSpace(retType))
            {
                res.Add(new XAttribute("returns", retType));
            }

            if (method.NeedArguments)
            {
                res.Add(new XAttribute("needArguments", CommonFormatter.Format(method.NeedArguments)));
            }
            if (method.NeedActivation)
            {
                res.Add(new XAttribute("needActivation", CommonFormatter.Format(method.NeedActivation)));
            }
            if (method.NeedRest)
            {
                res.Add(new XAttribute("needRest", CommonFormatter.Format(method.NeedRest)));
            }
            if (method.SetDxns)
            {
                res.Add(new XAttribute("setDxns", CommonFormatter.Format(method.SetDxns)));
            }
            if (method.IgnoreRest)
            {
                res.Add(new XAttribute("ignoreRest", CommonFormatter.Format(method.IgnoreRest)));
            }
            if (method.Native)
            {
                res.Add(new XAttribute("native", CommonFormatter.Format(method.Native)));
            }

            if (method.Params.Count > 0)
            {
                var xParams = new XElement("params");
                foreach (var param in method.Params)
                {
                    xParams.Add(ToXml(param));
                }
                res.Add(xParams);
            }
            if (method.Body != null)
            {
                res.Add(ToXml(method.Body));
            }

            return(res);
        }
Exemplo n.º 8
0
 protected override void FormatAdditionalAttributes(DefineShape4Tag tag, XElement xTag)
 {
     xTag.Add(new XAttribute("nonScalingStrokes", CommonFormatter.Format(tag.UsesNonScalingStrokes)));
     xTag.Add(new XAttribute("scalingStrokes", CommonFormatter.Format(tag.UsesScalingStrokes)));
     if (tag.UsesFillWindingRule)
     {
         xTag.Add(new XAttribute("fillWindingRule", CommonFormatter.Format(tag.UsesFillWindingRule)));
     }
     if (tag.ReservedFlags != 0)
     {
         xTag.Add(new XAttribute("reserved", tag.ReservedFlags));
     }
 }
Exemplo n.º 9
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.º 10
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.º 11
0
        public static XElement ToXml(BlurFilter filter)
        {
            var res = new XElement(TAG_NAME,
                                   new XAttribute("blurX", CommonFormatter.Format(filter.BlurX)),
                                   new XAttribute("blurY", CommonFormatter.Format(filter.BlurY)),
                                   new XAttribute("passes", filter.Passes)
                                   );

            if (filter.Reserved != 0)
            {
                res.Add(new XAttribute("reserved", filter.Reserved));
            }
            return(res);
        }
Exemplo n.º 12
0
        XElement IActionVisitor <XElement, XElement> .Visit(ActionGotoFrame2 action, XElement param)
        {
            var res = new XElement(XActionNames.FromAction(action),
                                   new XAttribute("play", CommonFormatter.Format(action.Play)));

            if (action.SceneBias.HasValue)
            {
                res.Add(new XAttribute("bias", action.SceneBias.Value));
            }
            if (action.Reserved != 0)
            {
                res.Add(new XAttribute("reserved", action.Reserved));
            }
            return(res);
        }
Exemplo n.º 13
0
        public static XElement ToXml(GlowFilter filter)
        {
            var res = new XElement(TAG_NAME,
                                   new XAttribute("blurX", CommonFormatter.Format(filter.BlurX)),
                                   new XAttribute("blurY", CommonFormatter.Format(filter.BlurY)),
                                   new XAttribute("innerGlow", CommonFormatter.Format(filter.InnerGlow)),
                                   new XAttribute("knockout", CommonFormatter.Format(filter.Knockout)),
                                   new XAttribute("passes", filter.Passes),
                                   new XAttribute("strength", CommonFormatter.Format(filter.Strength)),
                                   new XElement("color", XColorRGBA.ToXml(filter.Color)),
                                   new XAttribute("compositeSource", CommonFormatter.Format(filter.CompositeSource))
                                   );

            return(res);
        }
Exemplo n.º 14
0
 public static XElement ToXml(DropShadowFilter filter)
 {
     return(new XElement(TAG_NAME,
                         new XAttribute("angle", CommonFormatter.Format(filter.Angle)),
                         new XAttribute("blurX", CommonFormatter.Format(filter.BlurX)),
                         new XAttribute("blurY", CommonFormatter.Format(filter.BlurY)),
                         new XAttribute("distance", CommonFormatter.Format(filter.Distance)),
                         new XAttribute("innerShadow", CommonFormatter.Format(filter.InnerShadow)),
                         new XAttribute("knockout", CommonFormatter.Format(filter.Knockout)),
                         new XAttribute("compositeSource", CommonFormatter.Format(filter.CompositeSource)),
                         new XAttribute("passes", filter.Passes),
                         new XAttribute("strength", CommonFormatter.Format(filter.Strength)),
                         new XElement("color", XColorRGBA.ToXml(filter.Color))
                         ));
 }
Exemplo n.º 15
0
        protected override void FormatTagElement(CSMTextSettingsTag tag, XElement xTag)
        {
            xTag.Add(new XAttribute(XName.Get("useFlashType"), tag.UseFlashType));
            xTag.Add(new XAttribute(XName.Get("gridFit"), tag.GridFit));

            if (tag.ReservedFlags != 0)
            {
                xTag.Add(new XAttribute("reservedFlags", tag.ReservedFlags));
            }
            xTag.Add(new XAttribute(XName.Get("thickness"), CommonFormatter.Format(tag.Thickness)));
            xTag.Add(new XAttribute(XName.Get("sharpness"), CommonFormatter.Format(tag.Sharpness)));
            if (tag.Reserved != 0)
            {
                xTag.Add(new XAttribute("reserved", tag.ReservedFlags));
            }
        }
Exemplo n.º 16
0
 protected override void FormatPlaceElement(PlaceObject3Tag tag, XElement elem)
 {
     if (tag.Name != null)
     {
         elem.Add(new XAttribute("name", tag.Name));
     }
     if (tag.ClassName != null)
     {
         elem.Add(new XAttribute("className", tag.ClassName));
     }
     if (tag.HasClipActions)
     {
         var flags1 = XClipEventFlags.GetFlags1(tag.ClipActions.Flags);
         var flags2 = XClipEventFlags.GetFlags2(tag.ClipActions.Flags);
         elem.Add(new XAttribute("allflags1", flags1));
         elem.Add(new XAttribute("allflags2", flags2));
     }
     if (tag.Ratio.HasValue)
     {
         elem.Add(new XAttribute("morph", tag.Ratio.Value));
     }
     elem.Add(new XAttribute("replace", CommonFormatter.Format(tag.Move)));
     elem.Add(new XAttribute("hasImage", CommonFormatter.Format(tag.HasImage)));
     if (tag.BitmapCache.HasValue)
     {
         elem.Add(new XAttribute(BITMAP_CACHING_ATTRIB, tag.BitmapCache.Value));
     }
     if (tag.ColorTransform.HasValue)
     {
         elem.Add(new XElement("colorTransform", XColorTransformRGBA.ToXml(tag.ColorTransform.Value)));
     }
     if (tag.Filters.Count > 0)
     {
         var xFilters = new XElement("filters");
         foreach (var filter in tag.Filters)
         {
             xFilters.Add(XFilter.ToXml(filter));
         }
         elem.Add(xFilters);
     }
     if (tag.HasClipActions)
     {
         elem.Add(XClipActionsList.ToXml(tag.ClipActions));
     }
 }
Exemplo n.º 17
0
 protected override void FormatTagElement(FileAttributesTag tag, XElement xTag)
 {
     if (tag.Reserved0)
     {
         xTag.Add(new XAttribute("reserved0", CommonFormatter.Format(tag.Reserved0)));
     }
     xTag.Add(new XAttribute(USE_DIRECT_BLIT, CommonFormatter.Format(tag.UseDirectBlit)));
     xTag.Add(new XAttribute(USE_GPU, CommonFormatter.Format(tag.UseGPU)));
     xTag.Add(new XAttribute(HAS_METADATA_ATTRIB, CommonFormatter.Format(tag.HasMetadata)));
     xTag.Add(new XAttribute(ALLOW_ABC_ATTRIB, CommonFormatter.Format(tag.AllowAbc)));
     xTag.Add(new XAttribute(SUPPRESS_CROSSDOMAIN_CACHING_ATTRIB, CommonFormatter.Format(tag.SuppressCrossDomainCaching)));
     xTag.Add(new XAttribute(SWF_RELATIVE_URLS_ATTRIB, CommonFormatter.Format(tag.SwfRelativeUrls)));
     xTag.Add(new XAttribute(USE_NETWORK_ATTRIB, CommonFormatter.Format(tag.UseNetwork)));
     if (tag.Reserved != 0)
     {
         xTag.Add(new XAttribute("reserved", tag.Reserved));
     }
 }
Exemplo n.º 18
0
        public static XElement ToXml(GradientBevelFilter filter)
        {
            var res = new XElement(TAG_NAME,
                                   new XAttribute("blurX", CommonFormatter.Format(filter.BlurX)),
                                   new XAttribute("blurY", CommonFormatter.Format(filter.BlurY)),
                                   new XAttribute("angle", CommonFormatter.Format(filter.Angle)),
                                   new XAttribute("distance", CommonFormatter.Format(filter.Distance)),
                                   new XAttribute("strength", CommonFormatter.Format(filter.Strength)),
                                   new XAttribute("innerGlow", CommonFormatter.Format(filter.InnerGlow)),
                                   new XAttribute("knockout", CommonFormatter.Format(filter.Knockout)),
                                   new XAttribute("compositeSource", CommonFormatter.Format(filter.CompositeSource)),
                                   new XAttribute("onTop", CommonFormatter.Format(filter.OnTop)),
                                   new XAttribute("passes", filter.Passes)
                                   );

            res.Add(XGradientRecords.ToXml(filter.GradientColors));
            return(res);
        }
Exemplo n.º 19
0
        public static XElement ToXmlRGB(TextRecordRGB entry)
        {
            var res = new XElement(XName.Get("TextRecord6"));

            res.Add(new XAttribute("isSetup", CommonFormatter.Format(entry.Type)));
            if (entry.FontID.HasValue)
            {
                res.Add(new XAttribute("objectID", entry.FontID.Value));
            }
            if (entry.Reserved != 0)
            {
                res.Add(new XAttribute("reserved", entry.Reserved));
            }
            if (entry.XOffset.HasValue)
            {
                res.Add(new XAttribute("x", entry.XOffset.Value));
            }
            if (entry.YOffset.HasValue)
            {
                res.Add(new XAttribute("y", entry.YOffset.Value));
            }
            if (entry.FontID.HasValue)
            {
                if (!entry.TextHeight.HasValue)
                {
                    throw new InvalidOperationException("Text Height must be specified");
                }
                res.Add(new XAttribute("fontHeight", entry.TextHeight.Value));
            }
            if (entry.TextColor.HasValue)
            {
                var color = entry.TextColor.Value;
                res.Add(new XElement("color", XColorRGB.ToXml(color)));
            }
            res.Add(new XElement(XName.Get("glyphs"), entry.Glyphs.Select(FormatGlyphEntry)));
            return(res);
        }
Exemplo n.º 20
0
        XElement IActionVisitor <XElement, XElement> .Visit(ActionDefineFunction2 action, XElement res)
        {
            res.Add(new XAttribute("name", action.Name ?? ""));
            res.Add(new XAttribute("argc", action.Parameters.Count));
            res.Add(new XAttribute("regc", action.RegisterCount));
            res.Add(new XAttribute("preloadParent", CommonFormatter.Format(action.PreloadParent)));
            res.Add(new XAttribute("preloadRoot", CommonFormatter.Format(action.PreloadRoot)));
            res.Add(new XAttribute("suppressSuper", CommonFormatter.Format(action.SuppressSuper)));
            res.Add(new XAttribute("preloadSuper", CommonFormatter.Format(action.PreloadSuper)));
            res.Add(new XAttribute("suppressArguments", CommonFormatter.Format(action.SuppressArguments)));
            res.Add(new XAttribute("preloadArguments", CommonFormatter.Format(action.PreloadArguments)));
            res.Add(new XAttribute("suppressThis", CommonFormatter.Format(action.SuppressThis)));
            res.Add(new XAttribute("preloadThis", CommonFormatter.Format(action.PreloadThis)));
            res.Add(new XAttribute("reserved", action.Reserved));
            res.Add(new XAttribute("preloadGlobal", CommonFormatter.Format(action.PreloadGlobal)));

            var xArgs = new XElement("args");

            foreach (var arg in action.Parameters)
            {
                xArgs.Add(new XElement("Parameter",
                                       new XAttribute("reg", arg.Register),
                                       new XAttribute("name", arg.Name)));
            }
            res.Add(xArgs);

            var xActions = new XElement("actions");

            foreach (var subaction in action.Actions)
            {
                xActions.Add(Serialize(subaction));
            }
            res.Add(xActions);

            return(res);
        }
Exemplo n.º 21
0
        protected override void FormatTagElement(DefineButton2Tag tag, XElement xTag)
        {
            xTag.Add(new XAttribute(MENU_ATTRIB, CommonFormatter.Format(tag.TrackAsMenu)));
            if (tag.ReservedFlags != 0)
            {
                xTag.Add(new XAttribute("reserved", tag.ReservedFlags));
            }

            var xButtons = new XElement("buttons");

            foreach (var button in tag.Characters)
            {
                xButtons.Add(XButtonRecordEx.ToXml(button));
            }
            xTag.Add(xButtons);

            var xConditions = new XElement("conditions");

            foreach (var condition in tag.Conditions)
            {
                xConditions.Add(XButtonCondition.ToXml(condition));
            }
            xTag.Add(xConditions);
        }
Exemplo n.º 22
0
        public static XElement ToXml(ButtonCondition condition)
        {
            var res = new XElement("Condition",
                                   new XAttribute("key", condition.KeyPress),
                                   new XAttribute("menuEnter", CommonFormatter.Format(condition.IdleToOverDown)),
                                   new XAttribute("pointerReleaseOutside", CommonFormatter.Format(condition.OutDownToIdle)),
                                   new XAttribute("pointerDragEnter", CommonFormatter.Format(condition.OutDownToOverDown)),
                                   new XAttribute("pointerDragLeave", CommonFormatter.Format(condition.OverDownToOutDown)),
                                   new XAttribute("pointerReleaseInside", CommonFormatter.Format(condition.OverDownToOverUp)),
                                   new XAttribute("pointerPush", CommonFormatter.Format(condition.OverUpToOverDown)),
                                   new XAttribute("pointerLeave", CommonFormatter.Format(condition.OverUpToIdle)),
                                   new XAttribute("pointerEnter", CommonFormatter.Format(condition.IdleToOverUp)),
                                   new XAttribute("menuLeave", CommonFormatter.Format(condition.OverDownToIdle))
                                   );

            var xActions = new XElement("actions");

            foreach (var action in condition.Actions)
            {
                xActions.Add(XAction.ToXml(action));
            }
            res.Add(xActions);
            return(res);
        }
Exemplo n.º 23
0
        public static XElement ToXml(ButtonRecordEx record)
        {
            var res = new XElement("Button",
                                   new XAttribute("hitTest", CommonFormatter.Format(record.StateHitTest)),
                                   new XAttribute("down", CommonFormatter.Format(record.StateDown)),
                                   new XAttribute("over", CommonFormatter.Format(record.StateOver)),
                                   new XAttribute("up", CommonFormatter.Format(record.StateUp))
                                   );

            if (record.Reserved != 0)
            {
                res.Add(new XAttribute("reserved", record.Reserved));
            }
            if (record.BlendMode.HasValue)
            {
                res.Add(new XAttribute("blendMode", (byte)record.BlendMode));
            }
            if (!record.IsEndButton)
            {
                res.Add(new XAttribute("objectID", record.CharacterID));
                res.Add(new XAttribute("depth", record.PlaceDepth));

                res.Add(new XElement("transform", XMatrix.ToXml(record.PlaceMatrix)));
                res.Add(new XElement("colorTransform", XColorTransformRGBA.ToXml(record.ColorTransform)));
                if (record.Filters.Count > 0)
                {
                    var xFilters = new XElement("filters");
                    foreach (var filter in record.Filters)
                    {
                        xFilters.Add(XFilter.ToXml(filter));
                    }
                    res.Add(xFilters);
                }
            }
            return(res);
        }
Exemplo n.º 24
0
 private static void AddFocalPoint(XElement xml, double val)
 {
     xml.Add(new XAttribute("focalPoint", CommonFormatter.Format(val)));
 }
Exemplo n.º 25
0
        public static XElement ToXml(this AbcTrait trait)
        {
            var res = new XElement("trait",
                                   new XAttribute("name", trait.Name.ToXml()),
                                   new XAttribute("kind", trait.Kind));

            if (trait.Final)
            {
                res.Add(new XAttribute("final", CommonFormatter.Format(trait.Final)));
            }
            if (trait.Override)
            {
                res.Add(new XAttribute("override", CommonFormatter.Format(trait.Override)));
            }
            switch (trait.Kind)
            {
            case AsTraitKind.Slot:
                var slot = (AbcSlotTrait)trait;
                res.Add(new XAttribute("slotId", slot.SlotId));
                res.Add(new XAttribute("typeName", slot.TypeName.ToXml()));
                res.Add(new XAttribute("value", slot.Value.ToXml()));
                break;

            case AsTraitKind.Const:
                var con = (AbcConstTrait)trait;
                res.Add(new XAttribute("slotId", con.SlotId));
                res.Add(new XAttribute("typeName", con.TypeName.ToXml()));
                res.Add(new XAttribute("value", con.Value.ToXml()));
                break;

            case AsTraitKind.Class:
                var cl = (AbcClassTrait)trait;
                res.Add(new XAttribute("slotId", cl.SlotId));
                //todo: class ref
                break;

            case AsTraitKind.Function:
                var func = (AbcFunctionTrait)trait;
                res.Add(new XAttribute("slotId", func.SlotId));
                //todo: method ref
                break;

            case AsTraitKind.Method:
                var met = (AbcMethodTrait)trait;
                res.Add(new XAttribute("dispId", met.DispId));
                //todo: method ref
                break;

            case AsTraitKind.Getter:
                var getter = (AbcGetterTrait)trait;
                res.Add(new XAttribute("dispId", getter.DispId));
                //todo: method ref
                break;

            case AsTraitKind.Setter:
                var setter = (AbcSetterTrait)trait;
                res.Add(new XAttribute("dispId", setter.DispId));
                //todo: method ref
                break;

            default:
                throw new Exception("unsupported trait kind " + trait.Kind);
            }
            if (trait.Metadata.Count > 0)
            {
                res.Add(trait.Metadata.ToXml());
            }
            return(res);
        }
Exemplo n.º 26
0
 public XElement Visit(PushDoubleOpcode opcode, AbcMethodBodyInstruction arg)
 {
     return(new XElement("pushdouble", new XAttribute("value", CommonFormatter.Format(opcode.Value))));
 }