private void htmlPanel_LinkClicked(object sender, HtmlLinkClickedEventArgs e) { e.Handled = true; }
/// <summary> /// Handle mouse up to handle selection and link click. /// </summary> /// <param name="parent">the control hosting the html to invalidate</param> /// <param name="e">the mouse event args</param> public void HandleMouseUp(Control parent, MouseEventArgs e) { ArgChecker.AssertArgNotNull(parent, "parent"); ArgChecker.AssertArgNotNull(e, "e"); if (_selectionHandler != null) { var inSelection = _selectionHandler.HandleMouseUp(parent, e.Button); if (!inSelection && (e.Button & MouseButtons.Left) != 0) { var loc = OffsetByScroll(e.Location); var link = DomUtils.GetLinkBox(_root, loc); if (link != null) { if (LinkClicked != null) { var args = new HtmlLinkClickedEventArgs(link.GetAttribute("href")); LinkClicked(this, args); if (args.Handled) { return; } } CssValueParser.GoLink(link.GetAttribute("href", string.Empty), Bridge); } } } }
/// <summary> /// Handle link clicked going over <see cref="LinkClicked"/> event and using <see cref="Process.Start()"/> if not canceled. /// </summary> /// <param name="parent">the control hosting the html to invalidate</param> /// <param name="e">the mouse event args</param> /// <param name="link">the link that was clicked</param> internal void HandleLinkClicked(Control parent, MouseEventArgs e, CssBox link) { if (LinkClicked != null) { var args = new HtmlLinkClickedEventArgs(link.HrefLink, link.HtmlTag.Attributes); LinkClicked(this, args); if (args.Handled) { return; } } if (!string.IsNullOrEmpty(link.HrefLink)) { if (link.HrefLink.StartsWith("#")) { if( ScrollChange != null ) { var box = DomUtils.GetBoxById(_root, link.HrefLink.Substring(1)); if (box != null) { var rect = CommonUtils.GetFirstValueOrDefault(box.Rectangles, box.Bounds); ScrollChange(this, new HtmlScrollEventArgs(Point.Round(rect.Location))); HandleMouseMove(parent, e); } } } else { var nfo = new ProcessStartInfo(link.HrefLink); nfo.UseShellExecute = true; Process.Start(nfo); } } }
/// <summary> /// Propogate the LinkClicked event from root container. /// </summary> protected void OnLinkClicked(object sender, HtmlLinkClickedEventArgs e) { if (LinkClicked != null) { LinkClicked(this, e); } }
/// <summary> /// On specific link click handle it here. /// </summary> private static void OnLinkClicked(object sender, HtmlLinkClickedEventArgs e) { if(e.Link == "SayHello") { MessageBox.Show("Hello you!"); e.Handled = true; } else if (e.Link == "ShowSampleForm") { using (SampleForm f = new SampleForm()) { f.ShowDialog(); e.Handled = true; } } }