private void OpenContextMenu(IHTMLEventObj e) { int x = e.clientX; int y = e.clientY; var htmlDoc = ContentUtils.GetFocusedHtmlDocument(); // Clear old events ContextItemClicked = new HtmlEvent(); ContextItemMouseout = new HtmlEvent(); ContextItemMouseover = new HtmlEvent(); Application.Current.Dispatcher.BeginInvoke((Action)(() => { var window = htmlDoc.parentWindow; CurrentPopup = ((IHTMLWindow4)window).createPopup() as IHTMLPopup; var popupDoc = ((IHTMLDocument2)CurrentPopup.document); var popupBody = popupDoc.body; popupBody.innerHTML = ""; ApplyPopupBodyStyling(popupBody); foreach (var cmd in PluginCmdActionMap.Keys) { AddContextItem(CurrentPopup, cmd); } var popupHeight = (PluginCmdActionMap.Count * 17) + 5; CurrentPopup.Show(x + 2, y + 2, 150, popupHeight, htmlDoc.body); })); }
public HtmlPopupEventArgs(int x, int y, int w, int h, IHTMLPopup popup) { this.x = x; this.y = y; this.w = w; this.h = h; this.popup = popup; }
public HtmlPopup(IHTMLWindow4 wdw) { try { _popup = wdw?.createPopup() as IHTMLPopup; StylePopup(); } catch (UnauthorizedAccessException) { } catch (COMException) { } }
private void AddContextItem(IHTMLPopup popup, string cmdName) { var doc = popup.document as IHTMLDocument2; var body = doc.body as IHTMLDOMNode; var el = doc.createElement("<div>"); ApplyContextItemStyling(el, cmdName); if (!cmdName.IsNullOrEmpty()) { SubscribeToContextItemEvents(el); } body.appendChild((IHTMLDOMNode)el); el.style.color = cmdName.IsNullOrEmpty() ? "GrayText" : "MenuText"; }