/// <summary>
        /// Defines all the body attributes once a document has been loaded
        /// </summary>
        private void DefineBodyAttributes()
        {
            // define the body colors based on the new body html
            if (body.bgColor == null)
            {
                _bodyBackColor = _defaultBodyBackColor;
            }
            else
            {
                _bodyBackColor = ColorTranslator.FromHtml((string)body.bgColor);
            }
            if (body.text == null)
            {
                _bodyForeColor = _defaultBodyForeColor;
            }
            else
            {
                _bodyForeColor = ColorTranslator.FromHtml((string)body.text);
            }

            // define the font object based on current font of new document
            // deafult used unless a style on the body modifies the value
            mshtmlStyle bodyStyle = body.style;
            if (bodyStyle != null)
            {
                string fontName = _bodyFont.Name;
                HtmlFontSize fontSize = _bodyFont.Size;
                bool fontBold = _bodyFont.Bold;
                bool fontItalic = _bodyFont.Italic;
                bool fontUnderline = _bodyFont.Underline;
                // define the font name if defined in the style
                if (bodyStyle.fontFamily != null) fontName = bodyStyle.fontFamily;
                if (bodyStyle.fontSize != null) fontSize = HtmlFontConversion.StyleSizeToHtml(bodyStyle.fontSize.ToString());
                if (bodyStyle.fontWeight != null) fontBold = HtmlFontConversion.IsStyleBold(bodyStyle.fontWeight);
                if (bodyStyle.fontStyle != null) fontItalic = HtmlFontConversion.IsStyleItalic(bodyStyle.fontStyle);
                fontUnderline = bodyStyle.textDecorationUnderline;
                // define the new font object and set the property
                _bodyFont = new HtmlFontProperty(fontName, fontSize, fontBold, fontItalic, fontUnderline);
                this.BodyFont = _bodyFont;
            }

            // define the content based on the current value
            this.ReadOnly = _readOnly;
            this.ScrollBars = _scrollBars;
            this.AutoWordWrap = _autoWordWrap;
        }
        /// <summary>
        /// Private control constructor defining all default values
        /// </summary>
        public HtmlEditorControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // define the default values
            // browser constants and commands
            EMPTY_PARAMETER = System.Reflection.Missing.Value;

            // default values used to reset values
            _defaultBodyBackColor = Color.White;
            _defaultBodyForeColor = Color.Black;
            _defaultBackColor = SystemColors.ControlLight;
            _defaultFont = new HtmlFontProperty(this.Font);

            // define the default values of the properties
            _readOnly = false;
            _toolbarVisible = true;
            _toolbarDock = DockStyle.Bottom;
            _bodyText = DEFAULT_HTML_TEXT;
            _bodyHtml = DEFAULT_HTML_TEXT;
            _bodyBackColor = _defaultBodyBackColor;
            _bodyForeColor = _defaultBodyForeColor;
            _bodyFont = _defaultFont;
            _scrollBars = DisplayScrollBarOption.Auto;
            _imageDirectory = string.Empty;
            _htmlDirectory = string.Empty;
            _navigateWindow = NavigateActionOption.Default;
            _baseHref = string.Empty;
            _autoWordWrap = true;
            _borderSize = DEFAULT_BORDER_SIZE;
            stylesheet = null;
            script = null;

            // define context menu state and size
            this.BackColor = _defaultBackColor;
            this.contextDocumentToolbar.Checked = true;
            this.contextDocumentScrollbar.Checked = true;
            this.contextDocumentWordwrap.Checked = true;
            SetBrowserPanelSize();

            // load the blank Html page to load the MsHtml object model
            BrowserCodeNavigate(BLANK_HTML_PAGE);

            // after load ensure document marked as editable
            this.ReadOnly = _readOnly;
            this.ScrollBars = _scrollBars;
        }
        /// <summary>
        /// Method using the exec command that defines the font properties for the selected text
        /// </summary>
        public void FormatFontAttributes(HtmlFontProperty font)
        {
            // obtain the selected range object
            mshtmlTextRange range = GetTextRange();

            if (range != null && HtmlFontProperty.IsNotNull(font))
            {
                // Use the FONT object to set the properties
                // FontName, FontSize, Bold, Italic, Underline, Strikeout
                ExecuteCommandRange(range, HTML_COMMAND_FONT_NAME, font.Name);
                // set the font size provide set to a value
                if (font.Size != HtmlFontSize.Default) ExecuteCommandRange(range, HTML_COMMAND_FONT_SIZE, (int)font.Size);
                // determine the BOLD property and correct as neccessary
                object currentBold = QueryCommandRange(range, HTML_COMMAND_BOLD);
                bool fontBold = (currentBold is System.Boolean) ? fontBold = (bool)currentBold : false;
                if (font.Bold != fontBold) ExecuteCommandRange(HTML_COMMAND_BOLD, null);
                // determine the UNDERLINE property and correct as neccessary
                object currentUnderline = QueryCommandRange(range, HTML_COMMAND_UNDERLINE);
                bool fontUnderline = (currentUnderline is System.Boolean) ? fontUnderline = (bool)currentUnderline : false;
                if (font.Underline != fontUnderline) ExecuteCommandRange(HTML_COMMAND_UNDERLINE, null);
                // determine the ITALIC property and correct as neccessary
                object currentItalic = QueryCommandRange(range, HTML_COMMAND_ITALIC);
                bool fontItalic = (currentItalic is System.Boolean) ? fontItalic = (bool)currentItalic : false;
                if (font.Italic != fontItalic) ExecuteCommandRange(HTML_COMMAND_ITALIC, null);
                // determine the STRIKEOUT property and correct as neccessary
                object currentStrikeout = QueryCommandRange(range, HTML_COMMAND_STRIKE_THROUGH);
                bool fontStrikeout = (currentStrikeout is System.Boolean) ? fontStrikeout = (bool)currentStrikeout : false;
                if (font.Strikeout != fontStrikeout) ExecuteCommandRange(HTML_COMMAND_STRIKE_THROUGH, null);
                // determine the SUPERSCRIPT property and correct as neccessary
                object currentSuperscript = QueryCommandRange(range, HTML_COMMAND_SUPERSCRIPT);
                bool fontSuperscript = (currentSuperscript is System.Boolean) ? fontSuperscript = (bool)currentSuperscript : false;
                if (font.Superscript != fontSuperscript) ExecuteCommandRange(HTML_COMMAND_SUPERSCRIPT, null);
                // determine the SUBSCRIPT property and correct as neccessary
                object currentSubscript = QueryCommandRange(range, HTML_COMMAND_SUBSCRIPT);
                bool fontSubscript = (currentSubscript is System.Boolean) ? fontSubscript = (bool)currentSubscript : false;
                if (font.Subscript != fontSubscript) ExecuteCommandRange(HTML_COMMAND_SUBSCRIPT, null);
            }
            else
            {
                // do not have text selected or a valid font class
                throw new HtmlEditorException("Invalid Text selection made or Invalid Font selection.", "FormatFont");
            }
        }