Пример #1
0
        // save character layout to dictionary
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (ld.FindChar(txtNewCharacter.Text[0]))  // check if it already exists
            {
                if (MessageBox.Show("Replace existing char?", "Add character", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No)
                {
                    return;
                }
            }

            // add to dictionary
            ld.AddChar(txtNewCharacter.Text[0], bits);

            // write definitions to file
            ld.WriteCharDef();

            // renew combobox list
            cbSelectCharacter.Items.Clear();
            cbSelectCharacter.Items.AddRange(ld.GetKeys().ToArray());
            cbSelectCharacter.SelectedIndex = cbSelectCharacter.Items.Count - 1; // jump to the last inserted
            txtNewCharacter.Text            = cbSelectCharacter.SelectedItem.ToString();

            // update number of characters in dictionary
            lblNoOfChars.Text = "no. of chars " + cbSelectCharacter.Items.Count.ToString();
        }