本文整理汇总了C#中System.Windows.Documents.Hyperlink类的典型用法代码示例。如果您正苦于以下问题:C# Hyperlink类的具体用法?C# Hyperlink怎么用?C# Hyperlink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hyperlink类属于System.Windows.Documents命名空间,在下文中一共展示了Hyperlink类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var htmlText = value as string;
if (string.IsNullOrWhiteSpace(htmlText))
return value;
var splits = Regex.Split(htmlText, "<a ");
var result = new List<Inline>();
foreach (var split in splits)
{
if (!split.StartsWith("href=\""))
{
result.AddRange(FormatText(split));
continue;
}
var match = Regex.Match(split, "^href=\"(?<url>(.+?))\" class=\".+?\">(?<text>(.*?))</a>(?<content>(.*?))$", RegexOptions.Singleline);
if (!match.Success)
{
result.Add(new Run(split));
continue;
}
var hyperlink = new Hyperlink(new Run(match.Groups["text"].Value))
{
NavigateUri = new Uri(match.Groups["url"].Value)
};
hyperlink.RequestNavigate += Hyperlink_RequestNavigate;
result.Add(hyperlink);
result.AddRange(FormatText(match.Groups["content"].Value));
}
return result;
}
开发者ID:caesay,项目名称:Hurricane,代码行数:33,代码来源:HtmlToInlinesConverter.cs
示例17: DecorateAsHyperlink
public static Inline DecorateAsHyperlink(string text)
{
var hyperlink = new Hyperlink(new Run(text)) { NavigateUri = new Uri(text) };
hyperlink.Click += HyperlinkClickHandler;
hyperlink.SetResourceReference(FrameworkContentElement.StyleProperty, "hyperlinkStyle");
return hyperlink;
}
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:7,代码来源:HyperlinkDecorator.cs
示例18: about
public about()
{
InitializeComponent();
aboutBox.AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(RequestNavigateHandler));
// Create a FlowDocument to contain content for the RichTextBox.
FlowDocument myFlowDoc = new FlowDocument();
// Add paragraphs to the FlowDocument.
Hyperlink oskarGithub = new Hyperlink();
oskarGithub.Inlines.Add("github");
oskarGithub.NavigateUri = new Uri("https://github.com/oskarp/redminetimetask");
Hyperlink redmineLib = new Hyperlink();
redmineLib.Inlines.Add("Redmine-net-api");
redmineLib.NavigateUri = new Uri("https://github.com/zapadi/redmine-net-api");
// Create a paragraph and add the Run and hyperlink to it.
Paragraph mePa = new Paragraph();
mePa.Inlines.Add("This project is open source and hosted at ");
mePa.Inlines.Add(oskarGithub);
myFlowDoc.Blocks.Add(mePa);
Paragraph redminePa = new Paragraph();
redminePa.Inlines.Add("We use ");
redminePa.Inlines.Add(redmineLib);
redminePa.Inlines.Add(" for the redmine communication.");
myFlowDoc.Blocks.Add(redminePa);
// Add initial content to the RichTextBox.
aboutBox.Document = myFlowDoc;
}
开发者ID:oskarp,项目名称:RedmineNaiveTimeLog,代码行数:32,代码来源:About.xaml.cs
示例19: Populate
public void Populate(IEnumerable<ILayer> layers)
{
Children.Clear();
foreach (var layer in layers)
{
if (string.IsNullOrEmpty(layer.Attribution.Text)) continue;
var attribution = new StackPanel {Orientation = Orientation.Horizontal};
var textBlock = new TextBlock();
if (string.IsNullOrEmpty(layer.Attribution.Url))
{
textBlock.Text = layer.Attribution.Text;
}
else
{
var hyperlink = new Hyperlink();
hyperlink.Inlines.Add(layer.Attribution.Text);
hyperlink.NavigateUri = new Uri(layer.Attribution.Url);
hyperlink.RequestNavigate += (sender, args) => Process.Start(args.Uri.ToString());
textBlock.Inlines.Add(hyperlink);
textBlock.Padding = new Thickness(6,2,6,2);
attribution.Children.Add(textBlock);
}
Children.Add(attribution);
}
}
开发者ID:pauldendulk,项目名称:Mapsui,代码行数:26,代码来源:AttributionPanel.cs
示例20: GetConvertedText
private InlineCollection GetConvertedText(object value)
{
if (value == null)
{
return null;
}
TextBlock tb = new TextBlock();
TextBlock tbUserName = new TextBlock();
string statusContent = string.Empty;
Binding bind = new Binding();
TweetsTemplate tweetTemplate = new TweetsTemplate();
Hyperlink hyperLinkUser = new Hyperlink();
Style usernameStyle = (Style)tweetTemplate.FindResource("UsernameLinkStyle");
hyperLinkUser.Style = usernameStyle;
hyperLinkUser.Command = TOBCommands.ShowUserProfile;
switch (value.GetType().Name)
{
case "Status":
{
statusContent = StatusText(value, tb, tbUserName, statusContent, bind, hyperLinkUser);
break;
}
case "TwitterSearchStatus":
{
statusContent = SearchText(value, tb, tbUserName, statusContent, bind, hyperLinkUser);
break;
}
case "TwitterStatus":
{
statusContent = TwitterStatusText(value, tb, tbUserName, statusContent, bind, hyperLinkUser);
break;
}
}
return GetInlineCollections(tb, statusContent, bind, tweetTemplate, hyperLinkUser);
}
开发者ID:ankitb,项目名称:TweetOBox,代码行数:35,代码来源:TagsLinkConverter.cs
注:本文中的System.Windows.Documents.Hyperlink类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论