void LoadLanguages() { SuspendLayout(); lbFrom.Items.Clear(); lbTo.Items.Clear(); LanguageCollection fromLangs = new LanguageCollection(); LanguageCollection toLangs = new LanguageCollection(); foreach (LanguagePair lp in Manager.LanguagePairServiceItems.Keys) { if (!fromLangs.Contains(lp.From)) { fromLangs.Add(lp.From); } if (!toLangs.Contains(lp.To)) { toLangs.Add(lp.To); } } fromLangs.Sort(); string val = ""; int idx; val = "+" + TranslateString("Toggle all"); lbFrom.Items.Add(new LanguageDataContainer(Language.Any, val)); foreach (Language l in fromLangs) { val = LangPack.TranslateLanguage(l); idx = lbFrom.Items.Add(new LanguageDataContainer(l, val)); lbFrom.SetItemChecked(idx, !profile.DisabledSourceLanguages.Contains(l)); } lbFrom.SetItemChecked(0, lbFrom.CheckedItems.Count == fromLangs.Count); if (lbFrom.Items.Count > 0) { lbFrom.SelectedIndex = 0; } toLangs.Sort(); val = "+" + TranslateString("Toggle all"); lbTo.Items.Add(new LanguageDataContainer(Language.Any, val)); foreach (Language l in toLangs) { val = LangPack.TranslateLanguage(l); idx = lbTo.Items.Add(new LanguageDataContainer(l, val)); lbTo.SetItemChecked(idx, !profile.DisabledTargetLanguages.Contains(l)); } lbTo.SetItemChecked(0, lbTo.CheckedItems.Count == toLangs.Count); if (lbTo.Items.Count > 0) { lbTo.SelectedIndex = 0; } ResumeLayout(true); }
void PrepareProcessing() { Subjects.Sort(); disabledSourceLanguages.Sort(); disabledTargetLanguages.Sort(); }