public void AddItemToEnd(StatusItem Item) { Items.Add(Item); if (Items.Count > MaxItems) { Items.RemoveAt(0); Items.TrimExcess(); RenderNewItemAtEnd(); } }
public void ReRenderItem(StatusItem Item) { lock (_RenderThreads) { try { if (Items.Contains(Item)) { int i = Items.IndexOf(Item); Rectangle itemBounds = new Rectangle(0, ClientSettings.ItemHeight * i, Item.Bounds.Width, ClientSettings.ItemHeight); Item.Render(_RenderedGraphics, itemBounds); } } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); } } }
public void AddItemsToEnd(StatusItem[] Items) { foreach (StatusItem Item in Items) { AddItemToEnd(Item); } NewImage(); }
public void AddItemToStart(StatusItem Item) { Items.Insert(0, Item); if (Items.Count > MaxItems) { Items.RemoveAt(Items.Count - 1); Items.TrimExcess(); RenderNewItemAtStart(); } }
public void AddItemsToStart(StatusItem[] Items) { for (int i = Items.Length - 1; i >= 0; i--) { AddItemToStart(Items[i]); } NewImage(); }
public void SetItemList(List<StatusItem> SetOfItems) { StatusItem FirstNewItem = SetOfItems[0]; int SpacesMoved = 0; if (Items.Contains(FirstNewItem) && SetOfItems.Count > SpacesMoved) { try { //Items added to the end SpacesMoved = Items.IndexOf(FirstNewItem); StatusItem[] ItemsToAdd = new StatusItem[SpacesMoved]; Array.Copy(SetOfItems.ToArray(), SetOfItems.Count - SpacesMoved, ItemsToAdd, 0, SpacesMoved); System.Diagnostics.Debug.WriteLine("Blitting " + SpacesMoved + " to the end of the image."); AddItemsToEnd(ItemsToAdd); return; } catch(ArgumentOutOfRangeException) { } } else { try { StatusItem LastNewItem = SetOfItems[SetOfItems.Count - 1]; if (Items.Contains(LastNewItem)) { //Items added to the start SpacesMoved = MaxItems - (Items.IndexOf(LastNewItem) + 1); StatusItem[] ItemsToAdd = new StatusItem[SpacesMoved]; Array.Copy(SetOfItems.ToArray(), 0, ItemsToAdd, 0, SpacesMoved); System.Diagnostics.Debug.WriteLine("Blitting " + SpacesMoved + " to the start of the image."); AddItemsToStart(ItemsToAdd); return; } } catch (ArgumentOutOfRangeException) { } } System.Diagnostics.Debug.WriteLine("Jumped " + SpacesMoved + " spaces"); Items.Clear(); Items = new List<StatusItem>(SetOfItems); if (Items.Count > MaxItems) { Items.RemoveRange(MaxItems, Items.Count - MaxItems); } Rerender(); }
private void AddStatusesToList(Library.status[] mergedstatuses, bool KeepPosition) { if (InvokeRequired) { delAddStatuses d = new delAddStatuses(AddStatusesToList); this.Invoke(d, new object[] { mergedstatuses, KeepPosition }); } else { int newItems = 0; if(KeepPosition) { FingerUI.StatusItem selectedItem = (FingerUI.StatusItem)statList.SelectedItem; TimelineManagement.TimeLineType t = TimelineManagement.TimeLineType.Friends; if(statList.CurrentList()=="Messages_TimeLine") { t = TimelineManagement.TimeLineType.Messages; } string Constraints = ""; if(currentGroup!=null){ Constraints = currentGroup.GetConstraints();} newItems = LocalStorage.DataBaseUtility.CountItemsNewerThan(t, selectedItem.Tweet.id, Constraints); } if (mergedstatuses == null) { return; } if (mergedstatuses.Length == 0) { return; } int OldOffset = 0; int oldIndex = 0; oldIndex = statList.SelectedIndex; OldOffset = statList.YOffset - (ClientSettings.ItemHeight * oldIndex); int oldCount = statList.Count; statList.Clear(); foreach (Library.status stat in mergedstatuses) { if (stat != null && stat.user != null && stat.user.screen_name != null) { FingerUI.StatusItem item = new FingerUI.StatusItem(); item.Tweet = stat; statList.AddItem(item); } } FingerUI.StatusItem currentItem = null; if (!ClientSettings.AutoScrollToTop) { if (oldIndex >= 0 && KeepPosition && newItems < ClientSettings.MaxTweets) { try { statList.SelectedItem = statList[newItems]; currentItem = (FingerUI.StatusItem)statList.SelectedItem; statList.YOffset = OldOffset + (newItems * ClientSettings.ItemHeight); } catch (KeyNotFoundException) { //What to do? } } else { statList.JumpToLastSelected(); currentItem = (FingerUI.StatusItem)statList[0]; } } else { statList.SelectedItem = statList[0]; statList.YOffset = 0; } if (currentItem != null) { CurrentlySelectedAccount = currentItem.Tweet.Account; UpdateRightMenu(); } statList.Redraw(); statList.RerenderPortal(); statList.Repaint(); } }