public GeoViewModel(MetroTwitStatusBase Tweet) { this.ShowAnimation = true; this.LinkCommand = new RelayCommand<string>(new Action<string>(CommonCommands.OpenLink)); Coordinate coordinate = Tweet.Coordinates != null ? Tweet.Coordinates.Coordinate[0] : Tweet.Geo.BoundingBox.Coordinates[0]; if (coordinate != null) { Task task = new Task((Action) (() => this.GeoLookup(coordinate))); task.ContinueWith((Action<Task>) (t => CommonCommands.CheckTaskExceptions(t))); task.Start(); object resource = Application.Current.FindResource((object) "ModernColorFeature"); string PinColour = resource == null ? "blue" : "0x" + resource.ToString().Remove(0, 3); this.GeoImageURI = CoreServices.Instance.CurrentMapService.StaticMapURL(coordinate.Latitude, coordinate.Longitude, 320, 320, PinColour); GeoViewModel geoViewModel = this; double num = coordinate.Latitude; string str1 = num.ToString((IFormatProvider) CultureInfo.InvariantCulture.NumberFormat); string str2 = ", "; num = coordinate.Longitude; string str3 = num.ToString((IFormatProvider) CultureInfo.InvariantCulture.NumberFormat); string str4 = str1 + str2 + str3; geoViewModel.GeoPlaceText = str4; this.LiveMapURL = CoreServices.Instance.CurrentMapService.LiveMapURL(coordinate.Latitude, coordinate.Longitude); } this.ShowAnimation = false; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { MetroTwitStatusBase metroTwitStatusBase = new MetroTwitStatusBase(); if (value != null) { switch ((value as TwitterStreamEventExtended).EventType) { case TwitterSteamEvent.Favorite: return (object) (Application.Current.FindResource((object) "PathFav") as Geometry); case TwitterSteamEvent.Unfavorite: return (object) (Application.Current.FindResource((object) "PathUnfav") as Geometry); case TwitterSteamEvent.Follow: return (object) (Application.Current.FindResource((object) "PathFollowsUser") as Geometry); case TwitterSteamEvent.ListMemberAdded: return (object) (Application.Current.FindResource((object) "PathListAdd") as Geometry); case TwitterSteamEvent.ListMemberRemoved: return (object) (Application.Current.FindResource((object) "PathListRemove") as Geometry); } } return (object) (Application.Current.FindResource((object) "PathPin") as Geometry); }
public static void Retweet(MetroTwitStatusBase orig) { System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => { if (!orig.User.IsProtected && orig.AdUrls == null) Messenger.Default.Send<RetweetMessage>(new RetweetMessage((Action<MessageBoxResult, Decimal>)(async (answer, account) => { if (answer == MessageBoxResult.Yes) { Decimal ID = orig.IsRetweet ? orig.OriginalID : orig.ID; TwitterResponse<Status> r = await Tweets.RetweetAsync(App.AppState.Accounts[account].Tokens, ID, MetroTwitTwitterizer.Options); if (r.Result != RequestResult.Success) await System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send<DialogMessage>(new DialogMessage(string.Empty, (Action<MessageBoxResult>)(o => { })), (object)DialogType.RetweetError)), new object[0]); } if (answer == MessageBoxResult.No) Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)orig), (object)CommonCommands.MultiAccountifyToken((System.Enum)ViewModelMessages.Retweet, account)); })), (object)DialogType.RetweetDialog); else Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)orig), (object)CommonCommands.MultiAccountifyToken((System.Enum)ViewModelMessages.Retweet, orig.TwitterAccountID)); }), DispatcherPriority.Background, new object[0]); }
private void RemoveTweet(MetroTwitStatusBase tweet) { lock (this._tweetsLock) this.Tweets.Remove(tweet); }
private void AddTweet(MetroTwitStatusBase tweet) { lock (this._tweetsLock) this.Tweets.Add(tweet); }
public TweetListViewModel(Guid UniqueID, TweetListType tweetListType, Decimal TwitterAccountID, MetroTwitColumn Settings, string columntitle = null, string searchterm = null, string searchName = null, Decimal? existingSearchID = null, bool dontloadtweets = false, MetroTwitStatusBase originaltweet = null, Decimal InitialLastID = 0M) { TweetListViewModel tweetListViewModel = this; this.Settings = Settings; this.UniqueTweetListID = UniqueID != Guid.Empty ? UniqueID : Guid.NewGuid(); this.RefreshCommand = new RelayCommand(new Action(this.RefreshExecute)); this.FlushCommand = new RelayCommand<bool>(new Action<bool>(this.Flush)); this.RemoveColumnCommand = new RelayCommand(new Action(this.RemoveColumn)); this.ContentLinkCommand = new RelayCommand<string>(new Action<string>(this.ExecuteLink)); this.LinkCommand = new RelayCommand(new Action(this.OpenLink)); this.ProfileLinkCommand = new RelayCommand(new Action(this.ProfileLink)); this.MarkasReadCommand = new RelayCommand(new Action(this.MarkasRead)); this.FollowCommand = new RelayCommand(new Action(this.Follow)); this.BlockCommand = new RelayCommand(new Action(this.Block)); this.ReportSpamCommand = new RelayCommand(new Action(this.ReportSpam)); this.MentionCommand = new RelayCommand(new Action(this.Mention)); this.DirectMessageCommand = new RelayCommand(new Action(this.DirectMessage)); this.CloseAdCommand = new RelayCommand(new Action(this.CloseAd)); this.ColumnSettingsCommand = new RelayCommand(new Action(this.ColumnSettings)); this.UnpauseColumnCommand = new RelayCommand(new Action(this.UnpauseColumn)); this.SaveRemoveSearchCommand = new RelayCommand(new Action(this.SaveRemoveSearch)); this.NoRetweetsCommand = new RelayCommand(new Action(this.NoRetweets)); this.AddToListCommand = new RelayCommand(new Action(this.AddToList)); this.ResetColumnWidthCommand = new RelayCommand(new Action(this.ResetColumnWidth)); this.EnableNotifications = true; this.TweetType = tweetListType; this.TwitterAccountID = TwitterAccountID; this.IsPaused = false; this.ShowLoading = true; this.NameVisible = true; this.TweetPanelVisible = true; this.TitleBarVisible = true; this.FollowButtonIsEnabled = true; this.DisplayType = DisplayType.Tweets; this.ResetWidthVisibility = this.Settings.ColumnIsSetWidth; this.hideLoadLock = new object(); this.Tweets = new SortableObservableCollection<MetroTwitStatusBase>(new List<MetroTwitStatusBase>()); BindingOperations.EnableCollectionSynchronization((IEnumerable)this.Tweets, this._tweetsLock); switch (tweetListType) { case TweetListType.FriendsTimeline: this.TweetListName = "friends"; break; case TweetListType.DirectMessages: this.TweetListName = "direct messages"; break; case TweetListType.Search: this.SearchID = existingSearchID; if (searchterm == null) return; this.SearchName = searchName; this.TwitterTerm = searchterm.Trim().Replace("\n", ""); this.TweetListName = !string.IsNullOrEmpty(searchName) ? searchName : this.TwitterTerm; this.SearchDetailsVisible = true; this.SetSaveRemoveSearchButton(); break; case TweetListType.UserTimeline: if (searchterm == null) return; this.TwitterTerm = searchterm.Trim().Replace("\n", "").Replace("@", ""); this.TweetListName = "@" + this.TwitterTerm; if (!dontloadtweets) { this.ShowProfileLoading = true; this.ProfileDetailsVisible = true; if (App.AppState.Accounts[this.TwitterAccountID].IsSignedIn) Users.ShowAsync(App.AppState.Accounts[this.TwitterAccountID].Tokens, this.TwitterTerm, MetroTwitTwitterizer.Options).ContinueWith(new Action<Task<TwitterResponse<User>>>(this.UserDetails)); break; } else break; case TweetListType.List: if (searchterm == null) return; this.TwitterTerm = searchterm.Trim(); this.TweetListName = this.TwitterTerm; break; case TweetListType.MentionsMyTweetsRetweeted: SettingsData settingsData = SettingsData.Instance; this.TweetListName = "mentions"; settingsData = (SettingsData)null; break; case TweetListType.MyTweets: this.TweetListName = "my tweets"; break; case TweetListType.Favourites: this.TweetListName = "favourites"; break; case TweetListType.Conversation: this.TweetListName = "tweet conversation"; if (originaltweet != null) { this.TwitterTerm = originaltweet.InReplyToScreenName; originaltweet.TwitterAccountID = this.TwitterAccountID; originaltweet.TweetType = TweetListType.Conversation; originaltweet.ReplyToVisibility = Visibility.Collapsed; this.AddTweet(originaltweet); ++this.taskCount; this.ShowContentPanel(); break; } else break; case TweetListType.RetweetUsers: this.TweetListName = "retweeted by"; this.TwitterTerm = searchterm; break; } if (!string.IsNullOrEmpty(columntitle)) this.TweetListName = columntitle; if (!dontloadtweets) { Messenger.Default.Register<GenericMessage<object>>((object)this, (object)(((object)ViewModelMessages.RestUpdate).ToString() + this.UniqueTweetListID.ToString()), new Action<GenericMessage<object>>(this.RestUpdate)); ++this.taskCount; Task.Run((Action)(() => TwitterREST.TwitterRest(tweetListViewModel.UniqueTweetListID, tweetListType, tweetListViewModel.TwitterAccountID, tweetListViewModel.TweetType != TweetListType.Conversation ? RefreshTypes.Normal : RefreshTypes.ForeverScroll, new Action(tweetListViewModel.ShowContentPanel), tweetListViewModel.TwitterTerm, originaltweet != null ? originaltweet.InReplyTo : new Decimal(0), InitialLastID, new Decimal(0), tweetListViewModel.ListRetweets))); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.DeleteTweet), new Action<GenericMessage<object>>(this.DeleteTweet)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.DeleteUserTweets), new Action<GenericMessage<object>>(this.DeleteUserTweets)); Messenger.Default.Register<GenericMessage<KeyValuePair<Decimal, bool>>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.Blocked), new Action<GenericMessage<KeyValuePair<Decimal, bool>>>(this.Blocked)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)ViewModelMessages.EnableReplyOptions, new Action<GenericMessage<object>>(this.EnableReplyOptions)); if (tweetListType != TweetListType.DirectMessages) { if (tweetListType == TweetListType.FriendsTimeline || tweetListType == TweetListType.MyTweets || tweetListType == TweetListType.MentionsMyTweetsRetweeted || tweetListType == TweetListType.Conversation) { Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.StreamingStatusReceived), new Action<GenericMessage<object>>(this.StreamingUpdate)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.StreamingStatusDeleted), new Action<GenericMessage<object>>(this.StreamingDelete)); } Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.RemoveFavouriteTweet), new Action<GenericMessage<object>>(this.RemoveFavouriteTweet)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.FavouriteTweet), new Action<GenericMessage<object>>(this.FavouriteTweet)); } else { Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.StreamingDirectMessage), new Action<GenericMessage<object>>(this.StreamingDMUpdate)); Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((Enum)ViewModelMessages.StreamingDirectMessageDeleted), new Action<GenericMessage<object>>(this.StreamingDMDelete)); } } if (this.DataContextInitialised != null) this.DataContextInitialised((object)this, EventArgs.Empty); }
private static void PrepareTweetDocument(TextBlock textBlock, MetroTwitStatusBase tweet, bool Notification = false) { if (DesignerProperties.GetIsInDesignMode((DependencyObject) textBlock)) return; try { if (textBlock != null && textBlock.Inlines != null && textBlock.Inlines.Count > 0) textBlock.Inlines.Clear(); } catch { foreach (Inline inline in Enumerable.ToArray<Inline>((IEnumerable<Inline>) textBlock.Inlines)) textBlock.Inlines.Remove(inline); } if (Notification) { Span span1 = new Span(); span1.FontWeight = FontWeights.SemiBold; Span span2 = span1; Hyperlink hyperlink = new Hyperlink((Inline) new Run("@" + tweet.User.ScreenName)); hyperlink.SetResourceReference(TextElement.ForegroundProperty, (object)"ModernTextLighterBrush"); hyperlink.SetBinding(Hyperlink.CommandProperty, (BindingBase) new Binding("UserProfileCommand") { Mode = BindingMode.OneWay }); hyperlink.SetBinding(Hyperlink.CommandParameterProperty, (BindingBase) new Binding("CurrentTweet.User.ScreenName") { Mode = BindingMode.OneWay }); ((TextElementCollection<Inline>) span2.Inlines).Add((Inline) hyperlink); ((TextElementCollection<Inline>) span2.Inlines).Add((Inline) new Run() { Text = ": " }); ((TextElementCollection<Inline>) textBlock.Inlines).Add((Inline) span2); } if (tweet != null && tweet.Entities != null && tweet.Entities.Count > 0) { try { int[] numArray = StringInfo.ParseCombiningCharacters(tweet.RawText); IOrderedEnumerable<Entity> orderedEnumerable = Enumerable.OrderBy<Entity, int>((IEnumerable<Entity>) tweet.Entities, (Func<Entity, int>) (x => x.StartIndex)); int num1 = 0; foreach (Entity entity in (IEnumerable<Entity>) orderedEnumerable) { int num2 = 0; if (numArray.Length < tweet.RawText.Length && entity.StartIndex < numArray.Length) num2 = numArray[entity.StartIndex] - entity.StartIndex; int num3 = entity.StartIndex + num2; int num4 = entity.EndIndex + num2; int startIndex1 = num1; if (num3 > startIndex1 && startIndex1 < numArray.Length && startIndex1 + (num3 - startIndex1) < numArray.Length) { string input = WebUtility.HtmlDecode(tweet.RawText.Substring(startIndex1, num3 - startIndex1)); if (!string.IsNullOrEmpty(input)) { Run run = new Run(Regex.Replace(input, "\n{2,}|(\r\n){2,}", "\n\n")); ((TextElementCollection<Inline>) textBlock.Inlines).Add((Inline) run); } } if (entity is MentionEntity) { MentionEntity mentionEntity = entity as MentionEntity; if (!string.IsNullOrEmpty(mentionEntity.ScreenName)) { Hyperlink hyperlink = new Hyperlink((Inline) new TagMentionLinkRun("@" + mentionEntity.ScreenName)) { CommandParameter = (object) ("@" + mentionEntity.ScreenName) }; hyperlink.SetResourceReference(TextElement.ForegroundProperty, (object) "HyperlinkUsername"); hyperlink.SetBinding(Hyperlink.CommandProperty, (BindingBase) new Binding("UserProfileCommand") { Mode = BindingMode.OneTime }); ((TextElementCollection<Inline>) textBlock.Inlines).Add((Inline) hyperlink); hyperlink.ContextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); menuItem1.Header = (object) "Filter tweets from this user"; menuItem1.CommandParameter = hyperlink.CommandParameter; MenuItem menuItem2 = menuItem1; menuItem2.SetBinding(MenuItem.CommandProperty, (BindingBase) new Binding("FilterCommand") { Mode = BindingMode.OneTime }); hyperlink.ContextMenu.Items.Add((object) menuItem2); } } else if (entity is HashTagEntity) { HashTagEntity hashTagEntity = entity as HashTagEntity; if (!string.IsNullOrEmpty(hashTagEntity.Text)) { Hyperlink hyperlink = new Hyperlink((Inline) new TagMentionLinkRun("#" + hashTagEntity.Text)) { CommandParameter = (object) ("#" + hashTagEntity.Text) }; hyperlink.SetResourceReference(TextElement.ForegroundProperty, (object) "HyperlinkHashtag"); hyperlink.SetBinding(Hyperlink.CommandProperty, (BindingBase) new Binding("TagsCommand") { Mode = BindingMode.OneTime }); ((TextElementCollection<Inline>) textBlock.Inlines).Add((Inline) hyperlink); hyperlink.ContextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); menuItem1.Header = (object) "Filter tweets that contain this hashtag"; menuItem1.CommandParameter = hyperlink.CommandParameter; MenuItem menuItem2 = menuItem1; menuItem2.SetBinding(MenuItem.CommandProperty, (BindingBase) new Binding("FilterCommand") { Mode = BindingMode.OneTime }); hyperlink.ContextMenu.Items.Add((object) menuItem2); } } else if (entity is UrlEntity) { UrlEntity url = entity as UrlEntity; if (!string.IsNullOrEmpty(url.Url)) { if (tweet.AdUrls != null && !string.IsNullOrEmpty(tweet.AdUrls.click_url)) url.ExpandedUrl = tweet.AdUrls.click_url; string str = string.IsNullOrEmpty(url.DisplayUrl) || tweet.AdUrls != null ? url.Url : (url.DisplayUrl.Length > 50 ? url.DisplayUrl.Substring(0, 50) + "..." : url.DisplayUrl); if (tweet.AdUrls != null & !string.IsNullOrEmpty(url.DisplayUrl)) str = url.DisplayUrl; if (url.DisplayUrl == null && tweet.AdUrls == null) { try { MatchCollection matchCollection = RegularExpressions.VALID_URL.Matches(url.Url); if (matchCollection.Count == 0 || matchCollection.Count > 0 && !matchCollection[0].Groups[4].Success) url.Url = "http://" + url.Url; } catch { } } if (tweet.AdUrls != null) { if (string.IsNullOrEmpty(url.DisplayUrl)) url.DisplayUrl = url.Url; url.Url = url.ExpandedUrl; } Hyperlink hyperlink = new Hyperlink((Inline) new TagMentionLinkRun(WebUtility.HtmlDecode(str))) { CommandParameter = (object) url }; hyperlink.SetResourceReference(TextElement.ForegroundProperty, (object) "HyperlinkURL"); hyperlink.SetBinding(Hyperlink.CommandProperty, (BindingBase) new Binding(Notification ? "LinkCommand" : "ContentLinkCommand") { Mode = BindingMode.OneTime }); hyperlink.ToolTip = (object) url.ExpandedUrl; hyperlink.ContextMenu = new ContextMenu(); MenuItem menuItem1 = new MenuItem(); menuItem1.Header = (object) "Copy URL"; menuItem1.CommandParameter = (object) url; MenuItem menuItem2 = menuItem1; menuItem2.SetBinding(MenuItem.CommandProperty, (BindingBase) new Binding("CopyUrlCommand") { Mode = BindingMode.OneTime }); hyperlink.ContextMenu.Items.Add((object) menuItem2); hyperlink.PreviewMouseDown += (MouseButtonEventHandler) ((clickSender, clickArgs) => Application.Current.Dispatcher.BeginInvoke((Action) (() => { string local_0 = url.Url; if (clickArgs.MiddleButton == MouseButtonState.Pressed || Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { App.LastURLClickMousePosition = new Point?(); CommonCommands.OpenLink(local_0); clickArgs.Handled = true; } else App.LastURLClickMousePosition = new Point?(Application.Current.MainWindow.PointToScreen(Mouse.GetPosition((IInputElement) Application.Current.MainWindow))); }), new object[0])); ((TextElementCollection<Inline>) textBlock.Inlines).Add((Inline) hyperlink); } } num1 = num4; int startIndex2 = num4; if (Enumerable.Count<Entity>((IEnumerable<Entity>) orderedEnumerable) > 0 && Enumerable.Last<Entity>((IEnumerable<Entity>) orderedEnumerable) == entity && startIndex2 < numArray.Length) { string text = WebUtility.HtmlDecode(tweet.RawText.Substring(startIndex2)); if (!string.IsNullOrEmpty(text)) { Run run = new Run(text); ((TextElementCollection<Inline>) textBlock.Inlines).Add((Inline) run); } } } } catch { ((TextElementCollection<Inline>) textBlock.Inlines).Add((Inline) new Run(Regex.Replace(WebUtility.HtmlDecode(tweet.RawText), "\n{2,}|(\r\n){2,}", "\n\n"))); } } else ((TextElementCollection<Inline>) textBlock.Inlines).Add((Inline) new Run(Regex.Replace(WebUtility.HtmlDecode(tweet.RawText), "\n{2,}|(\r\n){2,}", "\n\n"))); }
private void ReplyAll(GenericMessage<object> o) { if (this.sendingTweetInProgress) return; if (this.Status == null) { this.Status = o.Content as MetroTwitStatusBase; this.ReplyToID = this.Status.ID; this.UserName = this.Status.User.ScreenName; this.newTweetType = TwitViewModel.NewTweetType.Reply; } string str = o.Content as MetroTwitStatusBase == this.Status ? this.SetupReplyAll(this.Status, this.UserName, this.Status.IsRetweet ? this.Status.RetweetUser.ScreenName : string.Empty) : this.SetupReplyAll(o.Content as MetroTwitStatusBase, (o.Content as MetroTwitStatusBase).User.ScreenName, (o.Content as MetroTwitStatusBase).IsRetweet ? (o.Content as MetroTwitStatusBase).RetweetUser.ScreenName : string.Empty); App.AppState.SwitchToAccount(this.TwitterAccountID); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText)); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)str), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.SelectTweetText)); }
public void ShowAd(MetroTwitStatusBase Ad) { this.Ad = (MetroTwitStatusBase)null; this.ShowingAd = true; this.Ad = Ad; }
private bool FilteringRemoveTweet(MetroTwitStatusBase tweet, List<string> filter) { using (List<string>.Enumerator enumerator = filter.GetEnumerator()) { while (enumerator.MoveNext()) { Func<UrlEntity, bool> predicate = null; string f = enumerator.Current; if (f.StartsWith(":") && tweet.Source.Contains(f.Replace(":", ""), StringComparison.OrdinalIgnoreCase)) { return true; } if (f.StartsWith("@")) { string str = string.Empty; string str2 = string.Empty; if (f.Contains(":")) { string[] strArray = f.Split(new char[] { ':' }); str = strArray[0]; str2 = strArray[1]; } else { str = f; } if ((tweet.User.ScreenName.ToLower() == str.Replace("@", "").ToLower()) || ((tweet.RetweetUser != null) && (tweet.RetweetUser.ScreenName.ToLower() == str.Replace("@", "").ToLower()))) { if (str2 == string.Empty) { return true; } if (tweet.Source.Contains(str2.Replace(":", ""), StringComparison.OrdinalIgnoreCase)) { return true; } } } if (!f.StartsWith("@") && !f.StartsWith(":")) { if (tweet.Text.Contains(f, StringComparison.OrdinalIgnoreCase)) { return true; } if (tweet.Entities != null) { if (predicate == null) { predicate = en => (!string.IsNullOrEmpty(en.DisplayUrl) && en.DisplayUrl.Contains(f)) || (string.IsNullOrEmpty(en.DisplayUrl) && en.Url.Contains(f)); } if (tweet.Entities.OfType<UrlEntity>().Cast<UrlEntity>().Where<UrlEntity>(predicate).Count<UrlEntity>() > 0) { return true; } } } } } return false; }
public static void ShowConversation(MetroTwitStatusBase orig) { System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)orig), (object)CommonCommands.MultiAccountifyToken((System.Enum)ViewModelMessages.ShowConversation, orig.TwitterAccountID))), DispatcherPriority.Background, new object[0]); }
public static void ShowGeo(MetroTwitStatusBase orig) { System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)orig), (object)DialogType.GeoDialog)), DispatcherPriority.Background, new object[0]); }
private void TweetTextCounter() { int count = 0; int num1 = 0; int num2 = this.actualtweetText.EndsWith(Environment.NewLine) ? Environment.NewLine.Length : 0; Match match1 = TwitViewModel.DM_EXPRESSION.Match(this.actualtweetText); if (match1.Success) { if (this.newTweetType != TwitViewModel.NewTweetType.DirectMessage) { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => this.ResetNewTweet(false))); this.newTweetType = TwitViewModel.NewTweetType.DirectMessage; this.DMCheckUserFollow(this.actualtweetText.Split(new char[1] { ' ' })[1]); count = this.actualtweetText.Replace(match1.Groups[0].Value, "").TrimStart(new char[0]).Length; } else { MatchCollection matchCollection = RegularExpressions.VALID_URL.Matches(this.actualtweetText); if (matchCollection.Count > 0) { foreach (Match match2 in matchCollection) { num2 += match2.Groups[3].Length; num1 += match2.Groups[4].Value == "https://" ? SettingsData.Instance.TwitterShortEncryptedUrlLength : SettingsData.Instance.TwitterShortUrlLength; } } count = Enumerable.Count<char>((IEnumerable<char>)this.actualtweetText) - match1.Groups[0].Length - num2 + num1; } } else { if (this.newTweetType == TwitViewModel.NewTweetType.DirectMessage) { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => this.ResetNewTweet(false))); } else { MatchCollection matchCollection = RegularExpressions.VALID_URL.Matches(this.actualtweetText); if (matchCollection.Count > 0) { foreach (Match match2 in matchCollection) { num2 += match2.Groups[3].Length; num1 += match2.Groups[4].Value == "https://" ? SettingsData.Instance.TwitterShortEncryptedUrlLength : SettingsData.Instance.TwitterShortUrlLength; } } } count = Enumerable.Count<char>((IEnumerable<char>)this.actualtweetText) - num2 + num1; } if (this.CurrentlySelectedImage != null) count += SettingsData.Instance.TwitterShortUrlLength; string countText = (SettingsData.Instance.TweetCharLimit - count).ToString(); bool postEnabled = (count <= SettingsData.Instance.TweetCharLimit || Enumerable.Count<ITweetService>(Enumerable.Where<ITweetService>((IEnumerable<ITweetService>)CoreServices.Instance.TweetServices, (Func<ITweetService, bool>)(x => x.OverrideTweetCharLimit))) != 0) && (count != 0 && this.StatusType != 0); Visibility countVisible = count == 0 ? Visibility.Collapsed : Visibility.Visible; bool countOver = count > SettingsData.Instance.TweetCharLimit; System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { this.CharCount = count; this.CharCountText = countText; this.PostTweetEnabled = postEnabled; this.CharCountVisibility = countVisible; this.CharCountOver = countOver; })); if (this.newTweetType != TwitViewModel.NewTweetType.Reply || (this.Status == null || this.ActualTweetText.IndexOf("@" + this.Status.User.ScreenName) >= 0)) return; this.ReplyToID = new Decimal(0); this.newTweetType = TwitViewModel.NewTweetType.Normal; this.Status = (MetroTwitStatusBase)null; }
public void ResetNewTweet(bool bNotify = true) { this.imageUploadsFailed = false; Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)true), (object)ViewModelMessages.EnableReplyOptions); this.StatusLabelVisibility = Visibility.Collapsed; this.StatusText = ""; this.ReplyToID = new Decimal(0); this.UserName = ""; if (bNotify) this.ActualTweetText = ""; this.newTweetType = TwitViewModel.NewTweetType.Normal; this.StatusType = -1; this.Status = (MetroTwitStatusBase)null; if (!bNotify) return; Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText)); }
private void TryAddView(ViewType viewType, ViewModelType viewModelType, TweetListType columnType, string searchTerm, string searchName, Decimal? existingSearchID = null, MetroTwitStatusBase Tweet = null, TwitterList ListItem = null) { if (viewType == ViewType.Column) { this.TryAddColumn(false, (TweetListViewModel)null, columnType, searchTerm, searchName, existingSearchID); } else { if (viewType != ViewType.Popup) return; if (InlinePopup.CurrentInline != null) InlinePopup.CurrentInline.Close(); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)null), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.SetNewTweetEntryOptionsContainer)); UserControl view = (UserControl)null; switch (viewModelType) { case ViewModelType.TweetList: if (columnType == TweetListType.Conversation) { string replyToScreenName = Tweet.InReplyToScreenName; TweetListViewModel tweetListViewModel = new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, replyToScreenName, string.Empty, new Decimal?(), false, Tweet, Tweet.ID) { EnableNotifications = false, TitleBarVisible = false, SettingsVisible = false }; TweetListView tweetListView = new TweetListView(); tweetListView.DataContext = (object)tweetListViewModel; view = (UserControl)tweetListView; break; } else { TweetListViewModel tweetListViewModel; if (Tweet != null && Tweet.AdUrls != null && !string.IsNullOrEmpty(Tweet.AdUrls.friendship_url)) tweetListViewModel = new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, searchTerm, searchName, new Decimal?(), false, (MetroTwitStatusBase)null, new Decimal(0)) { EnableNotifications = false, AdFollowUrl = Tweet.AdUrls.friendship_url, TitleBarVisible = false, SettingsVisible = false }; else tweetListViewModel = new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, searchTerm, searchName, new Decimal?(), false, (MetroTwitStatusBase)null, new Decimal(0)) { EnableNotifications = false, TitleBarVisible = false, SettingsVisible = false }; tweetListViewModel.AllowPin = columnType != TweetListType.RetweetUsers; ProfileView profileView = new ProfileView(); profileView.DataContext = (object)tweetListViewModel; view = (UserControl)profileView; break; } case ViewModelType.Lists: ListsView listsView = new ListsView(); listsView.DataContext = (object)new ListsViewModel(this.TwitterAccountID) { PopupTitle = "lists", AllowPin = false }; view = (UserControl)listsView; break; case ViewModelType.Trends: TrendsView trendsView1 = new TrendsView(); TrendsView trendsView2 = trendsView1; TrendsViewModel trendsViewModel1 = new TrendsViewModel(); trendsViewModel1.TwitterAccountID = this.TwitterAccountID; trendsViewModel1.AllowPin = false; trendsViewModel1.PopupTitle = "twitter trends"; TrendsViewModel trendsViewModel2 = trendsViewModel1; trendsView2.DataContext = (object)trendsViewModel2; view = (UserControl)trendsView1; break; case ViewModelType.ManageList: ManageTwitterListView manageTwitterListView = new ManageTwitterListView(); manageTwitterListView.DataContext = (object)new ManageTwitterListViewModel(ListItem != null ? ListItem : (TwitterList)null, this.TwitterAccountID) { AllowPin = false, PopupTitle = (ListItem != null ? string.Format("Edit {0}", (object)ListItem.Name) : "create new list") }; view = (UserControl)manageTwitterListView; break; } PopupService.ShowView(view); } }
private string SetupReplyAll(MetroTwitStatusBase status, string screenname, string retweetscreenname) { string str1 = string.Empty; if (this.ActualTweetText.IndexOf("@" + screenname) < 0) this.ActualTweetText = string.Format("{0}{1}@{2} ", (object)this.ActualTweetText.Trim(), this.ActualTweetText == string.Empty ? (object)"" : (object)" ", (object)screenname); if (status.IsRetweet && !string.IsNullOrEmpty(retweetscreenname) && (this.ActualTweetText.IndexOf("@" + retweetscreenname) < 0 && retweetscreenname.ToLower() != App.AppState.Accounts[this.TwitterAccountID].TwitterAccountName.ToLower())) { this.ActualTweetText = string.Format("{0}{1}@{2} ", (object)this.ActualTweetText.Trim(), this.ActualTweetText == string.Empty ? (object)"" : (object)" ", (object)retweetscreenname); str1 = string.Format("{0}{1}@{2} ", (object)str1.Trim(), str1 == string.Empty ? (object)"" : (object)" ", (object)retweetscreenname); } IEnumerable<MentionEntity> source = status.Entities != null ? Enumerable.OfType<MentionEntity>((IEnumerable)status.Entities) : (IEnumerable<MentionEntity>)null; if (source != null && Enumerable.Count<MentionEntity>(source) > 0) { foreach (string str2 in Enumerable.Select<MentionEntity, string>(source, (Func<MentionEntity, string>)(x => x.ScreenName.Trim()))) { if (this.ActualTweetText.IndexOf("@" + str2) < 0 && str2.ToLower() != App.AppState.Accounts[this.TwitterAccountID].TwitterAccountName.ToLower()) { this.ActualTweetText = string.Format("{0}{1}@{2} ", (object)this.ActualTweetText.Trim(), this.ActualTweetText == string.Empty ? (object)"" : (object)" ", (object)str2); str1 = string.Format("{0}{1}@{2} ", (object)str1.Trim(), str1 == string.Empty ? (object)"" : (object)" ", (object)str2); } } } return str1; }
private void TweetsUpdated(MetroTwitStatusBase tweet, List<MetroTwitStatusBase> newtweets, RefreshTypes RefreshType, bool flushingbacklog = false) { Action method = null; Action action2 = null; Action action3 = null; try { if ((tweet != null) || (newtweets != null)) { if (this.Tweets == null) { this.Tweets = new SortableObservableCollection<MetroTwitStatusBase>(new List<MetroTwitStatusBase>()); } if (tweet != null) { tweet = this.FilterTweets(tweet); } if (newtweets != null) { newtweets = this.FilterTweets(newtweets); } if ((((SettingsData.Instance.BacklogSeconds > 0) || this.IsPaused) && (!flushingbacklog && (RefreshType != RefreshTypes.ForeverScroll))) && (RefreshType != RefreshTypes.Normal)) { if (this.backlog == null) { this.backlog = new List<MetroTwitStatusBase>(); } if (tweet != null) { this.backlog.Insert(0, tweet); } else if ((newtweets != null) && (newtweets.Count > 0)) { this.backlog.InsertRange<MetroTwitStatusBase>(newtweets); } if (this.backlog.Count > 0) { if (this.Tweets[0].TweetListSpecial != TweetListSpecial.Backlog) { MetroTwitStatusBase item = new MetroTwitStatusBase { TweetListSpecial = TweetListSpecial.Backlog, CreatedDate = DateTime.MaxValue }; this.Tweets.Insert(0, item); } else { if (method == null) { method = () => this.RaisePropertyChanged("BacklogCount"); } System.Windows.Application.Current.Dispatcher.BeginInvoke(method, DispatcherPriority.Background, new object[0]); } } } else { if (RefreshType != RefreshTypes.ForeverScroll) { Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>(false), ViewModelMessages.TweetsUpdated.ToString() + this.UniqueTweetListID.ToString()); } bool flag = false; if ((tweet != null) || ((newtweets != null) && (newtweets.Count > 0))) { if ((newtweets != null) && (newtweets.Count > 0)) { newtweets = newtweets.Distinct<MetroTwitStatusBase>().ToList<MetroTwitStatusBase>(); MetroTwitStatusBase[] baseArray = newtweets.ToArray(); for (int i = 0; i < baseArray.Length; i++) { Func<MetroTwitStatusBase, int, bool> predicate = null; MetroTwitStatusBase t = baseArray[i]; if (predicate == null) { predicate = (x, r) => (x.ID == t.ID) || (x.ID == t.OriginalID); } IEnumerable<MetroTwitStatusBase> source = this.Tweets.ToArray<MetroTwitStatusBase>().Where<MetroTwitStatusBase>(predicate); if (RefreshType != RefreshTypes.ForeverScroll) { foreach (MetroTwitStatusBase base3 in source) { if (base3.UnRead) { flag = true; } this.RemoveTweet(base3); } } else if (source.Count<MetroTwitStatusBase>() > 0) { newtweets.Remove(t); } } if (newtweets.Count == 0) { return; } } if (flag) { if (action2 == null) { action2 = delegate { base.RaisePropertyChanged("TweetCount"); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>(null), ViewModelMessages.OverlayCountRecalc); }; } System.Windows.Application.Current.Dispatcher.BeginInvoke(action2, DispatcherPriority.Background, new object[0]); } } if (newtweets != null) { foreach (MetroTwitStatusBase base4 in newtweets.Where<MetroTwitStatusBase>(((Func<MetroTwitStatusBase, int, bool>)((x, r) => (x.RetweetUser != null)))).ToArray<MetroTwitStatusBase>()) { if (App.AppState.Accounts[base.TwitterAccountID].Cache.NoRetweetIds.Contains((long)base4.RetweetUser.Id)) { newtweets.Remove(base4); } } } if (((tweet != null) && (tweet.RetweetUser != null)) && App.AppState.Accounts[base.TwitterAccountID].Cache.NoRetweetIds.Contains((long)tweet.RetweetUser.Id)) { tweet = null; } else if ((tweet != null) && this.Tweets.Contains(tweet)) { tweet = null; } else { this.LastCollectionState = this.InitialForeverScroll ? RefreshTypes.InitialLoadForeverScroll : RefreshType; if (RefreshType != RefreshTypes.ForeverScroll) { if (tweet != null) { this.Tweets.Insert((this.TweetType != TweetListType.RetweetUsers) ? 0 : 1, tweet); } else { this.Tweets.InsertRange<MetroTwitStatusBase>(newtweets); } } else if (tweet != null) { this.AddTweet(tweet); } else { lock (this._tweetsLock) { this.Tweets.AddRange<MetroTwitStatusBase>(newtweets); } } if (action3 == null) { action3 = delegate { base.RaisePropertyChanged("TweetCount"); if ((tweet != null) && tweet.UnRead) { this.MakeSomeNoise(tweet, this.TweetListName, RefreshType); } if ((newtweets != null) && (newtweets.Count > 0)) { this.MakeSomeNoise(newtweets.Where<MetroTwitStatusBase>((Func<MetroTwitStatusBase, int, bool>)((x, r) => x.UnRead)), this.TweetListName, RefreshType); } if (RefreshType != RefreshTypes.ForeverScroll) { Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>(true), ViewModelMessages.TweetsUpdated.ToString() + this.UniqueTweetListID.ToString()); } }; } System.Windows.Application.Current.Dispatcher.BeginInvoke(action3, DispatcherPriority.Background, new object[0]); if (((RefreshType == RefreshTypes.ForeverScroll) && (this.TweetType != TweetListType.Conversation)) && (this.TweetType != TweetListType.RetweetUsers)) { this.ForeverScrolling = false; this.InitialForeverScroll = false; } if ((RefreshType == RefreshTypes.Normal) && (this.Tweets.Count<MetroTwitStatusBase>() < 50)) { this.InitialForeverScroll = true; this.ForeverScroll(); } if (this.TweetType != TweetListType.RetweetUsers) { this.Tweets.Sort<decimal>(x => x.ID, ListSortDirection.Descending); this.UpdateReadTweets(null); } } } } } catch { } }
private MetroTwitStatusBase FilterTweets(MetroTwitStatusBase tweet) { if (this.FilteringRemoveTweet(tweet, SettingsData.Instance.Filter) || this.FilteringRemoveTweet(tweet, App.AppState.Accounts[this.TwitterAccountID].Settings.Filter)) return (MetroTwitStatusBase)null; else return tweet; }
public static void CopyTweet(MetroTwitStatusBase tweet) { try { if (tweet == null || tweet.User == null) return; System.Windows.Clipboard.SetText(string.Format("@{0}: {1}", (object)tweet.User.ScreenName, (object)WebUtility.HtmlDecode(tweet.Text))); } catch { } }
private void MakeSomeNoise(MetroTwitStatusBase Tweet, string Name, RefreshTypes RefreshType) { this.MakeSomeNoise((IEnumerable<MetroTwitStatusBase>)new Collection<MetroTwitStatusBase>() { Tweet }, Name, RefreshType); }
private void Retweet(GenericMessage<object> o) { if (this.sendingTweetInProgress) return; this.ResetNewTweet(true); this.newTweetType = TwitViewModel.NewTweetType.Retweet; this.Status = o.Content as MetroTwitStatusBase; this.ActualTweetText = "RT @{1} {2}".Replace("{1}", (o.Content as MetroTwitStatusBase).User.ScreenName).Replace("{2}", WebUtility.HtmlDecode((o.Content as MetroTwitStatusBase).Text)); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText)); App.AppState.SwitchToAccount(this.TwitterAccountID); }
internal static void EmailTweet(MetroTwitStatusBase metroTwitStatusBase) { try { Process.Start(string.Format("mailto:{0}?subject={1}&body={2}", (object)"", (object)("Check this tweet out from @" + metroTwitStatusBase.User.ScreenName), (object)string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}", (object)metroTwitStatusBase.Text, (object)"%0D%0A", (object)"%0D%0A", (object)metroTwitStatusBase.Permalink, (object)"%0D%0A", (object)"%0D%0A", (object)"---------------------------------", (object)"%0D%0A", (object)"%0D%0A", (object)"Sent from MetroTwit"))); } catch { } }
private void Reply(GenericMessage<object> o) { if (this.sendingTweetInProgress) return; if (this.Status == null) { this.Status = o.Content as MetroTwitStatusBase; this.ReplyToID = this.Status.ID; this.UserName = this.Status.User.ScreenName; this.newTweetType = TwitViewModel.NewTweetType.Reply; } App.AppState.SwitchToAccount(this.TwitterAccountID); if (this.ActualTweetText.IndexOf("@" + this.UserName) < 0) { this.ActualTweetText = string.Format("{0}{1}@{2} ", (object)this.ActualTweetText.Trim(), this.ActualTweetText == string.Empty ? (object)"" : (object)" ", (object)this.UserName); Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText)); } else Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)null), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditFocus)); }