Example #1
0
 private void HtmlOnLinkClicked(object sender, HtmlLinkClickedEventArgs htmlLinkClickedEventArgs)
 {
     if (htmlLinkClickedEventArgs.Link.Equals("update")) {
         UpdateHandler.CheckForUpdate();
         htmlLinkClickedEventArgs.Handled = true;
     }
 }
Example #2
0
 private void OnLinkClicked(object sender, HtmlLinkClickedEventArgs e)
 {
     OnLinkClicked(e);
 }
Example #3
0
 /// <summary>
 /// Propagate the LinkClicked event from root container.
 /// </summary>
 protected virtual void OnLinkClicked(HtmlLinkClickedEventArgs e)
 {
     var handler = LinkClicked;
     if (handler != null)
         handler(this, e);
 }
Example #4
0
 /// <summary>
 /// Handles the clicks on the link displayed in the tooltip
 /// </summary>
 /// <param name="htmlLinkClickedEventArgs"></param>
 private static void ClickHandler(HtmlLinkClickedEventArgs htmlLinkClickedEventArgs)
 {
     var split = htmlLinkClickedEventArgs.Link.Split('#');
     var actionType = split[0];
     bool handled = true;
     switch (actionType) {
         case "gotoownerfile":
             if (split.Length > 1) {
                 Npp.Goto(split[1]);
                 Close();
             }
             break;
         case "trigger":
             if (split.Length > 1) {
                 var fullPath = ProEnvironment.Current.FindFirstFileInEnv(split[1]);
                 Npp.Goto(string.IsNullOrEmpty(fullPath) ? split[1] : fullPath);
                 Close();
             }
             break;
         case "proto":
             if (split.Length > 3) {
                 Npp.Goto(split[1], int.Parse(split[2]), int.Parse(split[3]));
                 Close();
             }
         break;
         case "gotodefinition":
             ProMisc.GoToDefinition();
             break;
         case "nexttooltip":
             IndexToShow++;
             TryToShowIndex();
             break;
         default:
             handled = false;
             break;
     }
     htmlLinkClickedEventArgs.Handled = handled;
 }
        /// <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="location">the location of the mouse</param>
        /// <param name="link">the link that was clicked</param>
        internal void HandleLinkClicked(RControl parent, RPoint location, CssBox link)
        {
            if (LinkClicked != null)
            {
                var args = new HtmlLinkClickedEventArgs(link.HrefLink, link.HtmlTag.Attributes);
                try
                {
                    LinkClicked(this, args);
                }
                catch (Exception ex)
                {
                    throw new HtmlLinkClickedException("Error in link clicked intercept", ex);
                }
                if (args.Handled)
                    return;
            }

            if (!string.IsNullOrEmpty(link.HrefLink))
            {
                if (link.HrefLink.StartsWith("#") && link.HrefLink.Length > 1)
                {
                    if (ScrollChange != null)
                    {
                        var rect = GetElementRectangle(link.HrefLink.Substring(1));
                        if (rect.HasValue)
                        {
                            ScrollChange(this, new HtmlScrollEventArgs(rect.Value.Location));
                            HandleMouseMove(parent, location);
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(link.HrefLink) && Directory.Exists(link.HrefLink)) {
                        Process.Start("explorer.exe", "\"" + link.HrefLink + "\"");
                    }
                    else {
                        if (!string.IsNullOrEmpty(link.HrefLink) && File.Exists(link.HrefLink)) {
                            var process = new ProcessStartInfo(link.HrefLink) {UseShellExecute = true};
                            Process.Start(process);
                        } else {
                            if (new Regex(@"^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?$").Match(link.HrefLink).Success) {
                                Process.Start(link.HrefLink);
                            }
                        }
                    }
                }
            }
        }