private void EnableControlsFromField(LexImportField field)
		{
			// see if the abbr controls should be enabled or not
			bool enable = false;
			if (field != null)
				enable = field.IsAbbrField;
			lblAbbr.Enabled = enable;
			rbAbbrName.Enabled = enable;
			rbAbbrAbbr.Enabled = enable;
			// see if the function controls should be enabled
			if (field != null)
				enable = field.IsRef;
			lblFunction.Enabled = enable;
			cbFunction.Enabled = enable;
			if (lblFunction.Enabled == false)
				lblFunction.Text = "Not An Active Field :";
		}
		private void FillLexicalRefTypesCombo(LexImportField field)
		{
			if (m_LastSelectedField == field)
				return;		// don't change
			m_LastSelectedField = field;

			// fill the combo box with current values in the DB
			cbFunction.Items.Clear();
			m_htNameToAbbr.Clear();
			if (field.IsRef)
			{
				lblFunction.Text = LexTextControls.ksLexicalRelationType;
				int pos = -1;
				//string abbr, name, reverseAbbr, reverseName;
				rbAbbrAbbr.Checked = true;
				rbAbbrName.Checked = false;
				if (field.ID == "cref" || field.ID == "scref")
				{
					// Fill the comboBox with the names (and where appropriate, reverse names) of the
					// LexRefType objects which map to entries.
					foreach (ILexRefType lrt in m_cache.LanguageProject.LexDbOA.ReferencesOA.PossibilitiesOS)
					{
						switch (lrt.MappingType)
						{
							case (int)MappingTypes.kmtEntryCollection:
							case (int)MappingTypes.kmtEntryPair:
							case (int)MappingTypes.kmtEntrySequence:
							case (int)MappingTypes.kmtEntryOrSenseCollection:
							case (int)MappingTypes.kmtEntryOrSensePair:
							case (int)MappingTypes.kmtEntryOrSenseSequence:
								//abbr = lrt.Abbreviation.AnalysisDefaultWritingSystem.Text;
								//name = lrt.Name.AnalysisDefaultWritingSystem.Text;
								//AddAbbrAndNameInfo(abbr, name, "en", null, null, null);
								AddAbbrAndNameInfo(lrt.Abbreviation, lrt.Name, null, null);
								break;
							case (int)MappingTypes.kmtEntryAsymmetricPair:
							case (int)MappingTypes.kmtEntryTree:
							case (int)MappingTypes.kmtEntryOrSenseAsymmetricPair:
							case (int)MappingTypes.kmtEntryOrSenseTree:
								//abbr = lrt.Abbreviation.AnalysisDefaultWritingSystem.Text;
								//name = lrt.Name.AnalysisDefaultWritingSystem.Text;
								//reverseAbbr = lrt.ReverseAbbreviation.AnalysisDefaultWritingSystem.Text;
								//reverseName = lrt.ReverseName.AnalysisDefaultWritingSystem.Text;
								//AddAbbrAndNameInfo(abbr, name, "en", reverseAbbr, reverseName, "en");
								AddAbbrAndNameInfo(lrt.Abbreviation, lrt.Name, lrt.ReverseAbbreviation, lrt.ReverseName);
								break;
						}
					}
				}
				else if (field.ID == "lxrel")
				{
					// Fill the comboBox with the names (and where appropriate, reverse names) of the
					// LexRefType objects which map to senses.
					foreach (ILexRefType lrt in m_cache.LanguageProject.LexDbOA.ReferencesOA.PossibilitiesOS)
					{
						switch (lrt.MappingType)
						{
							case (int)MappingTypes.kmtSenseCollection:
							case (int)MappingTypes.kmtSensePair:
							case (int)MappingTypes.kmtSenseSequence:
							case (int)MappingTypes.kmtEntryOrSenseCollection:
							case (int)MappingTypes.kmtEntryOrSensePair:
							case (int)MappingTypes.kmtEntryOrSenseSequence:
								//abbr = lrt.Abbreviation.AnalysisDefaultWritingSystem.Text;
								//name = lrt.Name.AnalysisDefaultWritingSystem.Text;
								//AddAbbrAndNameInfo(abbr, name, "en", null, null, null);
								AddAbbrAndNameInfo(lrt.Abbreviation, lrt.Name, null, null);
								break;
							case (int)MappingTypes.kmtSenseAsymmetricPair:
							case (int)MappingTypes.kmtSenseTree:
							case (int)MappingTypes.kmtEntryOrSenseAsymmetricPair:
							case (int)MappingTypes.kmtEntryOrSenseTree:
								//abbr = lrt.Abbreviation.AnalysisDefaultWritingSystem.Text;
								//name = lrt.Name.AnalysisDefaultWritingSystem.Text;
								//reverseAbbr = lrt.ReverseAbbreviation.AnalysisDefaultWritingSystem.Text;
								//reverseName = lrt.ReverseName.AnalysisDefaultWritingSystem.Text;
								//AddAbbrAndNameInfo(abbr, name, "en", reverseAbbr, reverseName, "en");
								AddAbbrAndNameInfo(lrt.Abbreviation, lrt.Name, lrt.ReverseAbbreviation, lrt.ReverseName);
								break;
						}
					}
				}
				else if (field.ID == "var")
				{
					lblFunction.Text = LexTextControls.ksVariantType;
					// fill the comboBox with the names of the Variant objects
					foreach (var let in m_cache.LangProject.LexDbOA.VariantEntryTypesOA.ReallyReallyAllPossibilities)
					{
						AddAbbrAndNameInfo(let.Abbreviation, let.Name, null, null);
						//int wsActual;
						//ITsString tssAnal = let.Name. GetAlternativeOrBestTss(m_cache.DefaultAnalWs, out wsActual);
						//name = tssAnal.Text;
						//string ws = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(wsActual);
						//AddAbbrAndNameInfo(null, name, ws, null, null, null);
					}
				}
				else if (field.ID == "sub")
				{
					lblFunction.Text = LexTextControls.ksComplexFormType;
					// fill the comboBox with the names of the Variant objects
					foreach (var let in m_cache.LangProject.LexDbOA.ComplexEntryTypesOA.ReallyReallyAllPossibilities)
					{
						AddAbbrAndNameInfo(let.Abbreviation, let.Name, null, null);
						//int wsActual;
						//ITsString tssAnal = let.Name.GetAlternativeOrBestTss(m_cache.DefaultAnalWs, out wsActual);
						//name = tssAnal.Text;
						//string ws = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(wsActual);
						//AddAbbrAndNameInfo(null, name, ws, null, null, null);
					}
				}


				// now select the one with the correct abbreviation
				pos = -1;
				if (m_refFuncString.Length > 0)
					pos = cbFunction.FindString(m_refFuncString);
				if (pos >= 0)
				{
					cbFunction.SelectedIndex = pos;
					cbFunction.Text = cbFunction.SelectedItem as string;
				}
			}
			// The radio buttons for abbr and Name are set when initialized - so don't reset them
		}
		private void ShowInfo(LexImportField field)
		{
			XmlNode node = field.Node;
			////if (node == null)
			////{
			////    // custom fields didn't come from the ImportFields.xml file so the node doesn't exist
			////    webBrowserInfo.DocumentText = "";	// just make it empty for now
			////    return;
			////}
			var tempfile = Path.Combine(Path.GetTempPath(), "temphelp.htm");
			using (StreamWriter w = new StreamWriter(tempfile, false))
			using (XmlTextWriter tw = new XmlTextWriter(w))
			{
				m_xmlShowInfoDoc.LoadXml(node.OuterXml); // N.B. LoadXml requires UTF-16 or UCS-2 encodings
				m_xslShowInfoTransform.Transform(m_xmlShowInfoDoc, tw);
			}
			var uri = new Uri(tempfile);
			m_browser.Navigate(uri.AbsoluteUri);
		}