Esempio n. 1
0
        public bool AddItem(PicHelperClass item)
        {
            if (Picture1.DataContext == null)
            {
                Picture1.DataContext = item;
                Picture1.Visibility = System.Windows.Visibility.Visible;
            }
            else if (Picture2.DataContext == null)
            {
                Picture2.DataContext = item;
                Picture2.Visibility = System.Windows.Visibility.Visible;
            }
            else
                return false;

            return true;
        }
Esempio n. 2
0
        public override void ProcessInStream(List<TOBEntityBase> inStreamList)
        {
            Regex regx = new Regex("https?://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&amp;\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?", 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;
        }
Esempio n. 3
0
        public override void ProcessSearchStream(List<Search> searchStream)
        {
            Regex regx = new Regex("https?://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&amp;\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?", 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);
                    }
                }
            }
        }