//</SNIPPET3> //<SNIPPET4> private void CreateHyperlinkFromSelection() { if (webBrowser1.Document != null) { MSHTML.IHTMLDocument2 iDoc = (MSHTML.IHTMLDocument2)webBrowser1.Document.DomDocument; if (iDoc != null) { MSHTML.IHTMLSelectionObject iSelect = iDoc.selection; if (iSelect == null) { MessageBox.Show("Please select some text before using this command."); return; } MSHTML.IHTMLTxtRange txtRange = (MSHTML.IHTMLTxtRange)iSelect.createRange(); // Create the link. if (txtRange.queryCommandEnabled("CreateLink")) { Object o = null; txtRange.execCommand("CreateLink", true, o); } } } }
void webBrowser1_Document_Body_KeyDown(object sender, HtmlElementEventArgs e) { if (e.KeyPressedCode == (int)Keys.Tab) { e.ReturnValue = false; } else if (e.KeyPressedCode == (int)Keys.F1) { e.ReturnValue = false; MSHTML.IHTMLDocument2 htmlDocument = webBrowser1.Document.DomDocument as MSHTML.IHTMLDocument2; MSHTML.IHTMLSelectionObject currentSelection = htmlDocument.selection; if (currentSelection != null) { MSHTML.IHTMLTxtRange range = currentSelection.createRange() as MSHTML.IHTMLTxtRange; if (range != null) { if (range.text != null) { if (MainForm.tts == null) { MainForm.tts = new SpeechSynthesizer(); MainForm.tts.SetOutputToDefaultAudioDevice(); } MainForm.tts.SpeakAsyncCancelAll(); MainForm.tts.SpeakAsync(range.text); } } } } }
public static bool ParsePlaceholder(MSHTML.IHTMLTxtRange rng, out string placeholderText, bool atomic = false) { placeholderText = String.Empty; if (!IsPlaceholder(rng, atomic)) { return(false); } return(ParsePlaceholder(rng.text, out placeholderText)); }
public static bool ParsePlaceholder(MSHTML.IHTMLTxtRange rng, out string placeholderText, out int level, bool atomic = false) { placeholderText = string.Empty; level = -1; string placeholder; if (!ParsePlaceholder(rng, out placeholder, atomic)) { return(false); } return(ParsePlaceholder(placeholder, out placeholderText, out level)); }
public static bool IsPlaceholder(MSHTML.IHTMLTxtRange rng, bool atomic = false) { if (rng == null) { return(false); } string unused; if (!ParsePlaceholder(rng.text, out unused)) { return(false); } if (!atomic) { return(true); } return(IsPlaceholder(rng.parentElement(), atomic)); }