示例#1
0
        //Display Type selection screen and organize pokemon by type
        private void bPictureBox_Click(object sender, EventArgs e)
        {
            //Declare variables
            DialogResult confirmDialogResult;

            //Only resume if the listbox is visible
            if (pokemonListBox.Visible == false)
            {
                //exit method
                return;
            }

            //Confrim action
            confirmDialogResult = MessageBox.Show("Do you want to organize pokemon by type", "Organize by type? ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            //Organize pokemon by type if result is yes
            if (confirmDialogResult == DialogResult.Yes)
            {
                //Create new instance of the type form
                TypeForm typeForm = new TypeForm();

                //Display type selection form
                typeForm.ShowDialog();

                //Set complex boolean to true
                complexName = false;

                //Clear listbox
                pokemonListBox.Items.Clear();

                //Set sorted to true
                pokemonListBox.Sorted = true;

                //Fill list with all pokemon names
                foreach (DataRow pokemonDataRow in pokemonDataSet.Tables[0].Rows)
                {
                    //Add Each Pokemon name to the list the name column is not empty
                    if (pokemonDataRow["Name"].ToString() == "")
                    {
                        //No Name In current record
                        Console.WriteLine("No Name");
                    }
                    else
                    {
                        //Add Name to List only if type matchs selected type
                        if (pokemonDataRow["Type 1"].ToString() == typeString || pokemonDataRow["Type 2"].ToString() == typeString)
                        {
                            pokemonListBox.Items.Add(pokemonDataRow["Name"].ToString() + " -- " + pokemonDataRow["Dex Num"].ToString());
                        }
                    }
                }
            }
        }
示例#2
0
        //Display Type selection screen and organize pokemon by type
        private void bPictureBox_Click(object sender, EventArgs e)
        {
            //Declare variables
            DialogResult confirmDialogResult;

            //Only resume if the listbox is visible
            if (pokemonListBox.Visible == false)
            {
                //exit method
                return;
            }

            //Confrim action
            confirmDialogResult = MessageBox.Show("Do you want to organize pokemon by type", "Organize by type? ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            //Organize pokemon by type if result is yes
            if (confirmDialogResult == DialogResult.Yes)
            {
                //Create new instance of the type form
                TypeForm typeForm = new TypeForm();

                //Display type selection form
                typeForm.ShowDialog();

                //Set complex boolean to true
                complexName = false;

                //Clear listbox
                pokemonListBox.Items.Clear();

                //Set sorted to true
                pokemonListBox.Sorted = true;

                //Fill list with all pokemon names
                foreach (DataRow pokemonDataRow in pokemonDataSet.Tables[0].Rows)
                {
                    //Add Each Pokemon name to the list the name column is not empty
                    if (pokemonDataRow["Name"].ToString() == "")
                    {
                        //No Name In current record
                        Console.WriteLine("No Name");
                    }
                    else
                    {
                        //Add Name to List only if type matchs selected type
                        if (pokemonDataRow["Type 1"].ToString() == typeString || pokemonDataRow["Type 2"].ToString() == typeString)
                        {
                            pokemonListBox.Items.Add(pokemonDataRow["Name"].ToString() + " -- " +pokemonDataRow["Dex Num"].ToString());
                        }
                    }
                }

            }
        }