protected virtual void SetPaintColors(IHTMLElement element) { IHTMLElement2 element2 = (element as IHTMLElement2); string textColor = HTMLColorHelper.GetTextColorString(element2); _textColorHex = HTMLColorHelper.ParseColorToHex(textColor); _textColor = HTMLColorHelper.GetColorFromHexColor(_textColorHex, Color.Black); string backgroundColor = HTMLColorHelper.GetBackgroundColorString(element2); _backgroundColorHex = HTMLColorHelper.ParseColorToHex(backgroundColor); _backgroundColor = HTMLColorHelper.GetColorFromHexColor(_backgroundColorHex, Color.White); }
/// <summary> /// Detect the background color of a post body from a URI where /// the post body element contains BlogEditingTemplate.POST_BODY_MARKER. /// This must be done in a browser (as opposed to a simple DOM) because /// the page elements don't layout relative to each other unless they /// are being displayed in a browser. /// </summary> public static Color?DetectColor(string uri, Color?defaultColor) { return(BrowserOperationInvoker.InvokeAfterDocumentComplete(uri, "BackgroundColorDetector", 700, 700, defaultColor, delegate(ExplorerBrowserControl browser) { IHTMLDocument2 document = browser.Document as IHTMLDocument2; IHTMLElement[] elements = HTMLDocumentHelper.FindElementsContainingText(document, BlogEditingTemplate.POST_BODY_MARKER); if (elements.Length == 1) { IHTMLElement postBody = elements[0]; if (postBody.offsetHeight < 300) { postBody.style.height = 300; } return HTMLColorHelper.GetBackgroundColor(postBody, true, null, Color.White); } return defaultColor; })); }