void SetLanguages(ReadOnlyLanguagePairCollection collection) { languages = new LanguagePairCollection(); languages.AddRange(collection); languages.Sort(); LoadLanguages(); }
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; }
public override ReadOnlyLanguagePairCollection GetLanguagePairs() { PrepareProcessing(); LanguagePairCollection result = new LanguagePairCollection(); int index; foreach (ServiceItemData sid in services) { if (Subjects.BinarySearch(sid.Subject) >= 0) { index = result.BinarySearch(sid.LanguagePair); if (index < 0) { result.Insert(~index, sid.LanguagePair); } } } return(new ReadOnlyLanguagePairCollection(result)); }
public override ReadOnlyLanguagePairCollection GetLanguagePairs() { PrepareProcessing(); LanguagePairCollection result = new LanguagePairCollection(); int index; foreach (ServiceItem item in Manager.ServiceItems) { foreach (string subject in item.SupportedSubjects) { if (Subjects.BinarySearch(subject) >= 0) { foreach (LanguagePair lp in item.SupportedTranslations) { if (disabledSourceLanguages.BinarySearch(lp.From) >= 0) { continue; } if (disabledTargetLanguages.BinarySearch(lp.To) >= 0) { continue; } index = result.BinarySearch(lp); if (index < 0) { result.Insert(~index, lp); } } } } } return(new ReadOnlyLanguagePairCollection(result)); }
void AFilterLanguagesExecute(object sender, EventArgs e) { DefaultTranslateProfile pf = currentProfile as DefaultTranslateProfile; if(pf == null) return; pf.DisabledLanguagesAlreadySet = true; 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); languageSelector.Profile = currentProfile; } form.Dispose(); }
void LbSubjectsItemCheck(object sender, ItemCheckEventArgs e) { if(loadingSubjects) return; if(e.Index == 0) { try { ignoreServicesLoading = true; loadingSubjects = true; LockUpdate(true); if(e.NewValue == CheckState.Checked) { //all subjects.Clear(); subjects.AddRange(supportedSubjects); for(int i = 1; i < lbSubjects.Items.Count; i++) lbSubjects.SetItemCheckState(i, e.NewValue); } else if(e.NewValue == CheckState.Unchecked) { subjects.Clear(); subjects.Add((lbSubjects.Items[1] as SubjectContainer).Subject); lbSubjects.SetItemCheckState(1, CheckState.Checked); for(int i = 2; i < lbSubjects.Items.Count; i++) lbSubjects.SetItemCheckState(i, e.NewValue); } SetLanguages(profile.GetLanguagePairs()); LanguagePairCollection to_delete = new LanguagePairCollection(); int index; foreach(LanguagePair lp in history) { index = Languages.BinarySearch(lp); if(index < 0) { to_delete.Add(lp); } } foreach(LanguagePair lp in to_delete) { history.Remove(lp); } LoadHistory(); } finally { LockUpdate(false); ignoreServicesLoading = false; loadingSubjects = false; serviceItemsSettings = null; //reset LoadServices(false); } if(SubjectsChanged != null) SubjectsChanged(this, new EventArgs()); return; } SubjectContainer sc = (SubjectContainer)lbSubjects.Items[e.Index]; if(e.NewValue == CheckState.Checked) subjects.Add(sc.Subject); else if(e.NewValue == CheckState.Unchecked) { if(subjects.Count == 1) { int new_idx = e.Index; new_idx ++; if(new_idx >= lbSubjects.Items.Count) { new_idx = 1; } lbSubjects.SetItemChecked(new_idx, true); } subjects.Remove(sc.Subject); } try { ignoreServicesLoading = true; SetLanguages(profile.GetLanguagePairs()); LanguagePairCollection to_delete = new LanguagePairCollection(); int index; foreach(LanguagePair lp in history) { index = Languages.BinarySearch(lp); if(index < 0) { to_delete.Add(lp); } } foreach(LanguagePair lp in to_delete) { history.Remove(lp); } LoadHistory(); } finally { ignoreServicesLoading = false; serviceItemsSettings = null; //reset LoadServices(false); } if(SubjectsChanged != null) SubjectsChanged(this, new EventArgs()); }
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; }
void LbSubjectsItemCheck(object sender, ItemCheckEventArgs e) { if (loadingSubjects) { return; } if (e.Index == 0) { try { ignoreServicesLoading = true; loadingSubjects = true; LockUpdate(true); if (e.NewValue == CheckState.Checked) { //all subjects.Clear(); subjects.AddRange(supportedSubjects); for (int i = 1; i < lbSubjects.Items.Count; i++) { lbSubjects.SetItemCheckState(i, e.NewValue); } } else if (e.NewValue == CheckState.Unchecked) { subjects.Clear(); subjects.Add((lbSubjects.Items[1] as SubjectContainer).Subject); lbSubjects.SetItemCheckState(1, CheckState.Checked); for (int i = 2; i < lbSubjects.Items.Count; i++) { lbSubjects.SetItemCheckState(i, e.NewValue); } } SetLanguages(profile.GetLanguagePairs()); LanguagePairCollection to_delete = new LanguagePairCollection(); int index; foreach (LanguagePair lp in history) { index = Languages.BinarySearch(lp); if (index < 0) { to_delete.Add(lp); } } foreach (LanguagePair lp in to_delete) { history.Remove(lp); } LoadHistory(); } finally { LockUpdate(false); ignoreServicesLoading = false; loadingSubjects = false; serviceItemsSettings = null; //reset LoadServices(false); } if (SubjectsChanged != null) { SubjectsChanged(this, new EventArgs()); } return; } SubjectContainer sc = (SubjectContainer)lbSubjects.Items[e.Index]; if (e.NewValue == CheckState.Checked) { subjects.Add(sc.Subject); } else if (e.NewValue == CheckState.Unchecked) { if (subjects.Count == 1) { int new_idx = e.Index; new_idx++; if (new_idx >= lbSubjects.Items.Count) { new_idx = 1; } lbSubjects.SetItemChecked(new_idx, true); } subjects.Remove(sc.Subject); } try { ignoreServicesLoading = true; SetLanguages(profile.GetLanguagePairs()); LanguagePairCollection to_delete = new LanguagePairCollection(); int index; foreach (LanguagePair lp in history) { index = Languages.BinarySearch(lp); if (index < 0) { to_delete.Add(lp); } } foreach (LanguagePair lp in to_delete) { history.Remove(lp); } LoadHistory(); } finally { ignoreServicesLoading = false; serviceItemsSettings = null; //reset LoadServices(false); } if (SubjectsChanged != null) { SubjectsChanged(this, new EventArgs()); } }
public override ReadOnlyLanguagePairCollection GetLanguagePairs() { PrepareProcessing(); LanguagePairCollection result = new LanguagePairCollection(); int index; foreach(ServiceItem item in Manager.ServiceItems) { foreach(string subject in item.SupportedSubjects) { if(Subjects.BinarySearch(subject) >= 0) { foreach(LanguagePair lp in item.SupportedTranslations) { if(disabledSourceLanguages.BinarySearch(lp.From) >= 0) continue; if(disabledTargetLanguages.BinarySearch(lp.To) >= 0) continue; index = result.BinarySearch(lp); if(index < 0) { result.Insert(~index,lp); } } } } } return new ReadOnlyLanguagePairCollection(result); }