示例#1
0
        /// <summary>
        /// Returns RTF descriptor for export to RTF
        /// </summary>
        /// <returns>RTFStyleDescriptor.</returns>
        public override RTFStyleDescriptor GetRTF()
        {
            var result = new RTFStyleDescriptor();

            if (BackgroundBrush is SolidBrush)
            {
                result.BackColor = (BackgroundBrush as SolidBrush).Color;
            }

            if (ForeBrush is SolidBrush)
            {
                result.ForeColor = (ForeBrush as SolidBrush).Color;
            }

            if ((FontStyle & FontStyle.Bold) != 0)
            {
                result.AdditionalTags += @"\b";
            }
            if ((FontStyle & FontStyle.Italic) != 0)
            {
                result.AdditionalTags += @"\i";
            }
            if ((FontStyle & FontStyle.Strikeout) != 0)
            {
                result.AdditionalTags += @"\strike";
            }
            if ((FontStyle & FontStyle.Underline) != 0)
            {
                result.AdditionalTags += @"\ul";
            }

            return(result);
        }
        /// <summary>
        /// Gets the RTF descriptor.
        /// </summary>
        /// <param name="styleIndex">Index of the style.</param>
        /// <returns>RTFStyleDescriptor.</returns>
        private RTFStyleDescriptor GetRtfDescriptor(StyleIndex styleIndex)
        {
            List <Style> styles = new List <Style>();
            //find text renderer
            ZeroitFastTextStyle textStyle = null;
            int  mask = 1;
            bool hasZeroitFastTextStyle = false;

            for (int i = 0; i < tb.Styles.Length; i++)
            {
                if (tb.Styles[i] != null && ((int)styleIndex & mask) != 0)
                {
                    if (tb.Styles[i].IsExportable)
                    {
                        var style = tb.Styles[i];
                        styles.Add(style);

                        bool isZeroitFastTextStyle = style is ZeroitFastTextStyle;
                        if (isZeroitFastTextStyle)
                        {
                            if (!hasZeroitFastTextStyle || tb.AllowSeveralZeroitFastTextStyleDrawing)
                            {
                                hasZeroitFastTextStyle = true;
                                textStyle = style as ZeroitFastTextStyle;
                            }
                        }
                    }
                }
                mask = mask << 1;
            }
            //add ZeroitFastTextStyle css
            RTFStyleDescriptor result = null;

            if (!hasZeroitFastTextStyle)
            {
                //draw by default renderer
                result = tb.DefaultStyle.GetRTF();
            }
            else
            {
                result = textStyle.GetRTF();
            }

            return(result);
        }