private void LoadGeneratorGUI(IGenerator Generator)
 {
     if (Generator.GetType() == typeof(CharacterGenerator))
     {
         ucCharacterGenerator ucGenerator = new ucCharacterGenerator();
         ucGenerator.LoadGenerator((CharacterGenerator)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(CharacterRepeater))
     {
         ucCharacterRepeater ucGenerator = new ucCharacterRepeater();
         ucGenerator.LoadGenerator((CharacterRepeater)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(FileGenerator))
     {
         ucFileGenerator ucGenerator = new ucFileGenerator();
         ucGenerator.LoadGenerator((FileGenerator)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(NumberGenerator))
     {
         ucNumberGenerator ucGenerator = new ucNumberGenerator();
         ucGenerator.LoadGenerator((NumberGenerator)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(RandomStringGenerator))
     {
         ucRandomStringGenerator ucGenerator = new ucRandomStringGenerator();
         ucGenerator.LoadGenerator((RandomStringGenerator)Generator);
         AddGenerator(ucGenerator);
     }
     else if (Generator.GetType() == typeof(StringGenerator))
     {
         ucStringGenerator ucGenerator = new ucStringGenerator();
         ucGenerator.LoadGenerator((StringGenerator)Generator);
         AddGenerator(ucGenerator);
     }
 }
        private void AddGeneratorFromPanel(int GeneratorIndex)
        {
            Type    panelType    = splitContainer4.Panel2.Controls[0].GetType();
            Control panelControl = splitContainer4.Panel2.Controls[0];

            ListViewItem Item = new ListViewItem();

            if (panelType == typeof(ucCharacterGenerator))
            {
                ucCharacterGenerator ucGenerator = (ucCharacterGenerator)panelControl;
                if (!ucGenerator.FieldsValid())
                {
                    return;
                }

                CharacterGenerator characterGenerator = ucGenerator.GetGenerator();
                foreach (ListViewItem item in listViewGenerators.Items)
                {
                    if (characterGenerator.Name == item.Text)
                    {
                        MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK);
                        return;
                    }
                }

                if (GeneratorIndex == -1)
                {
                    Generators.Add((IGenerator)characterGenerator);
                }
                else
                {
                    Generators.Insert(GeneratorIndex, (IGenerator)characterGenerator);
                }
                Item.Text = characterGenerator.Name;
                Item.SubItems.Add("Character Generator");
                Item.SubItems.Add(
                    "Inc: " + characterGenerator.Increment.ToString() +
                    ", Start: " + characterGenerator.StartCharacter.ToString() +
                    ", Stop: " + characterGenerator.StopCharacter.ToString() +
                    ", Enc: " + characterGenerator.Encoding.ToString()
                    );
            }
            else if (panelType == typeof(ucCharacterRepeater))
            {
                ucCharacterRepeater ucGenerator = (ucCharacterRepeater)panelControl;
                if (!ucGenerator.FieldsValid())
                {
                    return;
                }

                CharacterRepeater characterRepeater = ucGenerator.GetGenerator();
                foreach (ListViewItem item in listViewGenerators.Items)
                {
                    if (characterRepeater.Name == item.Text)
                    {
                        MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK);
                        return;
                    }
                }

                if (GeneratorIndex == -1)
                {
                    Generators.Add((IGenerator)characterRepeater);
                }
                else
                {
                    Generators.Insert(GeneratorIndex, (IGenerator)characterRepeater);
                }
                Item.Text = characterRepeater.Name;
                Item.SubItems.Add("Character Repeater Generator");
                Item.SubItems.Add(
                    "Inc: " + characterRepeater.Increment.ToString() +
                    ", Init: " + characterRepeater.InitialCount.ToString() +
                    ", Final: " + characterRepeater.FinalCount.ToString() +
                    ", Enc: " + characterRepeater.Encoding.ToString()
                    );
            }
            else if (panelType == typeof(ucFileGenerator))
            {
                ucFileGenerator ucGenerator = (ucFileGenerator)panelControl;
                if (!ucGenerator.FieldsValid())
                {
                    return;
                }

                FileGenerator fileGenerator = ucGenerator.GetGenerator();
                foreach (ListViewItem item in listViewGenerators.Items)
                {
                    if (fileGenerator.Name == item.Text)
                    {
                        MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK);
                        return;
                    }
                }

                if (GeneratorIndex == -1)
                {
                    Generators.Add((IGenerator)fileGenerator);
                }
                else
                {
                    Generators.Insert(GeneratorIndex, (IGenerator)fileGenerator);
                }
                Item.Text = fileGenerator.Name;
                Item.SubItems.Add("File Generator");
                Item.SubItems.Add(
                    "File: " + fileGenerator.FilePath.ToString() +
                    ", Enc: " + fileGenerator.Encoding.ToString()
                    );
            }
            else if (panelType == typeof(ucNumberGenerator))
            {
                ucNumberGenerator ucGenerator = (ucNumberGenerator)panelControl;
                if (!ucGenerator.FieldsValid())
                {
                    return;
                }

                NumberGenerator numberGenerator = ucGenerator.GetGenerator();
                foreach (ListViewItem item in listViewGenerators.Items)
                {
                    if (numberGenerator.Name == item.Text)
                    {
                        MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK);
                        return;
                    }
                }

                if (GeneratorIndex == -1)
                {
                    Generators.Add((IGenerator)numberGenerator);
                }
                else
                {
                    Generators.Insert(GeneratorIndex, (IGenerator)numberGenerator);
                }
                Item.Text = numberGenerator.Name;
                Item.SubItems.Add("Number Generator");
                Item.SubItems.Add(
                    "Inc: " + numberGenerator.Increment.ToString() +
                    ", Start: " + numberGenerator.StartNumber.ToString() +
                    ", Stop: " + numberGenerator.StopNumber.ToString() +
                    ", Enc: " + numberGenerator.Encoding.ToString()
                    );
            }
            else if (panelType == typeof(ucRandomStringGenerator))
            {
                ucRandomStringGenerator ucGenerator = (ucRandomStringGenerator)panelControl;
                if (!ucGenerator.FieldsValid())
                {
                    return;
                }

                RandomStringGenerator randomStringGenerator = ucGenerator.GetGenerator();
                foreach (ListViewItem item in listViewGenerators.Items)
                {
                    if (randomStringGenerator.Name == item.Text)
                    {
                        MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK);
                        return;
                    }
                }

                if (GeneratorIndex == -1)
                {
                    Generators.Add((IGenerator)randomStringGenerator);
                }
                else
                {
                    Generators.Insert(GeneratorIndex, (IGenerator)randomStringGenerator);
                }
                Item.Text = randomStringGenerator.Name;
                Item.SubItems.Add("Random String Generator");
                Item.SubItems.Add(
                    "Rep: " + randomStringGenerator.AllowRepetitions.ToString() +
                    ", Chars: " + randomStringGenerator.CharacterSet +
                    ", MaxStrings: " + randomStringGenerator.MaximumStrings.ToString() +
                    ", StrLength: " + randomStringGenerator.StringLength.ToString() +
                    ", Enc: " + randomStringGenerator.Encoding.ToString()
                    );
            }
            else if (panelType == typeof(ucStringGenerator))
            {
                ucStringGenerator ucGenerator = (ucStringGenerator)panelControl;
                if (!ucGenerator.FieldsValid())
                {
                    return;
                }

                StringGenerator stringGenerator = ucGenerator.GetGenerator();
                foreach (ListViewItem item in listViewGenerators.Items)
                {
                    if (stringGenerator.Name == item.Text)
                    {
                        MessageBox.Show("This generator name already exists. Please choose another.", "Name taken", MessageBoxButtons.OK);
                        return;
                    }
                }

                if (GeneratorIndex == -1)
                {
                    Generators.Add((IGenerator)stringGenerator);
                }
                else
                {
                    Generators.Insert(GeneratorIndex, (IGenerator)stringGenerator);
                }
                Item.Text = stringGenerator.Name;
                Item.SubItems.Add("String Generator");
                Item.SubItems.Add(
                    "Rep: " + stringGenerator.AllowRepetitions.ToString() +
                    ", Chars: " + stringGenerator.CharacterSet +
                    ", StrLength: " + stringGenerator.StringLength.ToString() +
                    ", Enc: " + stringGenerator.Encoding.ToString()
                    );
            }

            if (GeneratorIndex == -1)
            {
                listViewGenerators.Items.Add(Item);
            }
            else
            {
                listViewGenerators.Items.Insert(GeneratorIndex, Item);
            }
        }