Inheritance: IRtfHtmlStyle
        // ----------------------------------------------------------------------
        public virtual IRtfHtmlStyle TextToHtml( IRtfVisualText visualText )
        {
            if ( visualText == null )
            {
                throw new ArgumentNullException( "visualText" );
            }

            RtfHtmlStyle htmlStyle = new RtfHtmlStyle();

            IRtfTextFormat textFormat = visualText.Format;

            // background color
            Color backgroundColor = textFormat.BackgroundColor.AsDrawingColor;
            if ( backgroundColor.R != 0 || backgroundColor.G != 0 || backgroundColor.B != 0 )
            {
                htmlStyle.BackgroundColor = ColorTranslator.ToHtml( backgroundColor );
            }

            // foreground color
            Color foregroundColor = textFormat.ForegroundColor.AsDrawingColor;
            if ( foregroundColor.R != 0 || foregroundColor.G != 0 || foregroundColor.B != 0 )
            {
                htmlStyle.ForegroundColor = ColorTranslator.ToHtml( foregroundColor );
            }

            // font
            htmlStyle.FontFamily = textFormat.Font.Name;
            if ( textFormat.FontSize > 0 )
            {
                htmlStyle.FontSize = (textFormat.FontSize /2) + "pt";
            }

            return htmlStyle;
        }
Ejemplo n.º 2
0
        }         // GetHashCode

        // ----------------------------------------------------------------------
        private bool IsEqual(object obj)
        {
            RtfHtmlStyle compare = obj as RtfHtmlStyle;             // guaranteed to be non-null

            return
                (compare != null &&
                 string.Equals(foregroundColor, compare.foregroundColor) &&
                 string.Equals(backgroundColor, compare.backgroundColor) &&
                 string.Equals(fontFamily, compare.fontFamily) &&
                 string.Equals(fontSize, compare.fontSize));
        }         // IsEqual
Ejemplo n.º 3
0
        // ----------------------------------------------------------------------
        public virtual IRtfHtmlStyle TextToHtml(IRtfVisualText visualText)
        {
            if (visualText == null)
            {
                throw new ArgumentNullException("visualText");
            }

            RtfHtmlStyle htmlStyle = new RtfHtmlStyle();

            IRtfTextFormat textFormat = visualText.Format;

            // background color
            Color backgroundColor = textFormat.BackgroundColor.AsDrawingColor;

            if (backgroundColor.R != 0 || backgroundColor.G != 0 || backgroundColor.B != 0)
            {
                htmlStyle.BackgroundColor = ColorTranslator.ToHtml(backgroundColor);
            }

            // foreground color
            Color foregroundColor = textFormat.ForegroundColor.AsDrawingColor;

            if (foregroundColor.R != 0 || foregroundColor.G != 0 || foregroundColor.B != 0)
            {
                htmlStyle.ForegroundColor = ColorTranslator.ToHtml(foregroundColor);
            }

            // font
            htmlStyle.FontFamily = textFormat.Font.Name;
            if (textFormat.FontSize > 0)
            {
                htmlStyle.FontSize = (textFormat.FontSize / 2) + "pt";
            }

            return(htmlStyle);
        } // TextToHtml