Esempio n. 1
0
        protected override void Render()
        {
            InlineCollection inlines = Inlines;

            inlines.Clear();

            TwitterStatusViewer v = Owner;

            if (v == null)
            {
                return;
            }
            Status s = v.DataContext as Status;

            if (s == null)
            {
                return;
            }
            Status s1 = s;

            if (s.RetweetedStatus != null)
            {
                s = s.RetweetedStatus;
            }

            v.CreateTweetBody(s.Text, inlines);
        }
Esempio n. 2
0
		protected override void Render ()
		{
			InlineCollection inlines = Inlines;
			while (inlines.Count > 1)
				inlines.Remove (inlines.LastInline);

			TwitterStatusViewer v = Owner;
			if (v == null) return;
			Status s = v.DataContext as Status;
			if (s == null) return;
			Status s1 = s;
			if (s.RetweetedStatus != null)
				s = s.RetweetedStatus;

			// 改行や連続する空白を削除
			string text = s.Text;
			StringBuilder sb = new StringBuilder (text.Length);
			int state = 0;
			for (int i = 0; i < text.Length; i ++) {
				char c = text[i];
				if (c == '\r' || c == '\n') continue;
				if (char.IsWhiteSpace (c)) {
					if (state == 1) continue;
					state = 1;
				} else {
					state = 0;
				}
				sb.Append (text[i]);
			}
			text = sb.ToString ();

			// Favoriteアイコン
			ToggleButton favBtn = v.CreateFavoriteButton (s);
			favBtn.Margin = new Thickness (0, 0, 3, 0);
			inlines.Add (favBtn);

			// 名前を追加
			RoutedEventHandler defLinkHandler = new RoutedEventHandler (v.Hyperlink_Click);
			DependencyProperty nameFg = TwitterStatusViewer.NameForegroundProperty;
			inlines.Add (v.CreateHyperlink (s.User.ScreenName, "/" + s.User.ScreenName, nameFg, FontWeights.Bold, defLinkHandler));
			inlines.Add (" ");

			// 本文を追加
			v.CreateTweetBody (text, inlines);

			// 返信情報を追加
			if (!string.IsNullOrEmpty (s.InReplyToScreenName)) {
				inlines.Add (v.CreateTextBlock (" in reply to ", FontWeights.Normal, nameFg));
				inlines.Add (v.CreateHyperlink ("@" + s.InReplyToScreenName, "/" + s.InReplyToScreenName + (s.InReplyToStatusId == 0 ? string.Empty : "/status/" + s.InReplyToStatusId.ToString ()), nameFg, FontWeights.Bold, defLinkHandler));
			}
			if (s != s1) {
				inlines.Add (v.CreateTextBlock (" RT by ", FontWeights.Normal, nameFg));
				inlines.Add (v.CreateHyperlink ("@" + s1.User.ScreenName, "/" + s1.User.ScreenName, nameFg, FontWeights.Bold, defLinkHandler));
			}

		}