コード例 #1
0
        private void btnPick_Click(object sender, RoutedEventArgs e)
        {
            Names.CharacterNames nameGenerator = GetCharacterNameGenerator();

            if (null != nameGenerator)
            {
                if ((true == cbUsePrefix.IsChecked) && (0 < tbPrefix.Text.Length))
                {
                    string findName = nameGenerator.GetRandomName(m_random, tbPrefix.Text);

                    if (null == findName)
                    {
                        lasterror.Text = string.Format("I could not find a name matching '{0}'", tbPrefix.Text);
                    }
                    else
                    {
                        lbPicked.Items.Add(findName);
                    }
                }
                else
                {
                    lbPicked.Items.Add(nameGenerator.GetRandomName(m_random));
                }
            }
        }
コード例 #2
0
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            Names.CharacterNameGenerators nameGenerators = new Names.CharacterNameGenerators();
            Names.CharacterNames          names          = nameGenerators.GetWesternFemaleNameGenerator();
            Random rnd = new Random();

            tbLastError.Text = "Word: " + names.GenerateRandomName(rnd);
        }
コード例 #3
0
        private void btnGenerate_Click(object sender, RoutedEventArgs e)
        {
            Names.CharacterNames nameGenerator = GetCharacterNameGenerator();

            if (null != nameGenerator)
            {
                if ((true == cbUsePrefix.IsChecked) && (0 < tbPrefix.Text.Length))
                {
                    string genName = nameGenerator.GenerateRandomPostfix(m_random, tbPrefix.Text);

                    lbPicked.Items.Add(genName);
                }
                else
                {
                    lbPicked.Items.Add(nameGenerator.GenerateRandomName(m_random));
                }
            }
        }