Basically, I need to load any HTML document into WebBrowser and allow users to visually select one or more HTML DOM elements (to get their XPaths, but that's a different story).
Hovering an element selects it with color A, moving the mouse will restore its visual state.
Clicking on an element will highlight it with color B, clicking again on the element that previously clicked will restore its visual state.
To summarize, it should behave as a function of the FireBug Inspect Element or as a Dapp Factory Select Content Function.
The naive approach is to use the HtmlElement.Style property, as in the example below, but obviously I cannot, because the element could already have a border style set in the same way, in which case it cannot be deleted in MouseLeave:
void Document_MouseOver(object sender, HtmlElementEventArgs e)
{
e.FromElement.Style = "border: solid 1px Red; " + e.FromElement.Style;
[...]
}
Perhaps I could achieve this by setting / disabling my own CSS class (as is the case with JavaScript), but the HtmlElement does not seem to reveal such a property, and how would I introduce CSS class definitions anyway?
Update : you can actually set the CSS class with HtmlElement.SetAttribute("className"); to add CSS classes, check for example C #: best way to embed CSS in an MSHTML instance? .
Any ideas on how to achieve this are welcome. Thank.