Пример #1
0
        public void RefreshSpells()
        {
            var selectedIndex = spellsListBox.SelectedItemIndex;

            spellsListBox.ClearItems();

            for (var index = 0; index < SpellBook.Spells.Length; index++)
            {
                var spell = SpellBook.Spells[index];
                spellsListBox.AddItem(new SpellListBoxItem(spell, index));
            }

            if (selectedIndex != -1)
            {
                spellsListBox.SelectedItemIndex = selectedIndex;
            }
            else
            {
                spellsListBox.SelectedItemIndex = 0;
            }
        }
Пример #2
0
        public void RefreshSpells(bool keepSelection)
        {
            var selectedIndex = keepSelection ? spellsList.SelectedItemIndex : 0;

            spellsList.ClearItems();

            for (var index = 0; index < GetFilteredSpells().Length; index++)
            {
                var spell = Spells[index];
                spellsList.AddItem(new SpellListBoxItem(spell, index));
            }

            if (selectedIndex != -1)
            {
                spellsList.SelectedItemIndex = selectedIndex;
            }
            else
            {
                spellsList.SelectedItemIndex = 0;
            }
        }
Пример #3
0
        protected void RefreshItems(bool keepSelection)
        {
            var selectionIndex = itemsList.SelectedItemIndex;

            itemsList.ClearItems();

            foreach (var inventoryStack in Stacks.Where(stack => CheckFilter(stack.TopItem)))
            {
                itemsList.AddItem(CreateListBoxItem(inventoryStack));
            }

            if (keepSelection && selectionIndex < itemsList.Items.Length)
            {
                itemsList.SelectedItemIndex = selectionIndex;
            }
            else if (itemsList.Items.Length > 0)
            {
                itemsList.SelectedItemIndex = 0;
            }

            ProcessSelectedItemChanged();
        }