public ListControl(String name, Vector2 location, List<ListElement> elements) : base(name, location) { if (elements.Count == 0) { throw new ArgumentException("No elements in this list !"); } this.elements = elements; this.focus = Rectangle.Empty; this.indexList = 0; this.focusedElement = elements[this.indexList]; this.drawLeft = true; this.drawRight = true; this.confirmButtonEnable = false; this.actionCooldown = 0f; }
/// <summary> /// Select the previous element in the list /// </summary> public void PreviousElement() { if (this.indexList - 1 >= 0) { this.indexList--; this.Changed = true; } if (this.Changed) { this.focusedElement = elements[this.indexList]; } }
public void SetFocusedElementByValue(Object value) { foreach (ListElement listElement in elements) { if (listElement.Value.Equals(value)) { this.focusedElement = listElement; this.indexList = elements.IndexOf(this.focusedElement); break; } } this.Changed = false; }
/// <summary> /// Select the next element in the list /// </summary> public void NextElement() { if (this.indexList + 1 < this.elements.Count) { this.indexList++; this.Changed = true; } if (this.Changed) { this.focusedElement = elements[this.indexList]; } }