Esempio n. 1
0
 private void AddNewWordToList(TextParserWord word)
 {
     _parser.Words.Add(word);
     int addAtIndex = 0;
     if (lvwWords.SelectedIndices.Count > 0)
     {
         addAtIndex = lvwWords.SelectedIndices[0] + 1;
     }
     ListViewItem addedItem = lvwWords.Items.Insert(addAtIndex, CreateListItemFromWord(word));
     addedItem.Selected = true;
     addedItem.EnsureVisible();
     EditSelectedWord();
 }
Esempio n. 2
0
 private void ContextMenuEventHandler(object sender, EventArgs e)
 {
     ToolStripMenuItem item = (ToolStripMenuItem)sender;
     TextParserWord selectedWord = null;
     if (lvwWords.SelectedItems.Count > 0)
     {
         selectedWord = ((TextParserWord)lvwWords.SelectedItems[0].Tag);
     }
     if (item.Name == MENU_ITEM_EDIT_WORD)
     {
         EditSelectedWord();
     }
     else if (item.Name == MENU_ITEM_ADD_SYNONYM)
     {
         TextParserWord word = new TextParserWord(selectedWord.WordGroup, "", selectedWord.Type);
         AddNewWordToList(word);
     }
     else if (item.Name == MENU_ITEM_ADD_WORD)
     {
         TextParserWord word = new TextParserWord(_parser.GetAvailableWordGroupID(), "", TextParserWordType.Normal);
         AddNewWordToList(word);
     }
     else if (item.Name == MENU_ITEM_DELETE_WORD)
     {
         lvwWords.Items.RemoveAt(lvwWords.SelectedIndices[0]);
         _parser.Words.Remove(selectedWord);
     }
     else if (item.Name == MENU_ITEM_FIND_WORD)
     {
         string searchFor = TextEntryDialog.Show("Find word", "Type the word that you want to find into the list below.", "");
         if (searchFor != null)
         {
             searchFor = searchFor.ToLower();
             bool found = false;
             foreach (ListViewItem listItem in lvwWords.Items)
             {
                 if (listItem.SubItems[SUB_ITEM_INDEX_WORD_TEXT].Text.ToLower() == searchFor)
                 {
                     listItem.Selected = true;
                     listItem.EnsureVisible();
                     found = true;
                     break;
                 }
             }
             if (!found)
             {
                 Factory.GUIController.ShowMessage("The word '" + searchFor + "' could not be found.", MessageBoxIcon.Information);
             }
         }
     }
 }
Esempio n. 3
0
 private ListViewItem CreateListItemFromWord(TextParserWord word)
 {
     ListViewItem newItem = new ListViewItem(new string[] { word.WordGroup.ToString(), word.Word, word.Type.ToString() });
     newItem.Tag = word;
     return newItem;
 }