当前位置: 首页>>代码示例>>C#>>正文


C# Documents.Hyperlink类代码示例

本文整理汇总了C#中System.Windows.Documents.Hyperlink的典型用法代码示例。如果您正苦于以下问题:C# Hyperlink类的具体用法?C# Hyperlink怎么用?C# Hyperlink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Hyperlink类属于System.Windows.Documents命名空间,在下文中一共展示了Hyperlink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        /// <summary>
        /// Renders the specified chat node to the client.
        /// </summary>
        /// <param name="node">The node to append.</param>
        /// <remarks>
        /// <para>The return value of this function is a reference to the outermost <see cref="HtmlElement">HtmlElement</see> constructed
        /// by this function.  It may create additional inner elements as needed.</para>
        /// </remarks>
        /// <returns>
        /// Returns an object instance of <see cref="HtmlElement">HtmlElement</see> that can be appended to the HTML document.
        /// </returns>
        public override Inline Render(ChatNode node)
        {
            IIconProvider provider = ProfileResourceProvider.GetForClient(null).Icons;

            ImageChatNode icn = node as ImageChatNode;
            if (icn != null)
            {
                InlineUIContainer result = new InlineUIContainer();
                Image img = new Image();
                img.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap((icn.Image as System.Drawing.Bitmap).GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                img.ToolTip = icn.Text;
                img.Width = provider.IconSize.Width;
                img.Height = provider.IconSize.Height;

                result.Child = img;

                if (icn.LinkUri != null)
                {
                    Hyperlink container = new Hyperlink(result);
                    container.NavigateUri = node.LinkUri;
                    container.ToolTip = string.Format(CultureInfo.CurrentUICulture, "Link to {0}", node.LinkUri);

                    return container;
                }

                return result;
            }
            else
            {
                return base.Render(node);
            }
        }
开发者ID:Mofsy,项目名称:jinxbot,代码行数:43,代码来源:ImageChatNodeRenderer.cs

示例2: CompilePalLogger_OnError

        void CompilePalLogger_OnError(string errorText, Error e)
        {
            Dispatcher.Invoke(() =>
            {

                Hyperlink errorLink = new Hyperlink();

                Run text = new Run(errorText);

                text.Foreground = e.ErrorColor;

                errorLink.Inlines.Add(text);
                errorLink.TargetName = e.ID.ToString();
                errorLink.Click += errorLink_Click;

                if (CompileOutputTextbox.Document.Blocks.Any())
                {
                    var lastPara = (Paragraph)CompileOutputTextbox.Document.Blocks.LastBlock;
                    lastPara.Inlines.Add(errorLink);
                }
                else
                {
                    var newPara = new Paragraph(errorLink);
                    CompileOutputTextbox.Document.Blocks.Add(newPara);
                }

                CompileOutputTextbox.ScrollToEnd();

            });
        }
开发者ID:ruarai,项目名称:CompilePal,代码行数:30,代码来源:MainWindow.xaml.cs

示例3: TextToInlines

        /// <summary>
        /// Converts text containing hyperlinks in markdown syntax [text](url)
        /// to a collection of Run and Hyperlink inlines.
        /// </summary>
        public static IEnumerable<Inline> TextToInlines(this string text)
        {
            var inlines = new List<Inline>();

            while (!string.IsNullOrEmpty(text))
            {
                var match = regex.Match(text);
                Uri uri;

                if (match.Success &&
                    match.Groups.Count == 3 &&
                    Uri.TryCreate(match.Groups[2].Value, UriKind.Absolute, out uri))
                {
                    inlines.Add(new Run { Text = text.Substring(0, match.Index) });
                    text = text.Substring(match.Index + match.Length);

                    var link = new Hyperlink { NavigateUri = uri };
                    link.Inlines.Add(new Run { Text = match.Groups[1].Value });
            #if SILVERLIGHT
                    link.TargetName = "_blank";
            #elif !NETFX_CORE
                    link.ToolTip = uri.ToString();
                    link.RequestNavigate += (s, e) => System.Diagnostics.Process.Start(e.Uri.ToString());
            #endif
                    inlines.Add(link);
                }
                else
                {
                    inlines.Add(new Run { Text = text });
                    text = null;
                }
            }

            return inlines;
        }
开发者ID:huoxudong125,项目名称:XamlMapControl,代码行数:39,代码来源:HyperlinkText.cs

示例4: OpenBrowser

 private static void OpenBrowser(Hyperlink link)
 {
     Process proc = new Process();
     proc.StartInfo.UseShellExecute = true;
     proc.StartInfo.FileName = link.NavigateUri.ToString();
     proc.Start();
 }
开发者ID:NobodysNightmare,项目名称:TwitchURLGrabber,代码行数:7,代码来源:MainWindow.xaml.cs

示例5: PropertyChangedCallback

        private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(dependencyObject)) return;
            var contentControl = dependencyObject as ContentControl;
            if (contentControl == null) return;

            var textBlock = new TextBlock();
            var values = GetFormatValues(contentControl);

            int counter = 0;
            foreach (var item in Regex.Split(dependencyPropertyChangedEventArgs.NewValue.ToString(), @"\{.\}"))
            {
                textBlock.Inlines.Add(new Run(item));

                if (values.Length - 1 < counter) continue;
                string[] sSplit = values[counter].Split('$');
                string text = sSplit[0];
                string url = sSplit[1];

                var hyperlink = new Hyperlink(new Run(text)) { NavigateUri = new Uri(url) };
                hyperlink.RequestNavigate += (s, e) => { Process.Start(e.Uri.AbsoluteUri); };
                textBlock.Inlines.Add(hyperlink);
                counter++;
            }
            contentControl.Content = textBlock;
        }
开发者ID:WELL-E,项目名称:Hurricane,代码行数:26,代码来源:ContentControlBehavior.cs

示例6: IndexArticleSection

        /// <summary>
        /// Constructor from Article.Section
        /// </summary>
        /// <param name="section">Section to be displayed.</param>
        public IndexArticleSection(Article.Section section)
        {
            InitializeComponent();

            this.SectionTitle.Text = section.Heading;

            string[] chunks = section.Text.Split('[', ']');
            foreach (string chunk in chunks)
            {
                Run contents = new Run(chunk);

                if (chunk.StartsWith(Article.ArticleIdTag))
                {
                    Match m = RegexArticle.Match(chunk);
                    if (m.Success)
                    {
                        contents.Text = m.Groups[ArticleTitleGroup].Value;

                        Hyperlink link = new Hyperlink(contents);
                        link.CommandParameter = uint.Parse(m.Groups[ArticleIdGroup].Value);

                        this.SectionContents.Inlines.Add(link);
                    }
                    else
                    {
                        this.SectionContents.Inlines.Add(contents);
                    }
                }
                else
                {
                    this.SectionContents.Inlines.Add(contents);
                }
            }
        }
开发者ID:Fullburn,项目名称:Epic,代码行数:38,代码来源:IndexArticleSection.xaml.cs

示例7: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var text = value as string;
            if (text == null) throw new ArgumentException("Value must be of type string.");
            var fd = new FlowDocument();
            var paragraph = new Paragraph();
            var splitText = text.Split(' ');
            foreach (var word in splitText)
            {
                Uri uri;
                bool result = Uri.TryCreate(word, UriKind.Absolute, out uri) && uri.Scheme == Uri.UriSchemeHttp;
                if (result)
                {
                    var hl = new Hyperlink();
                    hl.Inlines.Add(uri.AbsoluteUri);
                    hl.NavigateUri = uri;
                    paragraph.Inlines.Add(hl);
                    paragraph.Inlines.Add(" ");
                }
                else
                {
                    paragraph.Inlines.Add(word);
                    paragraph.Inlines.Add(" ");
                }
            }

            fd.Blocks.Add(paragraph);

            return fd;
        }
开发者ID:rocky3598,项目名称:OpenChat,代码行数:30,代码来源:StringToIRCFlowDocument.cs

示例8: copyLink

 private void copyLink(object sender, RoutedEventArgs e)
 {
     Run testLink = new Run("Test Hyperlink");
     Hyperlink myLink = new Hyperlink(testLink);
     myLink.NavigateUri = new Uri("http://search.msn.com");
     Clipboard.SetDataObject(myLink);
 }
开发者ID:JamesPinkard,项目名称:SolutionsForWork,代码行数:7,代码来源:MainWindow.xaml.cs

示例9: HelpPage

 /// <summary>
 /// Constructor
 /// </summary>
 public HelpPage()
 {
     this.InitializeComponent();
     var version = XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value;
     var versionRun = new Run()
     {
         Text = String.Format(AppResources.AboutPage_VersionRun, version) + "\n"
     };
     VersionParagraph.Inlines.Add(versionRun);
     // Application about text
     var aboutRun = new Run()
     {
         Text = AppResources.HelpPage_AboutRun + "\n"
     };
     AboutParagraph.Inlines.Add(aboutRun);
     // Link to project homepage
     var projectRunText = AppResources.AboutPage_ProjectRun;
     var projectRunTextSpans = projectRunText.Split(new string[] { "{0}" }, StringSplitOptions.None);
     var projectRunSpan1 = new Run { Text = projectRunTextSpans[0] };
     var projectsLink = new Hyperlink();
     projectsLink.Inlines.Add(AppResources.AboutPage_Hyperlink_Project);
     projectsLink.Click += ProjectsLink_Click;
     projectsLink.Foreground = new SolidColorBrush((Color)Application.Current.Resources["PhoneForegroundColor"]);
     projectsLink.MouseOverForeground = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
     var projectRunSpan2 = new Run { Text = projectRunTextSpans[1] + "\n" };
     ProjectParagraph.Inlines.Add(projectRunSpan1);
     ProjectParagraph.Inlines.Add(projectsLink);
     ProjectParagraph.Inlines.Add(projectRunSpan2);
 }
开发者ID:sumitkm,项目名称:recorder,代码行数:32,代码来源:HelpPage.xaml.cs

示例10: ShowNotifier

        public void ShowNotifier(string feedtitle, IEnumerable<Tuple<string, string>> newitemlist)
        {
            if (Opacity > 0)
            {
                holdWindowOpenTimer.Stop();
            }
            else
            {
                titlebox.Inlines.Clear();
                Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(FadeInWindowThingieLikeAnEpicAwesomeToaster));
            }
            titlebox.Inlines.Add(string.Format("New items in {0}", feedtitle));

            foreach (var link in newitemlist)
            {
                titlebox.Inlines.Add(new LineBreak());
                Uri linkuri;
                Uri.TryCreate(link.Item2, UriKind.Absolute, out linkuri);
                var hyperlink = new Hyperlink { NavigateUri = linkuri };
                hyperlink.RequestNavigate += HyperlinkRequestNavigate;
                hyperlink.Inlines.Add(link.Item1);
                titlebox.Inlines.Add(hyperlink);
            }
            PositionWindow();
            holdWindowOpenTimer.Start();
        }
开发者ID:growse,项目名称:Feedling,代码行数:26,代码来源:Notifier.xaml.cs

示例11: FormatName

        public static TweetTextBlock FormatName(TweetTextBlock textblock, string word)
        {
            string userName = String.Empty;
            string firstLetter = word.Substring(0, 1);

            Match foundUsername = Regex.Match(word, @"@(\w+)(?<suffix>.*)");

            if (foundUsername.Success)
            {
                userName = foundUsername.Groups[1].Captures[0].Value;
                Hyperlink name = new Hyperlink();
                name.Inlines.Add(userName);
                name.NavigateUri = new Uri("http://twitter.com/" + userName);
                name.ToolTip = "View @" + userName + "'s recent tweets";
                name.Tag = userName;

                name.Click += new RoutedEventHandler(name_Click);

                if (firstLetter != "@")
                    textblock.Inlines.Add(firstLetter);

                textblock.Inlines.Add("@");
                textblock.Inlines.Add(name);
                textblock.Inlines.Add(foundUsername.Groups["suffix"].Captures[0].Value);
            }
            return textblock;
        }
开发者ID:detroitpro,项目名称:ProStudioTweet,代码行数:27,代码来源:TweetTextBlock.cs

示例12: Initialize

        //=====================================================================

        /// <inheritdoc />
        public override void Initialize(XElement configuration)
        {
            Hyperlink hyperLink;

            // Load the What's New link information
            foreach(var wn in configuration.Elements("whatsNew"))
            {
                hyperLink = new Hyperlink(new Run(wn.Attribute("description").Value));
                hyperLink.Tag = wn.Attribute("url").Value;
                hyperLink.Click += LaunchLink;

                pnlLinks.Children.Add(new Label
                {
                    Margin = new Thickness(20, 0, 0, 0),
                    Content = hyperLink
                });
            }

            if(pnlLinks.Children.Count == 0)
                pnlLinks.Children.Add(new Label
                {
                    Margin = new Thickness(20, 0, 0, 0),
                    Content = "(No new information to report)"
                });

            base.Initialize(configuration);
        }
开发者ID:julianhaslinger,项目名称:SHFB,代码行数:30,代码来源:WhatsNewPage.xaml.cs

示例13: btnCreate_Click

 private void btnCreate_Click(object sender, RoutedEventArgs e)
 {
     int ind = cmbStandard.SelectedIndex+6;
     if (profile.StandardExists(ind))
     {
         StackPanel stack = new StackPanel();
         txtLog.Inlines.Clear();
         txtLog.Inlines.Add(cmbStandard.SelectedItem+ " standard already exists.");
         txtLog.Inlines.Add(new LineBreak());
         txtLog.Inlines.Add("Click ");
         Hyperlink link = new Hyperlink(new  Run("here"));
         link.Click += link_Click;
         link.Tag = ind;
         txtLog.Inlines.Add(link);
         txtLog.Inlines.Add(" to go to the "+cmbStandard.SelectedItem+" standard tab.");
         stack.Orientation = Orientation.Horizontal;
         stack.Children.Add( new TextBlock() { Text = "Standard already exists." });
         stack.Children.Add(new TextBlock() { });
     }
     else
     {
         txtLog.Inlines.Clear();
         Classes.Standard standard=profile.AddStandard(ind);
         AddTab(standard);
     }
 }
开发者ID:aarsee,项目名称:Marksheet-Application,代码行数:26,代码来源:PageStudentMarks.xaml.cs

示例14: AboutPage

 /// <summary>
 /// Constructor
 /// </summary>
 public AboutPage()
 {
     InitializeComponent();
     // Application version number
     var ver = Windows.ApplicationModel.Package.Current.Id.Version;
     var versionRun = string.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
     VersionParagraph.Inlines.Add(versionRun);
     // Application about text
     var aboutRun = new Run()
     {
         Text = AppResources.AboutPage_AboutRun + "\n"
     };
     AboutParagraph.Inlines.Add(aboutRun);
     // Link to project homepage
     var projectRunText = AppResources.AboutPage_ProjectRun;
     var projectRunTextSpans = projectRunText.Split(new string[] { "{0}" }, StringSplitOptions.None);
     var projectRunSpan1 = new Run { Text = projectRunTextSpans[0] };
     var projectsLink = new Hyperlink();
     projectsLink.Inlines.Add(AppResources.AboutPage_Hyperlink_Project);
     projectsLink.Click += ProjectsLink_Click;
     projectsLink.Foreground = new SolidColorBrush((Color)Application.Current.Resources["PhoneForegroundColor"]);
     projectsLink.MouseOverForeground = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
     var projectRunSpan2 = new Run { Text = projectRunTextSpans[1] + "\n" };
     ProjectParagraph.Inlines.Add(projectRunSpan1);
     ProjectParagraph.Inlines.Add(projectsLink);
     ProjectParagraph.Inlines.Add(projectRunSpan2);
 }
开发者ID:sumitkm,项目名称:recorder,代码行数:30,代码来源:AboutPage.xaml.cs

示例15: Format

        public static void Format(string message, InlineCollection collection)
        {
            UrlMatch urlMatch;
            int cur = 0;

            while (UrlMatcher.TryGetMatch(message, cur, out urlMatch))
            {
                string before = message.Substring(cur, urlMatch.Offset - cur);
                if (before.Length > 0)
                    collection.Add(new Run(before));

                var matchRun = new Run(urlMatch.Text);
                try
                {
                    Hyperlink link = new Hyperlink(matchRun);
                    link.NavigateUri = new Uri(urlMatch.Text);
                    link.RequestNavigate += hlink_RequestNavigate;
                    collection.Add(link);
                }
                catch
                {
                    collection.Add(matchRun);
                }

                cur = urlMatch.Offset + urlMatch.Text.Length;
            }

            string ending = message.Substring(cur);
            if (ending.Length > 0)
                collection.Add(new Run(ending));
        }
开发者ID:pointgaming,项目名称:point-gaming-desktop,代码行数:31,代码来源:ChatCommon.cs


注:本文中的System.Windows.Documents.Hyperlink类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。