コード例 #1
0
 private void NestUpdate(NestSync sync)
 {
     if (!App.AppState.Accounts[this.TwitterAccountID].Settings.SyncColumns || sync == null)
         return;
     if (sync.Add != null && sync.Add.Count > 0)
     {
         foreach (NestColumn nestColumn in (IEnumerable)sync.Add)
         {
             NestColumn column = nestColumn;
             IEnumerable<TweetListViewModel> source = Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, int, bool>)((x, r) => x.NestColumnID == column.Id || x.TweetListName == column.Name && x.TwitterTerm == (string.IsNullOrEmpty(column.Value) ? string.Empty : column.Value) && x.TweetType == (TweetListType)column.Type));
             if (Enumerable.Count<TweetListViewModel>(source) == 0)
             {
                 TweetListViewModel tweetListViewModel = new TweetListViewModel(Guid.Empty, (TweetListType)column.Type, this.TwitterAccountID, new MetroTwitColumn(), column.Name, string.Empty, column.Value, new Decimal?(), false, (MetroTwitStatusBase)null, (Decimal)column.LastReadId);
                 tweetListViewModel.ChangetoSavedColumn();
                 this.ColumnsToShow.Add(tweetListViewModel);
                 this.SetAddButtonsEnabled(tweetListViewModel.TweetType, false);
                 System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)-1), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.ColumnsToShow))), new object[0]);
             }
             else
                 Enumerable.First<TweetListViewModel>(source).NestColumnID = column.Id;
         }
     }
     if (sync.Edit != null && sync.Edit.Count > 0)
     {
         foreach (NestColumn nestColumn in (IEnumerable)sync.Edit)
         {
             NestColumn column = nestColumn;
             IEnumerable<TweetListViewModel> source = Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, int, bool>)((x, r) => x.NestColumnID == column.Id));
             if (Enumerable.Count<TweetListViewModel>(source) > 0)
             {
                 foreach (TweetListViewModel tweetListViewModel in source)
                 {
                     TweetListViewModel MTColumn = tweetListViewModel;
                     if (!string.IsNullOrEmpty(column.Name))
                         Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => MTColumn.TweetListName = column.Name), DispatcherPriority.ContextIdle, new object[0]);
                     if (!string.IsNullOrEmpty(column.Value))
                         Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => MTColumn.TwitterTerm = column.Value), DispatcherPriority.ContextIdle, new object[0]);
                     if (column.LastReadId > 0L && (Decimal)column.LastReadId > MTColumn.CurrentTweetID)
                         Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() =>
                         {
                             MTColumn.CurrentTweetID = (Decimal)column.LastReadId;
                             MTColumn.UpdateReadTweets(new Decimal?());
                         }), DispatcherPriority.ContextIdle, new object[0]);
                 }
             }
             else
             {
                 IEnumerable<TweetListViewModel> possiblecolumns = Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, int, bool>)((x, r) => x.TweetListName == column.Name && x.TwitterTerm == (string.IsNullOrEmpty(column.Value) ? string.Empty : column.Value) && x.TweetType == (TweetListType)column.Type));
                 if (Enumerable.Count<TweetListViewModel>(possiblecolumns) > 0)
                     Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => Enumerable.First<TweetListViewModel>(possiblecolumns).NestColumnID = column.Id), DispatcherPriority.ContextIdle, new object[0]);
             }
         }
     }
     if (sync.Remove != null && sync.Remove.Count > 0)
     {
         foreach (NestColumn nestColumn in (IEnumerable)sync.Remove)
         {
             NestColumn column = nestColumn;
             foreach (TweetListViewModel tweetListViewModel in Enumerable.ToArray<TweetListViewModel>(Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, int, bool>)((x, r) => x.NestColumnID == column.Id))))
             {
                 TweetListViewModel MTColumn = tweetListViewModel;
                 Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => this.RemoveColumn(new GenericMessage<TweetListViewModel>(MTColumn), false)), DispatcherPriority.ContextIdle, new object[0]);
             }
         }
     }
     if (sync.Add.Count == 0 && sync.Edit.Count == 0 && sync.Edit.Count == 0 && Enumerable.Count<TweetListViewModel>(Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, bool>)(x => x.NestColumnID == 0))) == this.ColumnsToShow.Count)
     {
         NestSync NestSync = new NestSync();
         NestSync.Add = (IList)new ArrayList();
         foreach (TweetListViewModel tweetListViewModel in (Collection<TweetListViewModel>)this.ColumnsToShow)
             NestSync.Add.Add((object)new NestColumn()
             {
                 Name = tweetListViewModel.TweetListName,
                 Value = tweetListViewModel.TwitterTerm,
                 Type = (int)tweetListViewModel.TweetType,
                 LastReadId = (long)tweetListViewModel.CurrentTweetID,
                 Date = DateTime.UtcNow.ToUniversalTime()
             });
         NestService.ColumnsSync(NestSync, (Action<NestSync>)(r => this.NestUpdate(r)), this.TwitterAccountID);
     }
     else
     {
         App.AppState.Accounts[this.TwitterAccountID].Settings.SyncLastUpdate = new DateTime?(DateTime.UtcNow.ToUniversalTime());
         foreach (TweetListViewModel tweetListViewModel in Enumerable.Where<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow, (Func<TweetListViewModel, bool>)(x => x.NestColumnID == 0)))
         {
             TweetListViewModel overriddencolumn = tweetListViewModel;
             Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => this.RemoveColumn(new GenericMessage<TweetListViewModel>(overriddencolumn), false)), DispatcherPriority.ContextIdle, new object[0]);
         }
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 private void TryAddColumn(bool existing, TweetListViewModel existingColumnModel, TweetListType columnType, string searchTerm, string searchName, Decimal? existingSearchID)
 {
     bool flag = false;
     TweetListViewModel tweetListViewModel1 = existingColumnModel;
     foreach (TweetListViewModel tweetListViewModel2 in (Collection<TweetListViewModel>)this.ColumnsToShow)
     {
         if (!existing)
             tweetListViewModel1 = new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, searchTerm, searchName, existingSearchID, true, (MetroTwitStatusBase)null, new Decimal(0));
         if (tweetListViewModel2.TweetListName == tweetListViewModel1.TweetListName && tweetListViewModel2.TweetType == tweetListViewModel1.TweetType)
         {
             flag = true;
             break;
         }
     }
     if (!flag)
     {
         TweetListViewModel tweetListViewModel2 = existingColumnModel;
         if (!existing)
             tweetListViewModel2 = columnType != TweetListType.DirectMessages ? (columnType != TweetListType.MentionsMyTweetsRetweeted ? (columnType != TweetListType.FriendsTimeline ? new TweetListViewModel(Guid.Empty, columnType, this.TwitterAccountID, new MetroTwitColumn(), string.Empty, searchTerm, searchName, existingSearchID, false, (MetroTwitStatusBase)null, new Decimal(0)) : App.AppState.Accounts[this.TwitterAccountID].TwitViewModel.FriendsVM) : App.AppState.Accounts[this.TwitterAccountID].TwitViewModel.MentionsVM) : App.AppState.Accounts[this.TwitterAccountID].TwitViewModel.DirectMessagesVM;
         if (tweetListViewModel2.TweetType != TweetListType.DirectMessages && tweetListViewModel2.TweetType != TweetListType.MentionsMyTweetsRetweeted)
         {
             tweetListViewModel2.ToastNotification = false;
             tweetListViewModel2.TaskbarNotification = false;
             tweetListViewModel2.SoundNotification = false;
         }
         this.ColumnsToShow.Add(tweetListViewModel2);
         tweetListViewModel2.ChangetoSavedColumn();
         if (App.AppState.Accounts[this.TwitterAccountID].Settings.SyncColumns)
             NestService.ColumnsSync(new NestSync()
             {
                 Add = {
       (object) new NestColumn()
       {
         Name = tweetListViewModel2.TweetListName,
         Type = (int) tweetListViewModel2.TweetType,
         Value = tweetListViewModel2.TwitterTerm,
         Date = DateTime.UtcNow.ToUniversalTime(),
         LastReadId = 0
       }
     }
             }, (Action<NestSync>)(r => this.NestUpdate(r)), this.TwitterAccountID);
         this.SetAddButtonsEnabled(tweetListViewModel2.TweetType, false);
         Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)-1), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.ColumnsToShow));
     }
     else
         this.UnableToAddColumn();
 }
コード例 #4
0
 private void EnsureMentionsAndDirectMessagesAndFriendsVMs(bool addToColumns)
 {
     if (this.FriendsVM == null)
     {
         IEnumerable<MetroTwitColumn> source = Enumerable.Where<MetroTwitColumn>((IEnumerable<MetroTwitColumn>)App.AppState.Accounts[this.TwitterAccountID].Settings.Columns, (Func<MetroTwitColumn, bool>)(x => x.ColumnType == TweetListType.FriendsTimeline));
         MetroTwitColumn metroTwitColumn = Enumerable.Count<MetroTwitColumn>(source) > 0 ? Enumerable.FirstOrDefault<MetroTwitColumn>(source) : new MetroTwitColumn();
         TweetListViewModel newcolumn = new TweetListViewModel(Guid.Empty, TweetListType.FriendsTimeline, this.TwitterAccountID, metroTwitColumn, (string)null, (string)null, (string)null, new Decimal?(), false, (MetroTwitStatusBase)null, new Decimal(0));
         this.FriendsVM = newcolumn;
         newcolumn.SoundNotification = false;
         newcolumn.TaskbarNotification = false;
         newcolumn.ToastNotification = false;
         newcolumn.ChangetoSavedColumn();
         if (addToColumns)
             this.PinColumn(metroTwitColumn, newcolumn);
         else
             App.AppState.Accounts[this.TwitterAccountID].Settings.Columns[newcolumn.UniqueTweetListID].ColumnPinned = false;
     }
     if (this.MentionsVM == null)
     {
         IEnumerable<MetroTwitColumn> source = Enumerable.Where<MetroTwitColumn>((IEnumerable<MetroTwitColumn>)App.AppState.Accounts[this.TwitterAccountID].Settings.Columns, (Func<MetroTwitColumn, bool>)(x => x.ColumnType == TweetListType.MentionsMyTweetsRetweeted));
         MetroTwitColumn metroTwitColumn = Enumerable.Count<MetroTwitColumn>(source) > 0 ? Enumerable.FirstOrDefault<MetroTwitColumn>(source) : new MetroTwitColumn();
         TweetListViewModel newcolumn = new TweetListViewModel(Guid.Empty, TweetListType.MentionsMyTweetsRetweeted, this.TwitterAccountID, metroTwitColumn, (string)null, (string)null, (string)null, new Decimal?(), false, (MetroTwitStatusBase)null, new Decimal(0));
         this.MentionsVM = newcolumn;
         newcolumn.ChangetoSavedColumn();
         if (addToColumns)
             this.PinColumn(metroTwitColumn, newcolumn);
         else
             App.AppState.Accounts[this.TwitterAccountID].Settings.Columns[newcolumn.UniqueTweetListID].ColumnPinned = false;
     }
     if (this.DirectMessagesVM != null)
         return;
     IEnumerable<MetroTwitColumn> source1 = Enumerable.Where<MetroTwitColumn>((IEnumerable<MetroTwitColumn>)App.AppState.Accounts[this.TwitterAccountID].Settings.Columns, (Func<MetroTwitColumn, bool>)(x => x.ColumnType == TweetListType.DirectMessages));
     TweetListViewModel tweetListViewModel = new TweetListViewModel(Guid.Empty, TweetListType.DirectMessages, this.TwitterAccountID, Enumerable.Count<MetroTwitColumn>(source1) > 0 ? Enumerable.FirstOrDefault<MetroTwitColumn>(source1) : new MetroTwitColumn(), (string)null, (string)null, (string)null, new Decimal?(), false, (MetroTwitStatusBase)null, new Decimal(0));
     this.DirectMessagesVM = tweetListViewModel;
     tweetListViewModel.ChangetoSavedColumn();
     App.AppState.Accounts[this.TwitterAccountID].Settings.Columns[tweetListViewModel.UniqueTweetListID].ColumnPinned = false;
 }
コード例 #5
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);
 }
コード例 #6
0
 public void LoadTweetViews(bool forceReload)
 {
     this.ForceReload = forceReload;
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)0), (object)ViewModelMessages.OverlayCountUpdate);
     this.ResetAddButtonsEnabled();
     if (Enumerable.Count<TweetListViewModel>((IEnumerable<TweetListViewModel>)this.ColumnsToShow) == 1)
         this.ColumnsToShow[0] = (TweetListViewModel)null;
     this.ColumnsToShow.Clear();
     this.ListsEnabled = App.AppState.Accounts[this.TwitterAccountID].IsSignedIn;
     if (App.AppState.Accounts[this.TwitterAccountID].IsSignedIn)
     {
         this.UserStream = new TwitterStreaming(App.AppState.Accounts[this.TwitterAccountID].Tokens, App.AppState.Accounts[this.TwitterAccountID].Settings.TwitterAccountName, this.TwitterAccountID);
         Messenger.Default.Register<GenericMessage<object>>((object)this, (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.StreamingEvent), new Action<GenericMessage<object>>(this.EventReceived));
         if (App.AppState.Accounts[this.TwitterAccountID].Settings.Columns.Count > 0)
         {
             foreach (MetroTwitColumn column in (IEnumerable<MetroTwitColumn>)Enumerable.OrderBy<MetroTwitColumn, int>((IEnumerable<MetroTwitColumn>)App.AppState.Accounts[this.TwitterAccountID].Settings.Columns, (Func<MetroTwitColumn, int>)(x => x.Index)))
             {
                 TweetListType columnType = column.ColumnType;
                 string str = string.Empty;
                 string searchName = !string.IsNullOrEmpty(column.ColumnValue) || columnType != TweetListType.List && columnType != TweetListType.Search && columnType != TweetListType.UserTimeline ? column.ColumnValue : column.ColumnHeader;
                 Guid id = column.ID;
                 TweetListViewModel newcolumn = new TweetListViewModel(column.ID != Guid.Empty ? column.ID : Guid.Empty, columnType, this.TwitterAccountID, App.AppState.Accounts[this.TwitterAccountID].Settings.Columns[column.ID], column.ColumnHeader, !string.IsNullOrEmpty(column.ColumnValue) ? column.ColumnValue : column.ColumnHeader, searchName, column.SearchID, false, (MetroTwitStatusBase)null, column.ColumnLastUpdateID);
                 if (column.NestID > 0)
                     newcolumn.NestColumnID = column.NestID;
                 if (column.ColumnPinned)
                     this.PinColumn(column, newcolumn);
                 if (columnType == TweetListType.MentionsMyTweetsRetweeted)
                     this.MentionsVM = newcolumn;
                 else if (columnType == TweetListType.DirectMessages)
                     this.DirectMessagesVM = newcolumn;
                 else if (columnType == TweetListType.FriendsTimeline)
                     this.FriendsVM = newcolumn;
             }
             SettingsData.Instance.FirstLoad = true;
         }
         else
             this.EnsureMentionsAndDirectMessagesAndFriendsVMs(true);
         this.EnsureMentionsAndDirectMessagesAndFriendsVMs(false);
         this.StartNestTimer();
         Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)-1), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.ColumnsToShow));
         this.SignedInEnabled = true;
         App.RefreshSavedSearches(this.TwitterAccountID, (Action)null);
     }
     this.ForceReload = false;
 }
コード例 #7
0
 private TweetListView GetSpecialTweetListView(TweetListViewModel viewModel, TweetListType tweetListType, string title)
 {
     if (!App.PermanentSpecialTweetListViews.ContainsKey(this.TwitterAccountID))
         App.PermanentSpecialTweetListViews.Add(this.TwitterAccountID, new Dictionary<TweetListType, TweetListView>());
     if (!App.PermanentSpecialTweetListViews[this.TwitterAccountID].ContainsKey(tweetListType))
     {
         viewModel.AllowPin = false;
         viewModel.PopupTitle = title;
         Dictionary<TweetListType, TweetListView> dictionary = App.PermanentSpecialTweetListViews[this.TwitterAccountID];
         int num = (int)tweetListType;
         TweetListView tweetListView1 = new TweetListView();
         tweetListView1.DataContext = (object)viewModel;
         TweetListView tweetListView2 = tweetListView1;
         dictionary.Add((TweetListType)num, tweetListView2);
     }
     TweetListView tweetListView = App.PermanentSpecialTweetListViews[this.TwitterAccountID][tweetListType];
     if (tweetListView.DataContext is IPopupViewModel)
         (tweetListView.DataContext as IPopupViewModel).AllowPin = false;
     return tweetListView;
 }
コード例 #8
0
ファイル: TwitView.cs プロジェクト: unbearab1e/FlattyTweet
 private DataGridColumn CreateColumn(TweetListViewModel columnToShow)
 {
     DataGridColumn dataGridColumn1 = (DataGridColumn) new DataGridTextColumn();
       DataGridColumn dataGridColumn2 = dataGridColumn1;
       TweetListView tweetListView1 = new TweetListView();
       tweetListView1.DataContext = (object) columnToShow;
       TweetListView tweetListView2 = tweetListView1;
       dataGridColumn2.Header = (object) tweetListView2;
       dataGridColumn1.MinWidth = 300.0;
       return dataGridColumn1;
 }