Esempio n. 1
0
        private string getStringToCheck(ITweetable item)
        {
            if (item is LoadMoreTweetable)
            {
                return("");
            }

            switch (Type)
            {
            case FilterType.Source:
                if (item is TwitterStatus)
                {
                    return((item as TwitterStatus).Source.ToLowerInvariant());
                }
                else
                {
                    return("");
                }

            case FilterType.Text:
                return(item.Text.ToLowerInvariant());

            case FilterType.User:
                return(item.Author.ScreenName.ToLowerInvariant());

            default:
                return("");
            }
        }
Esempio n. 2
0
        public bool Evaluate(ITweetable item)
        {
            if (Filter == null)
            {
                Filter = "";
            }

            if (DateTime.Now > IsValidUntil)
            {
                return(false);
            }

            if (item == null)
            {
                return(false);
            }

            string whatToCheck = getStringToCheck(item);

            bool result = whatToCheck.Contains(Filter.ToLowerInvariant());

            if (Inclusion == IncludeOrExclude.Exclude)
            {
                return(result);
            }
            else
            {
                return(!result);
            }
        }
Esempio n. 3
0
        public bool Evaluate(object item)
        {
            ITweetable tweet = item as ITweetable;

            if (item == null)
            {
                return(false);
            }

            foreach (var filter in _predicates)
            {
                if (filter.Evaluate(tweet) == true)
                {
                    return(true);
                }
            }

            if (Global != null)
            {
                if (Global.Evaluate(item) == true)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        public object Convert(object value, Type targeType, object parameter, CultureInfo culture)
        {
            if (!(value is ITweetable))
            {
                return("");
            }

            ITweetable Tweet = value as ITweetable;

            if (Tweet is TwitterStatus)
            {
                TwitterStatus Status = Tweet as TwitterStatus;
                if (Status.RetweetedStatus != null)
                {
                    Tweet = Status.RetweetedStatus;
                }
            }

            string TweetText  = Tweet.Text;
            string ReturnText = "";
            string PreviousText;
            int    i = 0;

            foreach (var Entity in Tweet.Entities)
            {
                if (Entity.StartIndex > i)
                {
                    PreviousText = TweetText.Substring(i, Entity.StartIndex - i);
                    ReturnText  += HttpUtility.HtmlDecode(PreviousText);
                }

                i = Entity.EndIndex;

                switch (Entity.EntityType)
                {
                case TwitterEntityType.HashTag:
                    ReturnText += "#" + ((TwitterHashTag)Entity).Text;
                    break;

                case TwitterEntityType.Mention:
                    ReturnText += "@" + ((TwitterMention)Entity).ScreenName;
                    break;

                case TwitterEntityType.Url:
                    ReturnText += TrimUrl(((TwitterUrl)Entity).ExpandedValue);
                    break;

                case TwitterEntityType.Media:
                    ReturnText += ((TwitterMedia)Entity).DisplayUrl;
                    break;
                }
            }

            if (i < TweetText.Length)
            {
                ReturnText += HttpUtility.HtmlDecode(TweetText.Substring(i));
            }

            return(ReturnText);
        }
Esempio n. 5
0
        public void Execute(object parameter)
        {
            ITweetable tweet = (ITweetable)parameter;

            DataTransfer.ReplyId = tweet.Id;
            DataTransfer.Text    = GetReplied(tweet);

            Dependency.Resolve <INavigationService>().Navigate(Uris.WriteTweet);
        }
Esempio n. 6
0
        void ExtendedListBox_Link(object sender, LinkUnlinkEventArgs e)
        {
            ITweetable o = e.ContentPresenter.DataContext as ITweetable;

            if (o != null)
            {
                lock (viewportItemsLock)
                    viewportItems[o] = e.ContentPresenter;
            }
        }
Esempio n. 7
0
        private void OnItemRealized(object sender, ItemRealizationEventArgs e)
        {
            viewportChanged = true;
            ITweetable o = e.Container.DataContext as ITweetable;

            if (o != null)
            {
                lock (viewportItemsLock)
                    viewportItems[o] = e.Container;
            }
        }
Esempio n. 8
0
        public void Execute(object parameter)
        {
            ITweetable tweet = parameter as ITweetable;

            if (tweet == null)
            {
                return;
            }

            ITweeter author = tweet.Author;

            FilterManager.SetupMute(FilterType.User, author.ScreenName);
            Dependency.Resolve <IMessageService>().ShowLightNotification(Resources.Filtered);
        }
Esempio n. 9
0
        protected void ReceiveTweetable(IEnumerable <ITweetable> statuses, TwitterResponse response, TwitterResource Resource)
        {
            WriteMemUsage("Received tweet for column.");
            if (statuses == null || !statuses.Any() || response.StatusCode != System.Net.HttpStatusCode.OK)
            {
                WriteMemUsage("Exit with error");
                return;
            }

            string     tileString = Uri.EscapeDataString(Resource.String);
            ITweetable tweet      = statuses.FirstOrDefault();

            TileManager.SetColumnTweet(tileString, tweet.CleanText, tweet.AuthorName);
        }
Esempio n. 10
0
        private void OnItemUnrealized(object sender, ItemRealizationEventArgs e)
        {
            viewportChanged = true;

            if (e.ItemKind == LongListSelectorItemKind.Item)
            {
                ITweetable o = e.Container.DataContext as ITweetable;
                if (o != null)
                {
                    lock (viewportItemsLock)
                        viewportItems.Remove(o);
                }
            }
        }
Esempio n. 11
0
        public static string GetReplied(ITweetable tweet)
        {
            string textReplied = "";

            textReplied = "@" + tweet.Author.ScreenName + " ";
            foreach (string user in StringManipulator.GetUserNames(tweet.Text))
            {
                if (DataTransfer.CurrentAccount != null && user != "@" + DataTransfer.CurrentAccount.ScreenName)
                {
                    textReplied += user + " ";
                }
            }

            return(textReplied);
        }
Esempio n. 12
0
        private string TweetToText(ITweetable tweet)
        {
            string who, when, text;

            if (tweet is TwitterStatus)
            {
                who = String.Format(Resources.NewMention, tweet.AuthorName);
            }
            else
            {
                who = String.Format(Resources.NewMessage, tweet.AuthorName);
            }

            when = new RelativeDateTimeConverter().Convert(tweet.CreatedDate, null, null, null) as string;

            text = tweet.CleanText;

            return(String.Format("{0}, {1} : {2}", who, when, text));
        }
Esempio n. 13
0
        private string getStringToCheck(ITweetable item)
        {
            if (item is LoadMoreTweetable)
                return "";

            switch (Type)
            {
                case FilterType.Source:
                    if (item is TwitterStatus)
                        return (item as TwitterStatus).Source.ToLowerInvariant();
                    else
                        return "";
                case FilterType.Text:
                    return item.Text.ToLowerInvariant();
                case FilterType.User:
                    return item.Author.ScreenName.ToLowerInvariant();
                default:
                    return "";
            }
        }
Esempio n. 14
0
        public bool Evaluate(ITweetable item)
        {
            if (Filter == null)
                Filter = "";

            if (DateTime.Now > IsValidUntil)
                return false;

            if (item == null)
                return false;

            string whatToCheck = getStringToCheck(item);

            bool result = whatToCheck.Contains(Filter.ToLowerInvariant());

            if (Inclusion == IncludeOrExclude.Exclude)
                return result;
            else
                return !result;
        }
Esempio n. 15
0
        private bool IsAtBottom()
        {
            if (listbox.ItemsSource.Count == 0)
            {
                return(true);
            }

            ContentPresenter lastContainer;
            ITweetable       lastItem = listbox.ItemsSource[listbox.ItemsSource.Count - 1] as ITweetable;

            if (listbox.ViewportItems.TryGetValue(lastItem, out lastContainer))
            {
                var diff = lastContainer.GetRelativePosition(listbox);
                if (diff.Y <= listbox.ActualHeight - lastContainer.ActualHeight + 2)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 16
0
        private bool IsAtTop()
        {
            if (listbox.ItemsSource.Count == 0)
            {
                return(true);
            }

            ContentPresenter firstContainer;
            ITweetable       firstItem = listbox.ItemsSource[0] as ITweetable;

            if (listbox.ViewportItems.TryGetValue(firstItem, out firstContainer))
            {
                var diff = listbox.GetRelativePosition(firstContainer);
                if (diff.Y < 2)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 17
0
        public void Execute(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            ITweetable tweet = (ITweetable)parameter;

            DataTransfer.Text = "@" + tweet.Author.ScreenName + " ";
            if (parameter is TwitterStatus)
            {
                DataTransfer.ReplyId    = tweet.Id;
                DataTransfer.ReplyingDM = false;
            }
            else if (parameter is TwitterDirectMessage)
            {
                DataTransfer.DMDestinationId = (parameter as TwitterDirectMessage).SenderId;
                DataTransfer.ReplyingDM      = true;
            }

            Dependency.Resolve <INavigationService>().Navigate(Uris.WriteTweet);
        }
Esempio n. 18
0
        private string TweetToText(ITweetable tweet)
        {
            string who, when, text;

            if (tweet is TwitterStatus)
                who = String.Format(Resources.NewMention, tweet.AuthorName);
            else
                who = String.Format(Resources.NewMessage, tweet.AuthorName);

            when = new RelativeDateTimeConverter().Convert(tweet.CreatedDate, null, null, null) as string;

            text = tweet.CleanText;

            return String.Format("{0}, {1} : {2}", who, when, text);
        }
 private static Tweet MapTwitterStatusToTweet(ITweetable status)
 {
     return new Tweet {PostDate = status.CreatedDate, Message = status.Text};
 }
Esempio n. 20
0
        private void CreateText(ITweetable Status)
        {
            if (Status == null)
            {
                return;
            }

            var paragraph = new Paragraph();
            var runs      = new List <Inline>();

            Text.Blocks.Clear();

            string TweetText = Status.Text;
            string PreviousText;
            int    i = 0;

            if (viewModel.Tweet.Entities != null)
            {
                foreach (var Entity in viewModel.Tweet.Entities)
                {
                    if (Entity.StartIndex > i)
                    {
                        PreviousText = TweetText.Substring(i, Entity.StartIndex - i);
                        runs.Add(new Run {
                            Text = HttpUtility.HtmlDecode(PreviousText)
                        });
                    }

                    i = Entity.EndIndex;

                    switch (Entity.EntityType)
                    {
                    case TwitterEntityType.HashTag:
                        runs.Add(CreateHashtagLink((TwitterHashTag)Entity));
                        break;

                    case TwitterEntityType.Mention:
                        runs.Add(CreateMentionLink((TwitterMention)Entity));
                        break;

                    case TwitterEntityType.Url:
                        runs.Add(CreateUrlLink((TwitterUrl)Entity));
                        break;

                    case TwitterEntityType.Media:
                        runs.Add(CreateMediaLink((TwitterMedia)Entity));
                        break;
                    }
                }
            }

            if (i < TweetText.Length)
            {
                runs.Add(new Run
                {
                    Text = HttpUtility.HtmlDecode(TweetText.Substring(i))
                });
            }

            foreach (var run in runs)
            {
                paragraph.Inlines.Add(run);
            }

            Text.Blocks.Add(paragraph);

            Text.UpdateLayout();
        }
Esempio n. 21
0
        public static string GetReplied(ITweetable tweet)
        {
            string textReplied = "";
            textReplied = "@" + tweet.Author.ScreenName + " ";
            foreach (string user in StringManipulator.GetUserNames(tweet.Text))
                if (DataTransfer.CurrentAccount != null && user != "@" + DataTransfer.CurrentAccount.ScreenName)
                    textReplied += user + " ";

            return textReplied;
        }
Esempio n. 22
0
        private void CreateText(ITweetable Status)
        {
            if (Status == null)
                return;

            var paragraph = new Paragraph();
            var runs = new List<Inline>();

            Text.Blocks.Clear();

            string TweetText = Status.Text;
            string PreviousText;
            int i = 0;

            if (viewModel.Tweet.Entities != null)
            {
                foreach (var Entity in viewModel.Tweet.Entities)
                {
                    if (Entity.StartIndex > i)
                    {
                        PreviousText = TweetText.Substring(i, Entity.StartIndex - i);
                        runs.Add(new Run { Text = HttpUtility.HtmlDecode(PreviousText) });
                    }

                    i = Entity.EndIndex;

                    switch (Entity.EntityType)
                    {
                        case TwitterEntityType.HashTag:
                            runs.Add(CreateHashtagLink((TwitterHashTag)Entity));
                            break;

                        case TwitterEntityType.Mention:
                            runs.Add(CreateMentionLink((TwitterMention)Entity));
                            break;

                        case TwitterEntityType.Url:
                            runs.Add(CreateUrlLink((TwitterUrl)Entity));
                            break;
                        case TwitterEntityType.Media:
                            runs.Add(CreateMediaLink((TwitterMedia)Entity));
                            break;
                    }
                }
            }

            if (i < TweetText.Length)
                runs.Add(new Run
                {
                    Text = HttpUtility.HtmlDecode(TweetText.Substring(i))
                });

            foreach (var run in runs)
                paragraph.Inlines.Add(run);

            Text.Blocks.Add(paragraph);

            Text.UpdateLayout();
        }
 public Client(ITweetable tweet)
 {
     this.Tweet = tweet;
 }
Esempio n. 24
0
 private static Tweet MapTwitterStatusToTweet(ITweetable status)
 {
     return(new Tweet {
         PostDate = status.CreatedDate, Message = status.Text
     });
 }