public void AddPokeblock(Pokeblock pokeblock)
        {
            if (caseSize == 0 || pokeblocks.Count < caseSize)
            {
                inventory.GameSave.IsChanged = true;
                pokeblocks.Add(new Pokeblock(this, pokeblock.Color, pokeblock.Spicyness, pokeblock.Dryness, pokeblock.Sweetness, pokeblock.Bitterness, pokeblock.Sourness, pokeblock.Feel, pokeblock.Unknown));

                PokeblockCaseEventArgs args = new PokeblockCaseEventArgs();
                args.Index     = pokeblocks.Count - 1;
                args.Pokeblock = pokeblocks[pokeblocks.Count - 1];
                OnAddListViewItem(args);
            }
        }
        public void MovePokeblock(int oldIndex, int newIndex)
        {
            inventory.GameSave.IsChanged = true;
            Pokeblock pokeblock = pokeblocks[oldIndex];

            pokeblocks.RemoveAt(oldIndex);
            pokeblocks.Insert(newIndex, pokeblock);

            PokeblockCaseEventArgs args = new PokeblockCaseEventArgs();

            args.OldIndex  = oldIndex;
            args.NewIndex  = newIndex;
            args.Pokeblock = pokeblock;
            OnMoveListViewItem(args);
        }
        private void OnItemListSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = listViewItems.SelectedIndex;
            if (index < blockCase.SlotsUsed) {
                if (index != -1)
                    selectedIndex = index;
                selectedBlock = blockCase.GetPokeblockAt(selectedIndex);
                if (selectedIndex != -1) {
                    labelPokeblockName.Content = selectedBlock.Color.ToString() + " Pokéblock";
                    imagePokeblock.Source = ItemDatabase.GetPokeblockImageFromColor(selectedBlock.Color, true);
                    labelLevel.Content = selectedBlock.Level.ToString();
                    labelFeel.Content = selectedBlock.Feel.ToString();
                    labelLevelText.Content = "Level";
                    labelFeelText.Content = "Feel";

                    stackPanelFlavors1.Children.Clear();
                    stackPanelFlavors2.Children.Clear();
                    List<PokeblockFlavor> flavors = new List<PokeblockFlavor>();
                    flavors.Add(new PokeblockFlavor(PokeblockColors.Red, selectedBlock.Spicyness));
                    flavors.Add(new PokeblockFlavor(PokeblockColors.Blue, selectedBlock.Dryness));
                    flavors.Add(new PokeblockFlavor(PokeblockColors.Pink, selectedBlock.Sweetness));
                    flavors.Add(new PokeblockFlavor(PokeblockColors.Green, selectedBlock.Bitterness));
                    flavors.Add(new PokeblockFlavor(PokeblockColors.Yellow, selectedBlock.Sourness));

                    flavors.Sort((flavor1, flavor2) => (int)flavor2.Amount - (int)flavor1.Amount);
                    foreach (PokeblockFlavor flavor in flavors) {
                        if (flavor.Amount != 0)
                            AddFlavor(flavor.Flavor, flavor.Amount);
                    }
                }
                else {
                    labelPokeblockName.Content = "";
                    labelLevel.Content = "";
                    labelFeel.Content = "";
                    labelLevelText.Content = "";
                    labelFeelText.Content = "";
                    imagePokeblock.Source = null;
                    stackPanelFlavors1.Children.Clear();
                    stackPanelFlavors2.Children.Clear();
                }
            }
        }
 public int IndexOf(Pokeblock pokeblock)
 {
     return(pokeblocks.IndexOf(pokeblock));
 }
        public void OnRemoveListViewItem(object sender, PokeblockCaseEventArgs e)
        {
            if (e.Index == selectedIndex) {
                selectedBlock = null;
                selectedIndex = -1;
            }
            blockCase.ListViewItems.RemoveAt(e.Index);

            UpdateDetails();
        }