public EditDictionaryItem(IDictionarySection dictionary, string phraseLanguage, string translationLanguage, Entry entry = null) { InitializeComponent(); this.dictionary = dictionary; this.entry = entry; if (!string.IsNullOrEmpty(phraseLanguage)) phraseLabel.Text = phraseLanguage + ":"; if (!string.IsNullOrEmpty(translationLanguage)) translationsLabel.Text = translationLanguage + ":"; if (Adding) { this.Text = Properties.Resources.AddDictionaryItem; complete.Text = Properties.Resources.Add; } else { this.Text = Properties.Resources.EditDictionaryItem; complete.Text = Properties.Resources.Save; } if (entry != null) { phrase.Text = entry.Phrase; foreach (var t in entry.Translations) { translations.Items.Add(new ListViewItem(new string[] { t.Value })); } } ThemeHelper.UseExplorerTheme(translations); translations.Resize += delegate { AutoSizeColumns(); }; AutoSizeColumns(); }
public EditDictionaryItem(IDictionarySection dictionary, string phraseLanguage, string translationLanguage, Entry entry = null) { InitializeComponent(); this.dictionary = dictionary; this.entry = entry; if (!string.IsNullOrEmpty(phraseLanguage)) { phraseLabel.Text = phraseLanguage + ":"; } if (!string.IsNullOrEmpty(translationLanguage)) { translationsLabel.Text = translationLanguage + ":"; } if (Adding) { this.Text = Properties.Resources.AddDictionaryItem; complete.Text = Properties.Resources.Add; } else { this.Text = Properties.Resources.EditDictionaryItem; complete.Text = Properties.Resources.Save; } if (entry != null) { phrase.Text = entry.Phrase; foreach (var t in entry.Translations) { translations.Items.Add(new ListViewItem(new string[] { t.Value })); } } ThemeHelper.UseExplorerTheme(translations); translations.Resize += delegate { AutoSizeColumns(); }; AutoSizeColumns(); }
protected SimpleDictionary.Section GenerateSecondHalf(IDictionarySection firstSection) { Dictionary <string, List <string> > entries = new Dictionary <string, List <string> >(); StringPool pool = new StringPool(); // Normalize all translations (and entries, for good measure). // Also, pool them so that the "Contains" method of the List<string> works. foreach (Entry entry in firstSection) { entry.Phrase = pool.Pool(entry.Phrase.Normalize()); foreach (Translation t in entry.Translations) { t.Value = pool.Pool(t.Value.Normalize()); } } // Perform the actual reversion. foreach (Entry entry in firstSection) { foreach (Translation t in entry.Translations) { List <string> reverse; if (entries.TryGetValue(t.Value, out reverse)) { if (!reverse.Contains(entry.Phrase)) { reverse.Add(entry.Phrase); } } else { reverse = new List <string>(); entries.Add(t.Value, reverse); if (!reverse.Contains(entry.Phrase)) { reverse.Add(entry.Phrase); } } } } // Convert it into a list. List <Entry> list = new List <Entry>(); foreach (KeyValuePair <string, List <string> > kv in entries) { var translations = new List <Translation>(); Entry e = new Entry(kv.Key, translations); foreach (string t in kv.Value) { translations.Add(new Translation(t)); } // Sort the list of translations in each entry. translations.Sort((a, b) => a.Value.CompareTo(b.Value)); list.Add(e); } // Sort the list of entries. list.Sort((a, b) => (a.Phrase.CompareTo(b.Phrase))); SimpleDictionary.Section section = new SimpleDictionary.Section(list, true, null); foreach (var e in list) { e.Tag = new EntryTag(section, null); } return(section); }
public EntryTag(IDictionarySection section, object data) { DictionarySection = section; Data = data; }