示例#1
0
        public void SetChoices(IEnumerable<string> choices)
        {
            Components.Clear();
            HighlightedComponent = null;
            int lineSpacing = (BoundingBox.Height - 2 * Margin.Y) / (choices.Count() + 1);

            int i = 0;
            foreach (string choice in choices)
            {
                i += 1;
                LinkLabel component = new LinkLabel(Batch, _titleLabel.Font, choice);
                Components.Add(component);
                component.Position = new Point(BoundingBox.X + Margin.X, BoundingBox.Y + i * lineSpacing + Margin.Y);
                component.Selected += Item_Selected;
            }
            if (Components.Any())
            {
                HighlightedComponent = Components[0];
                HighlightedComponent.HasFocus = true;
            }
        }
示例#2
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;
            }
        }