Ejemplo n.º 1
0
        private void OnToolsSettings(object sender, EventArgs e)
        {
            SettingsDialog dlg = new SettingsDialog();

            dlg.m_tbLanguageName.Text     = _language.Name;
            dlg.m_udNumberOfPhrases.Value = (int)this._nudNumberOfPhrases.Value;

            SetIntegerData(_language.WordLengthDistribution, dlg.m_dgvWordLength);
            SetIntegerData(_language.PhraseLengthDistribution, dlg.m_dgvPhraseLength);

            SetStringData(_language.Vowels, dlg.m_dgvVowels);
            SetStringData(_language.Consonants, dlg.m_dgvConsonants);
            SetSyllableTypeData(_language.Syllables, dlg.m_dgvSyllableTypes);
            SetStringData(_language.InnerPunctuation, dlg.m_dgvInnerPunctuation);
            SetStringData(_language.FinalPunctuation, dlg.m_dgvFinalPunctuation);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                _language.Name = dlg.m_tbLanguageName.Text;

                this._nudNumberOfPhrases.Value = (int)dlg.m_udNumberOfPhrases.Value;

                GetIntegerData(dlg.m_dgvWordLength, _language.WordLengthDistribution);
                GetIntegerData(dlg.m_dgvPhraseLength, _language.PhraseLengthDistribution);

                GetStringData(dlg.m_dgvVowels, _language.Vowels);
                GetStringData(dlg.m_dgvConsonants, _language.Consonants);
                GetSyllableTypeData(dlg.m_dgvSyllableTypes, _language.Syllables);
                GetStringData(dlg.m_dgvInnerPunctuation, _language.InnerPunctuation);
                GetStringData(dlg.m_dgvFinalPunctuation, _language.FinalPunctuation);

                _language.UpdateRandomizers();
            }
        }
        public PasswordGeneratorDialog(bool bUseOwnLanguage, AleaForm form)
        {
            InitializeComponent();

            _useOwnLanguage = bUseOwnLanguage;
            _aleaForm       = form;

            if (_aleaForm != null)
            {
                _language = _aleaForm._language;
            }

            if (!_useOwnLanguage)
            {
                return;
            }

            _language.Consonants = new Dictionary <string, double>
            {
                { "b", 1 },
                { "d", 1 },
                { "f", 3 },
                { "g", 2 },
                { "h", 3 },
                { "k", 2 },
                { "l", 5 },
                { "m", 8 },
                { "n", 8 },
                { "p", 5 },
                { "r", 8 },
                { "s", 10 },
                { "t", 5 },
                { "v", 3 },
                { "z", 1 }
            };

            _language.Vowels = new Dictionary <string, double>
            {
                { "a", 5 },
                { "e", 10 },
                { "i", 5 },
                { "o", 8 },
                { "u", 1 },
            };

            _language.Syllables = new Dictionary <SyllabicType, double>
            {
                { SyllabicType.CV, 5 },
                { SyllabicType.VC, 5 },
                { SyllabicType.V, 1 }
            };

            _language.InnerPunctuation = new Dictionary <string, double>
            {
                { " ", 1 }
            };

            _language.FinalPunctuation = new Dictionary <string, double>
            {
                { " ", 1 }
            };

            _language.WordLengthDistribution = new Dictionary <int, double>
            {
                { 4, 1 }
            };

            _language.UpdateRandomizers(false);
        }