Esempio n. 1
0
        private void manageLists_Click(object sender, EventArgs e)
        {
            Manage manageList = new Manage(collectionList, Enums.ManageDialogue.List);

            manageList.ShowDialog();

            if (manageList.FormResponse.Count > 0)
            {
                foreach (ManageFormResponse response in manageList.FormResponse)
                {
                    if (response.RespondCommand == Enums.ManageFormState.New)
                    {
                        foreach (Enums.ListPositions position in Enum.GetValues(typeof(Enums.ListPositions)))
                        {
                            collectionList.Add(new ChampionCollection(response.Name, position.ToString(), CustomListsStrip, controlPanel, this));
                        }
                    }
                    else if (response.RespondCommand == Enums.ManageFormState.Edit)
                    {
                        foreach (ChampionCollection collectionItem in collectionList)
                        {
                            if (response.Name == collectionItem.Name)
                            {
                                collectionItem.Name = response.NewName;
                            }
                        }
                    }
                    else if (response.RespondCommand == Enums.ManageFormState.Delete)
                    {
                        for (int i = collectionList.Count - 1; i >= 0; i--)
                        {
                            if (response.Name == collectionList[i].Name)
                            {
                                collectionList.RemoveAt(i);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("Incorrect Form Response Command");
                    }
                }
            }
            else
            {
                MessageBox.Show("No changes were made");
            }

            //Update the dropdown with the newly added/edited lists and rebuild the context menu
            updateListCollectionDropdown();
            BuildContextMenu();

            //Save changes to file
            saveFile.ImportLines(collectionList);
            saveFile.saveToFile("rekt.gg");
        }
Esempio n. 2
0
        private void manageChamp_Click(object sender, EventArgs e)
        {
            Manage manageChamp = new Manage(collectionList, Enums.ManageDialogue.Champion);

            manageChamp.ShowDialog();

            if (manageChamp.FormResponse.Count > 0)
            {
                foreach (ManageFormResponse response in manageChamp.FormResponse)
                {
                    if (response.RespondCommand == Enums.ManageFormState.New)
                    {
                        foreach (ChampionCollection collectionItem in collectionList)
                        {
                            if (collectionItem.Name == Constants.ALL_CHAMPIONS)
                            {
                                collectionItem.Add(new Champion(response.Name, response.Picture, "", ""));

                                break;
                            }
                        }
                    }
                    else if (response.RespondCommand == Enums.ManageFormState.Edit)
                    {
                        foreach (ChampionCollection collectionItem in collectionList)
                        {
                            foreach (ChampionContainer containedChampion in collectionItem.ContainedChampions())
                            {
                                if (containedChampion.Name == response.Name)
                                {
                                    containedChampion.Name = response.NewName;
                                    containedChampion.Image = response.Picture;
                                    break; // Champion names should be unique so it should be safe to use break here;
                                }

                            }
                        }
                    }
                    else if (response.RespondCommand == Enums.ManageFormState.Delete)
                    {
                        foreach (ChampionCollection collectionItem in collectionList)
                        {
                            collectionItem.Remove(response.Name);
                        }
                    }
                    else
                    {
                        throw new Exception("Incorrect Form Response Command");
                    }
                }
            }
            else
            {
                MessageBox.Show("No changes were made");
            }

            //View newly added/edite champions
            selectedCollection.Print(textSeaarchBox.Text);

            //Save changes to file
            saveFile.ImportLines(collectionList);
            saveFile.saveToFile("rekt.gg");
        }