Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 private void PinColumn(MetroTwitColumn column, TweetListViewModel newcolumn)
 {
     this.ColumnsToShow.Add(newcolumn);
     if (column.Index != this.ColumnsToShow.Count - 1)
         column.Index = this.ColumnsToShow.Count - 1;
     this.SetAddButtonsEnabled(column.ColumnType, false);
 }