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); } } }
/// <summary> /// tworzy początek wiadomości, który zaczyna się od loginu(loginów) użytkownika /// </summary> /// <param name="mainTextBlock"></param> /// <param name="s"></param> private static void CreateUsersBegining(StatusBindableTextBlock mainTextBlock, StatusViewModel s) { Hyperlink hypUserLogin = CreateUserHyperLink(s.UserLogin, string.Format(userLinkFormat, s.UserLogin), string.Format(userProfileFormat, s.UserLogin), mainTextBlock); //dodajemy link użytkownka mainTextBlock.Inlines.Add(hypUserLogin); //tworzymy link odbiorcy wiadomośći if ((s.StatusType == "DirectedMessage") || (s.StatusType == "PrivateMessage")) { string mark = (s.StatusType == "DirectedMessage") ? " > " : " >> "; //Run r = CreateRun(mark); mainTextBlock.Inlines.Add(mark); //tworzymy link użytkownika odbiorcy wiadomości Hyperlink hypRecipientLogin = CreateUserHyperLink(s.RecipientLogin, string.Format(userLinkFormat, s.RecipientLogin), string.Format(userProfileFormat, s.RecipientLogin), mainTextBlock); //dodajemy link użytkownka mainTextBlock.Inlines.Add(hypRecipientLogin); } //Run rr = CreateRun(": "); mainTextBlock.Inlines.Add(": "); }
private static Hyperlink CreateVideoHyperLink(string linkText, string address, string toolTip, StatusBindableTextBlock block) { return CreateHyperLink(linkText, address, toolTip, FontWeights.Normal, hyperlinkColor, StatusesCommands.ShowVideo); }
private static Hyperlink CreateUserHyperLink(string linkText, string address, string toolTip, StatusBindableTextBlock block) { return CreateHyperLink(linkText, address, toolTip, FontWeights.SemiBold, userColor, StatusesCommands.Navigate); }