Beispiel #1
0
        public void SetChoices(IEnumerable<string> choices, string text = "")
        {
            int indexLine = 1;
            _textLabel.SetText(text);
            _textLabel.Layout(Width - 2 * TextMarginX);
            indexLine += _textLabel.LineCount;
            Components.Clear();
            HighlightedComponent = null;

            foreach (string choice in choices)
            {
                LinkLabel component = new LinkLabel(Batch, _textLabel.Font, choice);
                component.Layout(Width - MenuMarginX - TextMarginX);
                Components.Add(component);
                component.Position = new Point(X + MenuMarginX, Y + indexLine * _textLabel.Font.LineSpacing + TextMarginY);
                component.Selected += Item_Selected;
                indexLine += component.LineCount;
            }
            if (Components.Any())
            {
                HighlightedComponent = Components[0];
                HighlightedComponent.HasFocus = true;
            }
        }