예제 #1
0
        private void InitializeListBoxes()
        {
            listBoxAvailableItems.SelectedItem = null;
            listBoxIncludedItems.SelectedItem  = null;
            listBoxAvailableItems.Items.Clear();
            listBoxIncludedItems.Items.Clear();

            List <Item> items = ItemMaintenanceControl.ItemCache;

            if (_activeItem != null)
            {
                // Remove current item
                items.Remove(Item.FindById(items, _activeItem.Id));

                foreach (ItemGroup itemGroup in ItemGroup.GetAll(_activeItem.Id))
                {
                    bool      added, changed, removed;
                    ItemGroup current = GetItemGroup(itemGroup.Id,
                                                     out added, out changed, out removed);
                    if (removed)
                    {
                        continue;
                    }
                    Item item = Item.FindById(items, itemGroup.TargetItemId);
                    AddItemGroupToListBox(
                        (changed ? current : itemGroup), item);
                }
            }

            // Note: Added ones have an ItemId of zero so GetAll (above) will not find them
            foreach (ItemGroup itemGroup in _itemGroupsAdded)
            {
                Item item = Item.FindById(items, itemGroup.TargetItemId);
                AddItemGroupToListBox(itemGroup, item);
            }

            foreach (Item item in items)
            {
                if (ItemGroup.IsGroupMember(item.Id))
                {
                    continue;
                }
                listBoxAvailableItems.Items.Add(
                    new FormattedListBoxItem(item, item.FullName, true));
            }

            SetButtonsEnabled();
        }