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(""); } }
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); } }
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); }
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); }
public void Execute(object parameter) { ITweetable tweet = (ITweetable)parameter; DataTransfer.ReplyId = tweet.Id; DataTransfer.Text = GetReplied(tweet); Dependency.Resolve <INavigationService>().Navigate(Uris.WriteTweet); }
void ExtendedListBox_Link(object sender, LinkUnlinkEventArgs e) { ITweetable o = e.ContentPresenter.DataContext as ITweetable; if (o != null) { lock (viewportItemsLock) viewportItems[o] = e.ContentPresenter; } }
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; } }
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); }
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); }
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); } } }
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); }
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 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 ""; } }
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; }
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); }
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); }
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); }
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}; }
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 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; }
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; }
private static Tweet MapTwitterStatusToTweet(ITweetable status) { return(new Tweet { PostDate = status.CreatedDate, Message = status.Text }); }