예제 #1
0
        /// <summary>
        /// Creates XML for a given style
        /// </summary>
        /// <returns>Style in XML format</returns>
        public string ToXML()
        {
            StringBuilder result = new StringBuilder();

            result.Append("<TableStyle ID=\"" + ID + "\"");
            result.Append(Serialize.Brush(BorderBrush, " BorderBrush", false));
            result.Append(" BorderThickness=\"" + BorderThickness.ToString() + "\"");
            result.Append(Serialize.Brush(CellBorderBrush, " CellBorderBrush", false));
            result.Append(" CellBorderThickness=\"" + CellBorderThickness.ToString() + "\"");
            result.Append(" CellPadding=\"" + CellPadding.ToString(CultureInfo.InvariantCulture) + "\"");
            result.Append(">\r");
            result.Append(Serialize.Brush(Background, "Background", true));
            result.Append(Serialize.Brush(CellFill, "CellFill", true));
            result.Append(Serialize.Brush(HeaderFill, "HeaderFill", true));
            result.Append("</TableStyle>\r");

            return(result.ToString());
        }
예제 #2
0
        /// <summary>
        /// Creates XML for a given style
        /// </summary>
        /// <returns>Style in XML format</returns>
        public string ToXML()
        {
            StringBuilder result = new StringBuilder();

            result.Append("<Style ID=\"" + ID + "\" FontFamily=\"" + Family + "\" FontSize=\"" + Size.ToString() + "\"");
            if (Style == FontStyles.Italic)
            {
                result.Append(" FontStyle=\"Italic\"");
            }
            if (Weight == FontWeights.Bold)
            {
                result.Append(" FontWeight=\"Bold\"");
            }
            if (Decorations == TextDecorations.Underline)
            {
                result.Append(" Decoration=\"Underline\"");
            }

            result.Append(Serialize.Brush(Foreground, " Foreground", false));

            if (Background is SolidColorBrush)
            {
                if (((SolidColorBrush)Background).Color.A > 0)
                {
                    result.Append(Serialize.Brush(Background, " Background", false));
                }
            }

            result.Append(Serialize.Brush(BorderBrush, " BorderBrush", false));
            result.Append(Serialize.Brush(ShadowBrush, " ShadowBrush", false));

            result.Append(" Alignment=\"" + Alignment.ToString() + "\"");

            if (VerticalAlignment != VerticalAlignment.Bottom)
            {
                result.Append(" VerticalAlignment=\"" + VerticalAlignment.ToString() + "\"");
            }

            switch (Special)
            {
            case RichTextSpecialFormatting.Subscript:
                result.Append(" Special=\"Subscript\"");
                break;

            case RichTextSpecialFormatting.Superscript:
                result.Append(" Special=\"Superscript\"");
                break;

            default:
                break;
            }

            switch (Effect)
            {
            case TextBlockPlusEffect.Strike:
                result.Append(" Effect=\"Strike\"");
                break;

            default:
                break;
            }

            switch (BorderType)
            {
            case BorderEffect.Solid:
                result.Append(" Border=\"Solid\"");
                break;

            case BorderEffect.Dotted:
                result.Append(" Border=\"Dotted\"");
                break;

            case BorderEffect.Dashed:
                result.Append(" Border=\"Dashed\"");
                break;

            default:
                break;
            }

            switch (Shadow)
            {
            case ShadowEffect.Slight:
                result.Append(" Shadow=\"Slight\"");
                break;

            case ShadowEffect.Normal:
                result.Append(" Shadow=\"Normal\"");
                break;

            default:
                break;
            }

            if (Margin.Bottom != 0 || Margin.Left != 0 | Margin.Right != 0 || Margin.Top != 0)
            {
                result.Append(" Margin=\"" + Margin.ToString() + "\"");
            }

            result.Append(" />\r");

            return(result.ToString());
        }