public static void SetLaunchHyperlink(Hyperlink element, bool Value)
 {
     element.SetValue(LaunchHyperlinkProperty, Value);
 }
 public static void SetIsEnabled(Hyperlink element, bool value)
 {
     element.SetValue(IsEnabledProperty, value);
 }
示例#3
0
 /// <summary>
 /// Sets whether the target <see cref="Hyperlink"/>'s RequestNavigation event should open the URI in the
 /// default web browser.
 /// </summary>
 public static void SetNavigateExternally(Hyperlink element, bool value)
 {
     element.SetValue(NavigateExternallyProperty, value);
 }
 public static void SetWebUrl(Hyperlink element, string value)
 {
     element.SetValue(WebUrlProperty, value);
 }
示例#5
0
        public void AddInlines(InlineCollection inlineCollection, IEnumerable<ColorTextPair> pairs, bool allowHyperlinks)
        {
            Run run;
            foreach (ColorTextPair pair in pairs)
            {
                bool hasHyperlinks = false;
                if (allowHyperlinks)
                {
                    if (!string.IsNullOrEmpty(pair.Text))
                    {
                        MatchCollection matches = new Regex(ZChat.Options.HyperlinkPattern).Matches(pair.Text);
                        if (matches.Count > 0)
                        {
                            hasHyperlinks = true;
                            string linkText;
                            int linkStart = 0, linkLength = 0;
                            int curPos = 0;
                            foreach (Match match in matches)
                            {
                                if (match.Value.StartsWith(" "))
                                {
                                    linkStart = match.Index + 1;
                                    linkLength = match.Length - 1;
                                }
                                else
                                {
                                    linkStart = match.Index;
                                    linkLength = match.Length;
                                }
                                linkText = pair.Text.Substring(linkStart, linkLength);

                                Hyperlink link = new Hyperlink(new Run(linkText));
                                link.Foreground = ZChat.Options.LinkFore;
                                link.SetValue(KeyboardNavigation.IsTabStopProperty, false);
                                //if (link.FontStyle) link.TextDecorations.Add(TextDecorations.Underline);
                                link.Click += new RoutedEventHandler(link_Click);
                                link.Tag = linkText;
                                run = new Run(pair.Text.Substring(curPos, linkStart - curPos));
                                run.Foreground = pair.Color;
                                if (linkStart > 0) inlineCollection.Add(run);
                                curPos = linkStart + linkLength;
                                inlineCollection.Add(link);
                            }
                            if (curPos < pair.Text.Length)
                            {
                                run = new Run(pair.Text.Substring(curPos, pair.Text.Length - curPos));
                                run.Foreground = pair.Color;
                                inlineCollection.Add(run);
                            }
                        }
                    }
                }
                if (hasHyperlinks == false)
                {
                    AddNonHyperlinkText(inlineCollection, pair.Text, pair.Color);
                    //run = new Run(pair.Text);
                    //run.Foreground = pair.Color;
                    //inlineCollection.Add(run);
                }
            }
        }