internal static new void InvokeHandler(Delegate handler, IntPtr sender, IntPtr args) { RequestNavigateEventHandler handler_ = (RequestNavigateEventHandler)handler; if (handler_ != null) { handler_(Extend.GetProxy(sender, false), new RequestNavigateEventArgs(args, false)); } }
/// <summary>Invokes a specified event handler from a specified sender. </summary> /// <param name="genericHandler">The name of the handler.</param> /// <param name="genericTarget">The object that is raising the event.</param> // Token: 0x06002A81 RID: 10881 RVA: 0x000C27B0 File Offset: 0x000C09B0 protected override void InvokeEventHandler(Delegate genericHandler, object genericTarget) { if (base.RoutedEvent == null) { throw new InvalidOperationException(SR.Get("RequestNavigateEventMustHaveRoutedEvent")); } RequestNavigateEventHandler requestNavigateEventHandler = (RequestNavigateEventHandler)genericHandler; requestNavigateEventHandler(genericTarget, this); }
public void AddHyperLinkInUI(string text, Uri navigateUri, RequestNavigateEventHandler handle) { Hyperlink hyperlink = new Hyperlink((Inline) new Run(text)) { NavigateUri = navigateUri }; hyperlink.RequestNavigate += new RequestNavigateEventHandler(handle.Invoke); hyperlink.Foreground = (Brush) new SolidColorBrush((Color)ColorConverter.ConvertFromString("#047CD2")); this.mUrlTextBlock.Inlines.Clear(); this.mUrlTextBlock.Inlines.Add((Inline)hyperlink); this.mUrlTextBlock.Visibility = Visibility.Visible; }
private static IEnumerable <Inline> _BuildInlinesFromRawText(string text, RequestNavigateEventHandler navigateCallback) { Assert.IsNotNull(navigateCallback); MatchCollection matches = _SimpleUrlRegex.Matches(text); int index = 0; foreach (Match match in matches) { if (match.Index > index) { yield return(new Run(text.Substring(index, match.Index - index))); } string url = text.Substring(match.Index, match.Length); Hyperlink hyperlink = null; try { hyperlink = new Hyperlink(new Run(url)); string protocoledUrl = url; if (url.StartsWith("www", StringComparison.OrdinalIgnoreCase)) { protocoledUrl = "http://" + url; } hyperlink.NavigateUri = new Uri(protocoledUrl); hyperlink.RequestNavigate += navigateCallback; } catch (UriFormatException) { } if (hyperlink != null) { yield return(hyperlink); } else { yield return(new Run(url)); } index = match.Index + match.Length; } if (index < text.Length) { yield return(new Run(text.Substring(index, text.Length - index))); } }
public static Hyperlink CreateLink(string name, string uri, RequestNavigateEventHandler navigateHandler = null) { Hyperlink link = new Hyperlink(); link.IsEnabled = true; link.Inlines.Add(name); link.NavigateUri = new Uri(uri); if (navigateHandler == null) { link.RequestNavigate += (sender, args) => Process.Start(args.Uri.ToString()); } else { link.RequestNavigate += navigateHandler; } return(link); }
public RichtextHelper(string group, RequestNavigateEventHandler innerLinkHandler) { this.Group = group; this.InnerTopicLinkHandler = innerLinkHandler; }
public SmartFeedback Hyperlink(string text, string url, int spacesBefore = 2, RequestNavigateEventHandler navHandler = null) { // Marshal to UI Thread if (!_paragraph.Dispatcher.CheckAccess()) { _paragraph.Dispatcher.Invoke(new Func<string, string, int, RequestNavigateEventHandler, SmartFeedback>(Hyperlink), text, url, spacesBefore, navHandler); return this; } Hyperlink h = new Hyperlink(); try { h.NavigateUri = new Uri(url, UriKind.RelativeOrAbsolute); } catch (UriFormatException e) { Text("bad uri:" + e.Message, ErrorFontSize, ErrorColor); return this; } h.Inlines.Add(new Run(text)); h.RequestNavigate += navHandler ?? Hyperlink_RequestNavigate; if (spacesBefore > 0) _paragraph.Inlines.Add(new Run(new string(' ', spacesBefore))); _paragraph.Inlines.Add(h); return this; }
/// <summary> /// Iterate the element and its children elements, install event handler to hyper link element. /// </summary> /// <param name="element">The top-level FrameworkElement to process.</param> /// <param name="eventHandler">Event handlder responses user click on the hyper link.</param> /// <returns>The top-level element.</returns> public static FrameworkElement InstallHyperLinkerNavgiateEvent(FrameworkElement element, RequestNavigateEventHandler eventHandler) { if (element == null) { return(element); } foreach (object child in LogicalTreeHelper.GetChildren(element)) { if (child is Hyperlink hyperlink && eventHandler != null) { hyperlink.RequestNavigate += eventHandler; } if (child is FrameworkElement childElement) { InstallHyperLinkerNavgiateEvent(childElement, eventHandler); } } return(element); }
public static T1 AddRequestNavigate <T1>(this T1 hyperlink, RequestNavigateEventHandler handler) where T1 : Hyperlink { hyperlink.RequestNavigate += handler; return(hyperlink); }