private static void FormatStatusFragment(string statusFragment, StatusBindableTextBlock mainTextBlock)
{
string matchText;
Match match;
int position = 0;
while (!string.IsNullOrEmpty(statusFragment))
{
//dopasuj sam tekst, do rozpoczęcia tagu lub nazyw użytkonika
match = BlipRegExp.NormalText.Match(statusFragment);
matchText = match.Value;
if (!string.IsNullOrEmpty(matchText))
{
position = matchText.Length;
//dodaj zwykły tekst do wyświetlenia
mainTextBlock.Inlines.Add(matchText);
//skróć łańcuch
statusFragment = statusFragment.Substring(position);
}
//dopasuj nazwę użytkownika
match = BlipRegExp.User.Match(statusFragment);
matchText = match.Value;
if (!string.IsNullOrEmpty(matchText))
{
position = matchText.Length;
//stwórzy linka użytkownika
Hyperlink h = CreateUserHyperLink(matchText, string.Format(userLinkFormat, matchText.Substring(1)),
matchText, mainTextBlock);
//dołączam linka do wyświetlenia
mainTextBlock.Inlines.Add(h);
statusFragment = statusFragment.Substring(position);
}
match = BlipRegExp.Tag.Match(statusFragment);
matchText = match.Value;
if (!string.IsNullOrEmpty(matchText))
{
position = matchText.Length;
//stwórzy linka użytkownika
Hyperlink h = CreateTagHyperLink(matchText, string.Format(tagLinkFormat, matchText.Substring(1)),
matchText, mainTextBlock);
//dołączam linka do wyświetlenia
mainTextBlock.Inlines.Add(h);
statusFragment = statusFragment.Substring(position);
}
}
}