Пример #1
0
        public bool Underline { get; set; }                         //文本字体是否加下划线。         

        internal static string ToJson(ServerTextStyle serverTextStyle)
        {
            List<string> jsonlist = new List<string>();
            string json = "{";

            jsonlist.Add(string.Format("\"align\":\"{0}\"", serverTextStyle.Align.ToString()));
            //backcolor格式不对,提交时将此注释删除
            jsonlist.Add(string.Format("\"backColor\":{0}", ServerColor.ToJson(serverTextStyle.BackColor.ToServerColor())));
            jsonlist.Add(string.Format("\"backOpaque\":\"{0}\"", serverTextStyle.BackOpaque.ToString().ToLower()));
            jsonlist.Add(string.Format("\"bold\":\"{0}\"", serverTextStyle.Bold.ToString().ToLower()));
            //jsonlist.Add(string.Format("\"fixedTextSize\":\"{0}\"", serverTextStyle.FixedTextSize.ToString()));
            jsonlist.Add(string.Format("\"fontHeight\":\"{0}\"", serverTextStyle.FontHeight.ToString()));
            jsonlist.Add(string.Format("\"fontName\":\"{0}\"", serverTextStyle.FontName));
            //jsonlist.Add(string.Format("\"fontScale\":\"{0}\"", serverTextStyle.FontScale.ToString()));
            jsonlist.Add(string.Format("\"fontWeight\":\"{0}\"", serverTextStyle.FontWeight.ToString()));
            jsonlist.Add(string.Format("\"fontWidth\":\"{0}\"", serverTextStyle.FontWidth.ToString()));
            //foreColor格式不对,提交时将此注释删除
            jsonlist.Add(string.Format("\"foreColor\":{0}", ServerColor.ToJson(serverTextStyle.ForeColor.ToServerColor())));
            jsonlist.Add(string.Format("\"italic\":\"{0}\"", serverTextStyle.Italic.ToString().ToLower()));
            jsonlist.Add(string.Format("\"italicAngle\":\"{0}\"", serverTextStyle.ItalicAngle.ToString()));
            jsonlist.Add(string.Format("\"opaqueRate\":\"{0}\"", serverTextStyle.OpaqueRate.ToString()));
            jsonlist.Add(string.Format("\"outline\":\"{0}\"", serverTextStyle.Outline.ToString().ToLower()));
            jsonlist.Add(string.Format("\"rotation\":\"{0}\"", serverTextStyle.Rotation.ToString()));
            jsonlist.Add(string.Format("\"shadow\":\"{0}\"", serverTextStyle.Shadow.ToString().ToLower()));
            jsonlist.Add(string.Format("\"sizeFixed\":\"{0}\"", serverTextStyle.SizeFixed.ToString().ToLower()));
            jsonlist.Add(string.Format("\"strikeout\":\"{0}\"", serverTextStyle.Strikeout.ToString().ToLower()));
            jsonlist.Add(string.Format("\"underline\":\"{0}\"", serverTextStyle.Underline.ToString().ToLower()));

            json += string.Join(",", jsonlist.ToArray());
            json += "}";
            return json;
        }
Пример #2
0
        internal static ServerTextStyle FromJson(JsonObject json)
        {
            if (json == null) return null;
            ServerTextStyle textStyle = new ServerTextStyle();

            textStyle.Align = (TextAlignment)Enum.Parse(typeof(TextAlignment), json["align"].GetStringEx(), true);
            textStyle.BackColor = ServerColor.FromJson(json["backColor"].GetObjectEx()).ToColor();
            textStyle.BackOpaque = json["backOpaque"].GetBooleanEx();
            textStyle.Bold = json["bold"].GetBooleanEx();
            textStyle.FontHeight = json["fontHeight"].GetNumberEx();
            textStyle.FontName = json["fontName"].GetStringEx();
            textStyle.FontWeight = (int)json["fontWeight"].GetNumberEx();
            textStyle.FontWidth = json["fontWidth"].GetNumberEx();
            textStyle.ForeColor = ServerColor.FromJson(json["foreColor"].GetObjectEx()).ToColor();
            textStyle.Italic = json["italic"].GetBooleanEx();
            textStyle.ItalicAngle = json["italicAngle"].GetNumberEx();
            textStyle.OpaqueRate = (int)json["opaqueRate"].GetNumberEx();
            textStyle.Outline = json["outline"].GetBooleanEx();
            textStyle.Rotation = json["rotation"].GetNumberEx();
            textStyle.Shadow = json["shadow"].GetBooleanEx();
            textStyle.SizeFixed = json["sizeFixed"].GetBooleanEx();
            textStyle.Strikeout = json["strikeout"].GetBooleanEx();
            textStyle.Underline = json["underline"].GetBooleanEx();
            return textStyle;
        }