Example #1
0
        /// <summary>
        /// Inicializa una nueva instancia de la clase <see cref="Style"/> con una cadena como base.
        /// </summary>
        /// <param name="text">Texto conteniendo el estilo.</param>
        public Style(string text)
        {
            var regex = new Regex(RegularExpressions.RegexStyle);
            var match = regex.Match(text);

            if (match.Success)
            {
                Name           = match.Groups["name"].Value;
                FontName       = match.Groups["fontName"].Value;
                FontSize       = double.Parse(match.Groups["fontSize"].Value);
                PrimaryColor   = new TagTypeColor(match.Groups["color1"].Value);
                SecondaryColor = new TagTypeColor(match.Groups["color2"].Value);
                OutlineColor   = new TagTypeColor(match.Groups["color3"].Value);
                BackColor      = new TagTypeColor(match.Groups["color4"].Value);
                PrimaryAlpha   = Maths.HexToInt(match.Groups["alpha1"].Value);
                SecondaryAlpha = Maths.HexToInt(match.Groups["alpha2"].Value);
                OutlineAlpha   = Maths.HexToInt(match.Groups["alpha3"].Value);
                BackAlpha      = Maths.HexToInt(match.Groups["alpha4"].Value);

                Bold = false;
                if (match.Groups["bold"].Value == "-1")
                {
                    Bold = true;
                }

                Italic = false;
                if (match.Groups["italic"].Value == "-1")
                {
                    Italic = true;
                }

                Underline = false;
                if (match.Groups["underline"].Value == "-1")
                {
                    Underline = true;
                }

                StrikeOut = false;
                if (match.Groups["strikeout"].Value == "-1")
                {
                    StrikeOut = true;
                }

                Bold = false;
                if (match.Groups["bold"].Value == "-1")
                {
                    Bold = true;
                }

                ScaleX  = double.Parse(match.Groups["scaleX"].Value);
                ScaleY  = double.Parse(match.Groups["scaleX"].Value);
                Spacing = double.Parse(match.Groups["spacing"].Value);
                Angle   = double.Parse(match.Groups["angle"].Value);

                BorderStyle = false;
                if (match.Groups["borderStyle"].Value == "3")
                {
                    StrikeOut = true;
                }

                Outline        = double.Parse(match.Groups["outline"].Value);
                Shadow         = double.Parse(match.Groups["shadow"].Value);
                Alignment      = AlignmentInfo.StringToAlignment(match.Groups["alignment"].Value);
                MarginLeft     = int.Parse(match.Groups["marginL"].Value);
                MarginRight    = int.Parse(match.Groups["marginR"].Value);
                MarginVertical = int.Parse(match.Groups["marginV"].Value);
                Encoding       = CodificacionesInfo.StringToCodificacion(match.Groups["encoding"].Value);
            }
        }