コード例 #1
0
        private void buttonAddNewSourceWord_Click(object sender, EventArgs e)
        {
            var dlg = new AddNewSourceWordForm
            {
                Font      = textBoxFilter.Font,
                WordAdded = textBoxFilter.Text
            };

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string strNewSource = dlg.WordAdded.Trim(_achTrimSource);
            string strNewTarget = dlg.WordAdded.Trim(_achTrimTarget);

            _mapOfMaps.AddCouplet(strNewSource, strNewTarget);

            if (!listBoxSourceWordForms.Items.Contains(strNewSource))
            {
                listBoxSourceWordForms.Items.Add(strNewSource);
            }
            listBoxSourceWordForms.SelectedItem = strNewSource;

            SetModified();
        }
コード例 #2
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.Assert(listBoxSourceWordForms.SelectedIndex != -1);
            string strSourceWordToEdit = listBoxSourceWordForms.SelectedItem.ToString();
            var    dlg = new AddNewSourceWordForm
            {
                Font      = textBoxFilter.Font,
                WordAdded = strSourceWordToEdit
            };

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string            strNewWord        = dlg.WordAdded.Trim(_achTrimSource);
            SourceWordElement sourceWordElement = _mapOfMaps.ChangeSourceWord(strSourceWordToEdit, strNewWord);

            // remove it from the lst box and then add it back (since it might now go in a different map)
            RemoveFromForm(strSourceWordToEdit);

            if (sourceWordElement != null)
            {
                if (!listBoxSourceWordForms.Items.Contains(sourceWordElement.SourceWord))
                {
                    listBoxSourceWordForms.Items.Add(sourceWordElement.SourceWord);
                }
                listBoxSourceWordForms.SelectedItem = sourceWordElement.SourceWord;
            }
        }