Exemple #1
0
        private void AddStatusesToList(Library.status[] mergedstatuses, bool KeepPosition)
        {
            if (mergedstatuses == null) //Why would this turn up null? Comm error?
            {
                //MessageBox.Show("Status list was null for " + statList.CurrentList());
                return;
            }
            if (mergedstatuses.Length == 0) { return; }
            if (InvokeRequired)
            {
                delAddStatuses d = AddStatusesToList;
                this.Invoke(d, new object[] { mergedstatuses, KeepPosition });
            }
            else
            {
                int newItems = 0;
                if(KeepPosition)
                {
                    IDisplayItem selectedItem = statList.SelectedItem;
                    if (selectedItem != null && selectedItem is StatusItem)
                    {
                        TimelineManagement.TimeLineType t = TimelineManagement.TimeLineType.Friends;
                        if (statList.CurrentList() == "Messages_TimeLine")
                        {
                            t = TimelineManagement.TimeLineType.Messages;
                        }
                        string constraints = "";
                        if (currentSpecialTimeLine != null)
                        {
                            constraints = currentSpecialTimeLine.GetConstraints();
                            t = (currentSpecialTimeLine.Timelinetype == SpecialTimelines.SpecialTimeLinesRepository.TimeLineType.UserGroup) ? TimelineManagement.TimeLineType.Friends : TimelineManagement.TimeLineType.Searches;
                        }
                        newItems = LocalStorage.DataBaseUtility.CountItemsNewerThan(t, (selectedItem as StatusItem).Tweet.id, constraints);
                    }
                }

                int oldOffset = 0;
                int oldIndex = 0;

                oldIndex = statList.SelectedIndex;
                oldOffset = statList.YOffset - (ClientSettings.ItemHeight * oldIndex);

                statList.Clear();
                foreach (Library.status stat in mergedstatuses)
                {
                    if (stat == null || stat.user == null || stat.user.screen_name == null) continue;
                    StatusItem item = new StatusItem {Tweet = stat};
                    statList.AddItem(item);
                }
                IDisplayItem currentItem = null;
                if (!ClientSettings.AutoScrollToTop)
                {
                    if (oldIndex >= 0 && KeepPosition && newItems < ClientSettings.MaxTweets)
                    {
                        try
                        {
                            statList.SelectedItem = statList[newItems];
                            currentItem = statList.SelectedItem;
                            statList.YOffset = oldOffset + (newItems * ClientSettings.ItemHeight);
                        }
                        catch (KeyNotFoundException)
                        {
                            //What to do?
                        }
                    }
                    else
                    {
                        statList.JumpToLastSelected();
                        currentItem = statList[0];
                    }
                }
                else
                {
                    statList.SelectedItem = statList[0];
                    currentItem = statList.SelectedItem;
                    statList.YOffset = 0;
                }

                if (currentItem != null)
                {
                    if (currentItem is StatusItem)
                        CurrentlySelectedAccount = (currentItem as StatusItem).Tweet.Account;
                    UpdateRightMenu();
                }
                statList.Redraw();
                statList.RerenderPortal();
                statList.Repaint();
            }
        }
Exemple #2
0
 private void SetConnectedMenus(Yedda.Twitter t, StatusItem item)
 {
     SetLeftMenu();
     UpdateRightMenu();
 }