Example #1
0
        internal void UpdateTextContent()
        {
            var content = templateContent;

            content = content.Replace("{foreground}", HtmlForeground.ToHtml());
            content = content.Replace("{link_foreground}", LinkForeground.ToHtml());
            content = content.Replace("{font_family}", HtmlFontFamily.ToString());
            content = content.Replace("{font_size}", HtmlFontSize.ToString());
            Text    = content.Replace("{text}", HtmlText?.ToString());
        }
        //HtmlFontProperty

        // constrctor for all standard attributes
        public HtmlFontProperty(string name, HtmlFontSize size, bool bold, bool italic, bool underline)
        {
            m_name        = name;
            m_size        = size;
            m_bold        = bold;
            m_italic      = italic;
            m_underline   = underline;
            m_strikeout   = false;
            m_subscript   = false;
            m_superscript = false;
        }
Example #3
0
 // constrctor for all standard attributes
 public HtmlFontProperty(string name, HtmlFontSize size, bool bold, bool italic, bool underline)
 {
     _name = name;
     _size = size;
     _bold = bold;
     _italic = italic;
     _underline = underline;
     _strikeout = false;
     _subscript = false;
     _superscript = false;
 }
Example #4
0
        } //HtmlFontProperty

        /// <summary>
        /// Public constrctor for name and size only
        /// </summary>
        public HtmlFontProperty(string name, HtmlFontSize size)
        {
            _name        = name;
            _size        = size;
            _bold        = false;
            _italic      = false;
            _underline   = false;
            _strikeout   = false;
            _subscript   = false;
            _superscript = false;
        } //HtmlFontProperty
Example #5
0
 // constrctor for name and size only
 public HtmlFontProperty(string name, HtmlFontSize size)
 {
     _name = name;
     _size = size;
     _bold = false;
     _italic = false;
     _underline = false;
     _strikeout = false;
     _subscript = false;
     _superscript = false;
 }
Example #6
0
        } //HtmlFontProperty

        /// <summary>
        /// Public constrctor for all attributes
        /// </summary>
        public HtmlFontProperty(string name, HtmlFontSize size, bool bold, bool italic, bool underline, bool strikeout, bool subscript, bool superscript)
        {
            _name        = name;
            _size        = size;
            _bold        = bold;
            _italic      = italic;
            _underline   = underline;
            _strikeout   = strikeout;
            _subscript   = subscript;
            _superscript = superscript;
        } //HtmlFontProperty
Example #7
0
        } //HtmlFontProperty

        /// <summary>
        /// Public constructor given a system Font
        /// </summary>
        public HtmlFontProperty(System.Drawing.Font font)
        {
            _name        = font.Name;
            _size        = HtmlFontConversion.FontSizeToHtml(font.SizeInPoints);
            _bold        = font.Bold;
            _italic      = font.Italic;
            _underline   = font.Underline;
            _strikeout   = font.Strikeout;
            _subscript   = false;
            _superscript = false;
        } //HtmlFontProperty
 // constructor given a system Font
 public HtmlFontProperty(Font font)
 {
     m_name        = font.Name;
     m_size        = HtmlFontConversion.FontSizeToHtml(font.SizeInPoints);
     m_bold        = font.Bold;
     m_italic      = font.Italic;
     m_underline   = font.Underline;
     m_strikeout   = font.Strikeout;
     m_subscript   = false;
     m_superscript = false;
 }
 public HtmlFontProperty(string name)
 {
     m_name        = name;
     m_size        = HtmlFontSize.Default;
     m_bold        = false;
     m_italic      = false;
     m_underline   = false;
     m_strikeout   = false;
     m_subscript   = false;
     m_superscript = false;
 }
        } //Superscript


        /// <summary>
        /// Public constructor for name only
        /// </summary>
        public HtmlFontProperty(string name)
        {
            _name        = name;
            _size        = HtmlFontSize.Default;
            _sizeInEms   = 0;
            _bold        = false;
            _italic      = false;
            _underline   = false;
            _strikeout   = false;
            _subscript   = false;
            _superscript = false;
        } //HtmlFontProperty
        } //HtmlFontProperty

        /// <summary>
        /// Public constructor for name and size only
        /// </summary>
        public HtmlFontProperty(string name, float ems)
        {
            _name        = name;
            _sizeInEms   = ems;
            _size        = HtmlFontConversion.EmsToHtml(ems);
            _bold        = false;
            _italic      = false;
            _underline   = false;
            _strikeout   = false;
            _subscript   = false;
            _superscript = false;
        } //HtmlFontProperty
        } //HtmlFontProperty

        /// <summary>
        /// Public constructor for all standard attributes
        /// </summary>
        public HtmlFontProperty(string name, HtmlFontSize size, bool bold, bool italic, bool underline)
        {
            _name        = name;
            _size        = size;
            _sizeInEms   = 0;
            _bold        = bold;
            _italic      = italic;
            _underline   = underline;
            _strikeout   = false;
            _subscript   = false;
            _superscript = false;
        } //HtmlFontProperty
Example #13
0
        } //GetCreateInstanceSupported

        /// <summary>
        /// Creates a new HtmlFontProperty from a series of values
        /// </summary>
        public override object CreateInstance(ITypeDescriptorContext context, IDictionary values)
        {
            // obtain the HtmlFontProperty properties
            string       name        = (string)values[PROP_NAME];
            HtmlFontSize size        = (HtmlFontSize)values[PROP_SIZE];
            bool         bold        = (bool)values[PROP_BOLD];
            bool         italic      = (bool)values[PROP_ITALIC];
            bool         underline   = (bool)values[PROP_UNDERLINE];
            bool         strikeout   = (bool)values[PROP_STRIKEOUT];
            bool         subscript   = (bool)values[PROP_SUBSCRIPT];
            bool         superscript = (bool)values[PROP_SUPERSCRIPT];

            // return the new HtmlFontProperty
            return(new HtmlFontProperty(name, size, bold, italic, underline, strikeout, subscript, superscript));
        } //CreateInstance
Example #14
0
        /// <summary>
        /// Returns the correct string size description from a HtmlFontSize
        /// </summary>
        public static string HtmlFontSizeString(HtmlFontSize fontSize)
        {
            // set the size to blank as the default
            // this will ensure font size blanked out if not set
            string size = string.Empty;

            switch (fontSize)
            {
            case HtmlFontSize.xxSmall:
                size = "xx-small";
                break;

            case HtmlFontSize.xSmall:
                size = "x-small";
                break;

            case HtmlFontSize.Small:
                size = "small";
                break;

            case HtmlFontSize.Medium:
                size = "medium";
                break;

            case HtmlFontSize.Large:
                size = "large";
                break;

            case HtmlFontSize.xLarge:
                size = "x-large";
                break;

            case HtmlFontSize.xxLarge:
                size = "xx-large";
                break;

            case HtmlFontSize.Default:
                size = string.Empty;     //small
                break;
            }

            // return the calculated size
            return(size);
        } //HtmlFontSizeString
Example #15
0
        internal void UpdateTextContent()
        {
            var content = string.Empty;

            if (!string.IsNullOrEmpty(templateContent))
            {
                content = templateContent;
            }
            else if (HtmlText?.Contains("<html>") != true)
            {
                content = defaultTemplate;
            }

            content = content.Replace("{foreground}", ColorToHtml(HtmlForeground));
            content = content.Replace("{link_foreground}", ColorToHtml(LinkForeground));
            content = content.Replace("{font_family}", HtmlFontFamily.ToString());
            content = content.Replace("{font_size}", HtmlFontSize.ToString());
            Text    = content.Replace("{text}", HtmlText?.ToString());
        }
Example #16
0
        } //FontSizeToHtml

        /// <summary>
        /// Determines the font size given the html font size
        /// </summary>
        public static float FontSizeFromHtml(HtmlFontSize fontSize)
        {
            return(HtmlFontConversion.FontSizeFromHtml((int)fontSize));
        } //FontSizeFromHtml
 // determine the font size given the html font size
 public static float FontSizeFromHtml(HtmlFontSize fontSize)
 {
     return(FontSizeFromHtml((int)fontSize));
 }
        public static string HtmlGenerator(string htmlTextWithoutHtmlBodyTags, HtmlFontColor fontColorValue = HtmlFontColor.Black, HtmlFontWeight fontWeightValue = HtmlFontWeight.Normal, HtmlFontSize fontSizeEnum = HtmlFontSize.inherit)
        {
            string        _fontSize = fontSizeEnum.ToString().Replace('_', '-');
            StringBuilder sb        = new StringBuilder();

            sb.Append("<html><body style='text-align:center'>");
            sb.Append($"<div style='color:{fontColorValue.ToString().ToLower()};font-weight:{fontWeightValue.ToString().ToLower()};font-size:{_fontSize};padding: 20px 20px 20px 20px; margin: 20px 20px 20px 20px'>");
            sb.Append(htmlTextWithoutHtmlBodyTags);
            sb.Append("</div></body></html>");
            return(sb.ToString());
        }
 /// <summary>
 /// Method using the document to set the Html font size
 /// </summary>
 public void FormatFontSize(HtmlFontSize size)
 {
     ExecuteCommandRange(HTML_COMMAND_FONT_SIZE, (int)size);
 }
        } //FontSizeToHtml


        /// <summary>
        /// Determines the font size given the html font size
        /// </summary>
        public static float FontSizeFromHtml(HtmlFontSize fontSize)
        {
            return HtmlFontConversion.FontSizeFromHtml((int)fontSize);

        } //FontSizeFromHtml
        /// <summary>
        /// Returns the correct string size description from a HtmlFontSize
        /// </summary>
        public static string HtmlFontSizeString(HtmlFontSize fontSize)
        {
            // set the size to blank as the default
            // this will ensure font size blanked out if not set
            string size = string.Empty;

            switch (fontSize)
            {
                case HtmlFontSize.xxSmall:
                    size = "xx-small";
                    break;
                case HtmlFontSize.xSmall:
                    size = "x-small";
                    break;
                case HtmlFontSize.Small:
                    size = "small";
                    break;
                case HtmlFontSize.Medium:
                    size = "medium";
                    break;
                case HtmlFontSize.Large:
                    size = "large";
                    break;
                case HtmlFontSize.xLarge:
                    size = "x-large";
                    break;
                case HtmlFontSize.xxLarge:
                    size = "xx-large";
                    break;
                case HtmlFontSize.Default:
                    size = string.Empty; //small
                    break;
            }

            // return the calculated size
            return size;

        } //HtmlFontSizeString
        } //HtmlFontProperty

        /// <summary>
        /// Public constructor given a system Font
        /// </summary>
        public HtmlFontProperty(System.Drawing.Font font)
        {
            _name = font.Name;
            _size = HtmlFontConversion.FontSizeToHtml(font.SizeInPoints);
            _bold = font.Bold;
            _italic = font.Italic;
            _underline = font.Underline;
            _strikeout = font.Strikeout;
            _subscript = false;
            _superscript = false;

        } //HtmlFontProperty
        } //Superscript


        /// <summary>
        /// Public constrctor for name only
        /// </summary>
        public HtmlFontProperty(string name)
        {
            _name = name;
            _size = HtmlFontSize.Default;
            _bold = false;
            _italic = false;
            _underline = false;
            _strikeout = false;
            _subscript = false;
            _superscript = false;

        } //HtmlFontProperty