コード例 #1
0
        private string GetCss(StyleIndex styleIndex)
        {
            List <Style> allStyles = tb.GetStylesOfStyleIndex(styleIndex);
            List <Style> styles    = new List <Style>();
            //find text renderer
            TextStyle textStyle    = null;
            bool      hasTextStyle = false;

            foreach (var style in allStyles)
            {
                if (style.IsExportable)
                {
                    styles.Add(style);

                    bool isTextStyle = style is TextStyle;
                    if (isTextStyle)
                    {
                        if (!hasTextStyle || tb.AllowSeveralTextStyleDrawing)
                        {
                            hasTextStyle = true;
                            textStyle    = style as TextStyle;
                        }
                    }
                }
            }

            //add TextStyle css
            string result = "";

            if (!hasTextStyle)
            {
                //draw by default renderer
                result = tb.DefaultStyle.GetCSS();
            }
            else
            {
                result = textStyle.GetCSS();
            }
            //add no TextStyle css
            foreach (var style in styles)
            {
//            if (style != textStyle)
                if (!(style is TextStyle))
                {
                    result += style.GetCSS();
                }
            }

            return(result);
        }