void LoadSubjects() { lbSubjects.BeginUpdate(); loadingSubjects = true; lbSubjects.Items.Clear(); string val; val = "+ " + LangPack.TranslateString("Toggle all"); lbSubjects.Items.Add(new SubjectContainer("Toggle all", val)); foreach (string s in supportedSubjects) { val = LangPack.TranslateString(s); if (s == "Common") { val = "+" + val; } lbSubjects.Items.Add(new SubjectContainer(s, val), subjects.Contains(s)); } lbSubjects.EndUpdate(); lbSubjects.SetItemChecked(0, lbSubjects.CheckedItems.Count == supportedSubjects.Count); loadingSubjects = false; serviceItemsSettings = null; //reset LoadServices(false); }
void BLanguageFilterClick(object sender, EventArgs e) { DefaultTranslateProfile pf = defaultProfile; DefaultProfileLanguagesForm form = new DefaultProfileLanguagesForm(pf); if (form.ShowDialog(this) == DialogResult.OK) { SubjectCollection subjects = pf.GetSupportedSubjects(); SubjectCollection subjectsToDelete = new SubjectCollection(); foreach (string subject in pf.Subjects) { if (!subjects.Contains(subject)) { subjectsToDelete.Add(subject); } } foreach (string subject in subjectsToDelete) { pf.Subjects.Remove(subject); } LanguagePairCollection toDelete = new LanguagePairCollection(); foreach (LanguagePair lp in pf.History) { if (pf.DisabledSourceLanguages.Contains(lp.From) || pf.DisabledTargetLanguages.Contains(lp.To)) { toDelete.Add(lp); } } foreach (LanguagePair lp in toDelete) { pf.History.Remove(lp); } } form.Dispose(); changed = true; }