public override void ProcessInStream(List<TOBEntityBase> inStreamList) { Regex regx = new Regex("https?://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?", RegexOptions.IgnoreCase); foreach (TOBEntityBase tobEB in inStreamList) { try { string msgText = ""; string screenName = ""; string profileImage = ""; if (tobEB.GetType() == typeof(Status)) { Status tempVar = (Status)tobEB; msgText = tempVar.Text; screenName = tempVar.UserProfile.ScreenName; profileImage = tempVar.UserProfile.ProfileImageUrl; } else if (tobEB is DirectMessage) { DirectMessage tempDM = (DirectMessage)tobEB; msgText = tempDM.Text; screenName = tempDM.UserProfile.ScreenName; profileImage = tempDM.UserProfile.ProfileImageUrl; } MatchCollection matches = regx.Matches(msgText); foreach (Match match in matches) { string imageURI = GetImageURI(match.Value); if (imageURI != null) { PicHelperClass item = new PicHelperClass() { User = screenName, OrigUri=new Uri(match.Value), ProfileImage= new Uri(profileImage) , Image = new Uri(imageURI), Text = msgText }; Action action = delegate() { if (CurrentControl == null || !CurrentControl.AddItem(item)) { CurrentControl = new PicHelperControl(); AddControlToPanel(CurrentControl); CurrentControl.AddItem(item); } }; Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, action); } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } } return; }
public override void ProcessSearchStream(List<Search> searchStream) { Regex regx = new Regex("https?://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?", RegexOptions.IgnoreCase); foreach (Search search in searchStream) { MatchCollection matchesSearch = regx.Matches(search.SearchText); foreach (Match match in matchesSearch) { string imageURI = GetImageURI(match.Value); if (imageURI != null) { PicHelperClass item = new PicHelperClass() { User = search.UserName, Image = new Uri(imageURI), Text = search.SearchText }; Action action = delegate() { if (CurrentControl == null || !CurrentControlSearch.AddItem(item)) { CurrentControlSearch = new PicHelperControl(); AddControlToPanel(CurrentControlSearch); CurrentControlSearch.AddItem(item); } }; Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, action); } } } }