This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alkalinee
committed
Mar 21, 2015
1 parent
988e19b
commit d4ca2bd
Showing
26 changed files
with
204 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Text.RegularExpressions; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Documents; | ||
|
||
namespace Hurricane.Extensions | ||
{ | ||
class ContentControlExtensions | ||
{ | ||
public static readonly DependencyProperty FormattedContentProperty = DependencyProperty.RegisterAttached( | ||
"FormattedContent", typeof (string), typeof (ContentControlExtensions), new PropertyMetadata(default(string), PropertyChangedCallback)); | ||
|
||
private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) | ||
{ | ||
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; | ||
} | ||
|
||
public static void SetFormattedContent(DependencyObject element, string value) | ||
{ | ||
element.SetValue(FormattedContentProperty, value); | ||
} | ||
|
||
public static string GetFormattedContent(DependencyObject element) | ||
{ | ||
return (string) element.GetValue(FormattedContentProperty); | ||
} | ||
|
||
public static readonly DependencyProperty FormatValuesProperty = DependencyProperty.RegisterAttached( | ||
"FormatValues", typeof (string[]), typeof (ContentControlExtensions), new PropertyMetadata(default(string[]))); | ||
|
||
public static void SetFormatValues(DependencyObject element, string[] value) | ||
{ | ||
element.SetValue(FormatValuesProperty, value); | ||
} | ||
|
||
public static string[] GetFormatValues(DependencyObject element) | ||
{ | ||
return (string[]) element.GetValue(FormatValuesProperty); | ||
} | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
Hurricane/Extensions/Converter/TextWithHyperlinkParametersConverter.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.