Example #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try {
                if (value is string)
                {
                    string s = (string)value;
                    if (s.Length == 0)
                    {
                        return(null);
                    }
                    return(IconCache.GetImage(s));
                }
                if (value is Uri)
                {
                    return(IconCache.GetImage((Uri)value));
                }
                if (value is User)
                {
                    User user = (User)value;
                    return(IconCache.GetImage(user.ID, user.ProfileImageUrl));
                }
            } catch {}

            return(null);
        }
Example #2
0
        public TwitterAccountManager()
        {
            _accounts   = new TwitterAccount[0];
            _restThread = new Thread(RestThread);
            _restThread.IsBackground = true;
            _restThread.Start();
            IconCache.Init(this);

            // defaults
            HomeIncludeMentions = true;
        }
		void Render ()
		{
			if (Owner == null) {
				Source = null;
				return;
			}
			Status s = Owner.DataContext as Status;
			if (s == null)
				return;
			if (s.RetweetedStatus != null)
				s = s.RetweetedStatus;
			Source = IconCache.GetImage (s.User.ID, s.User.ProfileImageUrl);
		}
		public void CreateTweetBody (string text, InlineCollection inlines)
		{
			Match m = TwitterStatusViewer.TweetRegex.Match (text);
			int last = 0;
			List<Hyperlink> images = null;
			while (m.Success) {
				inlines.Add (text.Substring (last, m.Index - last));
				if (m.Success) {
					Hyperlink link = CreateHyperlink (m.Value, m.Value, TwitterStatusViewer.LinkForegroundProperty, this.FontWeight, Hyperlink_Click);
					inlines.Add (link);

					foreach (IInlineImageUrlHandler handler in InlineImageSites) {
						string picurl = handler.Process (m.Value);
						if (picurl == null)
							continue;
						Hyperlink imgLink = new Hyperlink {Tag = m.Value};
						imgLink.Click += Hyperlink_Click;
						imgLink.Inlines.Add (new Image {
							Source = IconCache.CreateBitmapImageIgnoreColorProfile (new Uri (picurl)),
							Stretch = Stretch.Uniform,
							MaxWidth = 50,
							MaxHeight = 50
						});
						if (images == null) images = new List<Hyperlink> ();
						images.Add (imgLink);
						break;
					}
				}

				last = m.Index + m.Length;
				m = m.NextMatch ();
			}
			inlines.Add (text.Substring (last));

			if (images != null) {
				inlines.Add (Environment.NewLine);
				for (int i = 0; i < images.Count; i ++)
					inlines.Add (images[i]);
			}
		}