public void RemoveSelectedItem() { if (selectedItem != null) { int index = selectedItem.index; itemList.Remove(selectedItem); currentCount--; for (int i = index; i < currentCount; i++) { Rectangle location = GetItemSize(i); int fontHeight = (int)(spriteFont.MeasureString("D").Y *DisplayController.uiScale); itemList[i].SetLocation(location, fontHeight, i); } selectedItem = null; if (index > itemList.Count - 1) { index = itemList.Count - 1; } if (index > -1) { itemList[index].selected = true; selectedItem = itemList[index]; } SetMaxHeight(); } }
public void AddItem(ListBoxObject item) { if (!itemList.Contains(item)) { Rectangle location = GetItemSize(currentCount); int fontHeight = (int)(spriteFont.MeasureString("D").Y *DisplayController.uiScale); item.SetLocation(location, fontHeight, currentCount); itemList.Add(item); currentCount++; } SetMaxHeight(); }
public void SetIndex(int index) { if (index < itemList.Count) { selectedItem = itemList[index]; itemList[index].selected = true; changed = true; foreach (ListBoxObject item in itemList) { if (item != selectedItem) { item.selected = false; } } } }
private void UpdateItems(Input input) { changed = false; foreach (ListBoxObject item in itemList) { item.Update(input, inViewport); if (item.selected && item != selectedItem) { if (selectedItem != null) { selectedItem.selected = false; } selectedItem = item; changed = true; } } }
private void SetMaxHeight() { float maxSize = 0; if (itemList.Count > 0) { ListBoxObject item = itemList.Last(); if (item != null) { maxSize = (float)(item.location.Y + item.location.Height); } } if (maxSize < location.Height) { maxSize = location.Height; } listBoxCamera.maxHeight = maxSize; listBoxScrollV.Rescale(location); //else max size just equals the height; }
public bool AddItemUniqueDisplay(ListBoxObject item) { if (!itemList.Contains(item)) { foreach (ListBoxObject itemIn in itemList) { if (itemIn.displayName == item.displayName) { return(false); } } Rectangle location = GetItemSize(currentCount); int fontHeight = (int)(spriteFont.MeasureString("D").Y *DisplayController.uiScale); item.SetLocation(location, fontHeight, currentCount); itemList.Add(item); currentCount++; SetMaxHeight(); return(true); } return(false); }
private void UpdateListBoxObject(Layer layer) { ListBoxObject.Items.Clear(); ListBoxObject.Items.AddRange(layer.ObjectsInMap.OrderBy(o => o.DrawOrder).ToArray()); ListBoxObject.Invalidate(); }