Пример #1
0
        public Listbox(int dropDownLength, int width, IResourceManager resourceManager,
                       List <string> initialOptions = null)
        {
            _resourceManager = resourceManager;

            _width        = width;
            _listboxLeft  = _resourceManager.GetSprite("button_left");
            _listboxMain  = _resourceManager.GetSprite("button_middle");
            _listboxRight = _resourceManager.GetSprite("button_right");

            _selectedLabel = new TextSprite("ListboxLabel", "", _resourceManager.GetFont("CALIBRI"))
            {
                Color = Color.Black
            };

            _dropDown = new ScrollableContainer("ListboxContents", new Size(width, dropDownLength), _resourceManager);
            _dropDown.SetVisible(false);

            if (initialOptions != null)
            {
                _contentStrings = initialOptions;
                RebuildList();
            }

            Update(0);
        }
Пример #2
0
        private void SetItem(Label toSet, bool raiseEvent = false)
        {
            if (ItemSelected != null && raiseEvent)
            {
                ItemSelected(toSet, this);
            }

            CurrentlySelected   = toSet;
            _selectedLabel.Text = toSet.Text.Text;
            _dropDown.SetVisible(false);

            ((ListboxItem)toSet).Selected = true;
            IEnumerable <ListboxItem> notSelected = from ListboxItem item in _dropDown.components
                                                    where item != toSet
                                                    select item;

            foreach (ListboxItem curr in notSelected)
            {
                curr.Selected = false;
            }
        }
Пример #3
0
        public Listbox(int dropDownLength, int width, IResourceManager resourceManager,
                       List<string> initialOptions = null)
        {
            _resourceManager = resourceManager;

            _width = width;
            _listboxLeft = _resourceManager.GetSprite("button_left");
            _listboxMain = _resourceManager.GetSprite("button_middle");
            _listboxRight = _resourceManager.GetSprite("button_right");

            _selectedLabel = new TextSprite("ListboxLabel", "", _resourceManager.GetFont("CALIBRI"))
                                 {Color = Color.Black};

            _dropDown = new ScrollableContainer("ListboxContents", new Size(width, dropDownLength), _resourceManager);
            _dropDown.SetVisible(false);

            if (initialOptions != null)
            {
                _contentStrings = initialOptions;
                RebuildList();
            }

            Update(0);
        }