示例#1
0
 public TmxText(XElement xText)
 {
     FontFamily = (string)xText.Attribute("fontfamily") ?? "sans-serif";
     PixelSize  = (int?)xText.Attribute("pixelsize") ?? 16;
     Wrap       = (bool?)xText.Attribute("wrap") ?? false;
     Color      = TmxColor.ParseColor(xText.Attribute("color"));
     Bold       = (bool?)xText.Attribute("bold") ?? false;
     Italic     = (bool?)xText.Attribute("italic") ?? false;
     Underline  = (bool?)xText.Attribute("underline") ?? false;
     Strikeout  = (bool?)xText.Attribute("strikeout") ?? false;
     Kerning    = (bool?)xText.Attribute("kerning") ?? true;
     Alignment  = new TmxAlignment(xText.Attribute("halign"), xText.Attribute("valign"));
     Value      = xText.Value;
 }
示例#2
0
        public static TmxAlignment LoadTmxAlignment(this TmxAlignment alignment, XElement xText)
        {
            string FirstLetterToUpperCase(string str)
            {
                if (string.IsNullOrEmpty(str))
                {
                    return(str);
                }
                return(str[0].ToString().ToUpper() + str.Substring(1));
            }

            var xHorizontal = (string)xText.Attribute("halign") ?? "Left";

            alignment.Horizontal = (TmxHorizontalAlignment)Enum.Parse(typeof(TmxHorizontalAlignment), FirstLetterToUpperCase(xHorizontal));

            var xVertical = (string)xText.Attribute("valign") ?? "Top";

            alignment.Vertical = (TmxVerticalAlignment)Enum.Parse(typeof(TmxVerticalAlignment), FirstLetterToUpperCase(xVertical));

            return(alignment);
        }