private void GetOwnerAndWsCode(int ws, out LexRefType lrtOwner, out SpecialWritingSystemCodes wsCode) { lrtOwner = (LexRefType)CmObject.CreateFromDBObject(m_cache, OwnerHVO); wsCode = SpecialWritingSystemCodes.DefaultAnalysis; if (ws < 0) { switch (ws) { case (int)CellarModuleDefns.kwsAnal: wsCode = SpecialWritingSystemCodes.DefaultAnalysis; break; case (int)CellarModuleDefns.kwsVern: wsCode = SpecialWritingSystemCodes.DefaultVernacular; break; default: wsCode = (SpecialWritingSystemCodes)ws; break; } } }
private void btnOK_Click(object sender, EventArgs e) { // See if the 'function' value is a user entered one and is the current selection, if // so then add it to the correct list in the DB. if (lblFunction.Enabled) { string funcText = cbFunction.Text; // add case to handle when the user hasn't entered text or selected any items in the drop down list. if (funcText.Length == 0) { string labelText = lblFunction.Text.TrimEnd(new char[]{' ', ':'}); MessageBox.Show("You must select a '"+labelText+"' item or enter a new one to continue.", "Missing information", MessageBoxButtons.OK, MessageBoxIcon.Stop); cbFunction.Focus(); return; } if (!cbFunction.Items.Contains(funcText)) { // found case where the user has entered their own text and want to add it to the proper list TreeNode tn = tvDestination.SelectedNode; Sfm2Xml.LexImportField field = tn.Tag as Sfm2Xml.LexImportField; if (field != null && field.IsRef) { switch (field.ID) { case "var": LexEntryType let = new LexEntryType(); m_cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Append(let); int iwsUI = m_cache.LanguageWritingSystemFactoryAccessor.UserWs; string wsUI = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(iwsUI); let.Name.UserDefaultWritingSystem = funcText; let.Description.SetUserDefaultWritingSystem("A \"var\" type entered by the user during the import process."); break; case "sub": let = new LexEntryType(); m_cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS.Append(let); iwsUI = m_cache.LanguageWritingSystemFactoryAccessor.UserWs; wsUI = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(iwsUI); let.Name.UserDefaultWritingSystem = funcText; let.Description.SetUserDefaultWritingSystem("A \"sub\" type entered by the user during the import process."); break; case "lxrel": LexRefType lrt = new LexRefType(); m_cache.LangProject.LexDbOA.ReferencesOA.PossibilitiesOS.Append(lrt); iwsUI = m_cache.LanguageWritingSystemFactoryAccessor.UserWs; wsUI = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(iwsUI); lrt.Name.UserDefaultWritingSystem = funcText; lrt.Description.SetUserDefaultWritingSystem("A \"lxrel\" type entered by the user during the import process."); break; } } } } this.DialogResult = DialogResult.OK; }