void CbFromSelectedIndexChanged(object sender, EventArgs e) { if (!initialized) { return; } bool generatedName = tbName.Text == GetNewProfileName(); LanguageDataContainer ld = cbFrom.SelectedItem as LanguageDataContainer; profile.TranslationDirection.From = ld.Language; ld = cbTo.SelectedItem as LanguageDataContainer; profile.TranslationDirection.To = ld.Language; SubjectContainer sc = cbSubject.SelectedItem as SubjectContainer; profile.Subject = sc.Subject; if (generatedName) { tbName.Text = GetNewProfileName(); } }
void CbSubjectSelectedIndexChanged(object sender, EventArgs e) { if (ignoreLanguageChange) { return; } if (lvProfiles.SelectedItems.Count != 1) { return; } ListViewItem lvi = lvProfiles.SelectedItems[0]; UserTranslateProfile pf = lvi.Tag as UserTranslateProfile; if (pf == null) { return; } SubjectContainer sc = cbSubject.SelectedItem as SubjectContainer; pf.Subject = sc.Subject; lvi.SubItems[2].Text = LangPack.TranslateString(sc.Subject); }
void InitUserProfileControls() { cbFrom.Items.Clear(); cbTo.Items.Clear(); for (int i = 0; i < (int)Language.Last; i++) { LanguageDataContainer ld = new LanguageDataContainer((Language)i, LangPack.TranslateLanguage((Language)i)); cbFrom.Items.Add(ld); cbTo.Items.Add(ld); } cbSubject.Items.Clear(); foreach (string subject in Manager.Subjects) { SubjectContainer sc = new SubjectContainer(subject, LangPack.TranslateString(subject)); cbSubject.Items.Add(sc); } SubjectContainer sc1 = new SubjectContainer(SubjectConstants.Any, LangPack.TranslateString(SubjectConstants.Any)); cbSubject.Items.Add(sc1); changed = false; LvProfilesSelectedIndexChanged(lvProfiles, new EventArgs()); }
public CustomProfileServicesForm(UserTranslateProfile profile) { InitializeComponent(); RegisterLanguageEvent(OnLanguageChanged); this.profile = profile; ServiceItemsDataCollection services = new ServiceItemsDataCollection(); foreach(ServiceItemData sid in profile.Services) services.Add(sid); lvCurrent.Services = services; cbFrom.Items.Clear(); cbTo.Items.Clear(); for(int i = 0; i < (int)Language.Last; i++) { LanguageDataContainer ld = new LanguageDataContainer((Language)i, LangPack.TranslateLanguage((Language)i)); cbFrom.Items.Add(ld); cbTo.Items.Add(ld); } cbFrom.SelectedIndex = 0; cbTo.SelectedIndex = 0; //cbSubject foreach(string subject in Manager.Subjects) { SubjectContainer sc = new SubjectContainer(subject, LangPack.TranslateString(subject)); cbSubject.Items.Add(sc); } SubjectContainer sc1 = new SubjectContainer(SubjectConstants.Any, "+" + LangPack.TranslateString(SubjectConstants.Any)); cbSubject.Items.Add(sc1); cbSubject.SelectedIndex = 0; for(int i = 0; i < cbFrom.Items.Count; i++) { LanguageDataContainer ld = cbFrom.Items[i] as LanguageDataContainer; if(ld.Language == profile.TranslationDirection.From) cbFrom.SelectedItem = ld; if(ld.Language == profile.TranslationDirection.To) cbTo.SelectedItem = ld; } for(int i = 0; i < cbSubject.Items.Count; i++) { SubjectContainer sc = cbSubject.Items[i] as SubjectContainer; if(profile.Subject == sc.Subject) { cbSubject.SelectedItem = sc; break; } } serviceStatusSource.Visible = false; serviceStatusCurrent.Visible = false; initialized = true; CbFromSelectedIndexChanged(null, new EventArgs()); }
void InitUserProfileControls() { cbFrom.Items.Clear(); cbTo.Items.Clear(); for(int i = 0; i < (int)Language.Last; i++) { LanguageDataContainer ld = new LanguageDataContainer((Language)i, LangPack.TranslateLanguage((Language)i)); cbFrom.Items.Add(ld); cbTo.Items.Add(ld); } cbSubject.Items.Clear(); foreach(string subject in Manager.Subjects) { SubjectContainer sc = new SubjectContainer(subject, LangPack.TranslateString(subject)); cbSubject.Items.Add(sc); } SubjectContainer sc1 = new SubjectContainer(SubjectConstants.Any, LangPack.TranslateString(SubjectConstants.Any)); cbSubject.Items.Add(sc1); changed = false; LvProfilesSelectedIndexChanged(lvProfiles, new EventArgs()); }
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 SetProfileNameForm(UserTranslateProfile profile, TranslateProfilesCollection profiles) { InitializeComponent(); RegisterLanguageEvent(OnLanguageChanged); this.profile = profile; this.profiles = profiles; cbFrom.Items.Clear(); cbTo.Items.Clear(); for (int i = 0; i < (int)Language.Last; i++) { LanguageDataContainer ld = new LanguageDataContainer((Language)i, LangPack.TranslateLanguage((Language)i)); cbFrom.Items.Add(ld); cbTo.Items.Add(ld); } cbFrom.SelectedIndex = 0; cbTo.SelectedIndex = 0; foreach (string subject in Manager.Subjects) { SubjectContainer sc = new SubjectContainer(subject, LangPack.TranslateString(subject)); cbSubject.Items.Add(sc); } SubjectContainer sc1 = new SubjectContainer(SubjectConstants.Any, LangPack.TranslateString(SubjectConstants.Any)); cbSubject.Items.Add(sc1); cbSubject.SelectedIndex = 0; for (int i = 0; i < cbFrom.Items.Count; i++) { LanguageDataContainer ld = cbFrom.Items[i] as LanguageDataContainer; if (ld.Language == profile.TranslationDirection.From) { cbFrom.SelectedItem = ld; } if (ld.Language == profile.TranslationDirection.To) { cbTo.SelectedItem = ld; } } for (int i = 0; i < cbSubject.Items.Count; i++) { SubjectContainer sc = cbSubject.Items[i] as SubjectContainer; if (profile.Subject == sc.Subject) { cbSubject.SelectedItem = sc; break; } } if (!string.IsNullOrEmpty(profile.Name)) { tbName.Text = profile.Name; } else { tbName.Text = GetNewProfileName(); } initialized = true; }
public CustomProfileServicesForm(UserTranslateProfile profile) { InitializeComponent(); RegisterLanguageEvent(OnLanguageChanged); this.profile = profile; ServiceItemsDataCollection services = new ServiceItemsDataCollection(); foreach (ServiceItemData sid in profile.Services) { services.Add(sid); } lvCurrent.Services = services; cbFrom.Items.Clear(); cbTo.Items.Clear(); for (int i = 0; i < (int)Language.Last; i++) { LanguageDataContainer ld = new LanguageDataContainer((Language)i, LangPack.TranslateLanguage((Language)i)); cbFrom.Items.Add(ld); cbTo.Items.Add(ld); } cbFrom.SelectedIndex = 0; cbTo.SelectedIndex = 0; //cbSubject foreach (string subject in Manager.Subjects) { SubjectContainer sc = new SubjectContainer(subject, LangPack.TranslateString(subject)); cbSubject.Items.Add(sc); } SubjectContainer sc1 = new SubjectContainer(SubjectConstants.Any, "+" + LangPack.TranslateString(SubjectConstants.Any)); cbSubject.Items.Add(sc1); cbSubject.SelectedIndex = 0; for (int i = 0; i < cbFrom.Items.Count; i++) { LanguageDataContainer ld = cbFrom.Items[i] as LanguageDataContainer; if (ld.Language == profile.TranslationDirection.From) { cbFrom.SelectedItem = ld; } if (ld.Language == profile.TranslationDirection.To) { cbTo.SelectedItem = ld; } } for (int i = 0; i < cbSubject.Items.Count; i++) { SubjectContainer sc = cbSubject.Items[i] as SubjectContainer; if (profile.Subject == sc.Subject) { cbSubject.SelectedItem = sc; break; } } serviceStatusSource.Visible = false; serviceStatusCurrent.Visible = false; initialized = true; CbFromSelectedIndexChanged(null, new EventArgs()); }
void LvProfilesSelectedIndexChanged(object sender, EventArgs e) { aEditServices.Enabled = false; if (lvProfiles.SelectedItems.Count == 0) { return; } TranslateProfile pf = lvProfiles.SelectedItems[0].Tag as TranslateProfile; UserTranslateProfile upf = pf as UserTranslateProfile; if (pf == defaultProfile) { if (!tcOptions.TabPages.Contains(tpDefaultOptions)) { tcOptions.TabPages.Add(tpDefaultOptions); } tcOptions.TabPages.Remove(tpOptions); tcOptions.TabPages.Remove(tpServices); tcOptions.TabPages.Remove(tpLanguageSelector); } else if (upf != null) { if (!tcOptions.TabPages.Contains(tpServices)) { tcOptions.TabPages.Add(tpServices); } if (!tcOptions.TabPages.Contains(tpOptions)) { tcOptions.TabPages.Add(tpOptions); } if (!tcOptions.TabPages.Contains(tpLanguageSelector)) { tcOptions.TabPages.Add(tpLanguageSelector); } tcOptions.TabPages.Remove(tpDefaultOptions); lProfileName.Text = pf.Name; lvServices.Services = upf.Services; } aEditServices.Enabled = pf != defaultProfile; if (upf != null) { ignoreLanguageChange = true; for (int i = 0; i < cbFrom.Items.Count; i++) { LanguageDataContainer ld = cbFrom.Items[i] as LanguageDataContainer; if (ld.Language == upf.TranslationDirection.From) { cbFrom.SelectedItem = ld; } if (ld.Language == upf.TranslationDirection.To) { cbTo.SelectedItem = ld; } } for (int i = 0; i < cbSubject.Items.Count; i++) { SubjectContainer sc = cbSubject.Items[i] as SubjectContainer; if (upf.Subject == sc.Subject) { cbSubject.SelectedItem = sc; break; } } cbShowServices.Checked = upf.ShowServices; cbShowSubjects.Checked = upf.ShowSubjects; cbShowLanguages.Checked = upf.ShowLanguages; ignoreLanguageChange = false; } }
public SetProfileNameForm(UserTranslateProfile profile, TranslateProfilesCollection profiles) { InitializeComponent(); RegisterLanguageEvent(OnLanguageChanged); this.profile = profile; this.profiles = profiles; cbFrom.Items.Clear(); cbTo.Items.Clear(); for(int i = 0; i < (int)Language.Last; i++) { LanguageDataContainer ld = new LanguageDataContainer((Language)i, LangPack.TranslateLanguage((Language)i)); cbFrom.Items.Add(ld); cbTo.Items.Add(ld); } cbFrom.SelectedIndex = 0; cbTo.SelectedIndex = 0; foreach(string subject in Manager.Subjects) { SubjectContainer sc = new SubjectContainer(subject, LangPack.TranslateString(subject)); cbSubject.Items.Add(sc); } SubjectContainer sc1 = new SubjectContainer(SubjectConstants.Any, LangPack.TranslateString(SubjectConstants.Any)); cbSubject.Items.Add(sc1); cbSubject.SelectedIndex = 0; for(int i = 0; i < cbFrom.Items.Count; i++) { LanguageDataContainer ld = cbFrom.Items[i] as LanguageDataContainer; if(ld.Language == profile.TranslationDirection.From) cbFrom.SelectedItem = ld; if(ld.Language == profile.TranslationDirection.To) cbTo.SelectedItem = ld; } for(int i = 0; i < cbSubject.Items.Count; i++) { SubjectContainer sc = cbSubject.Items[i] as SubjectContainer; if(profile.Subject == sc.Subject) { cbSubject.SelectedItem = sc; break; } } if(!string.IsNullOrEmpty(profile.Name)) { tbName.Text = profile.Name; } else { tbName.Text = GetNewProfileName(); } initialized = true; }