SIL.FieldWorks.XWorks.ExportDialog.AddFxts C# (CSharp) Method

AddFxts() protected method

protected AddFxts ( string filePaths ) : void
filePaths string
return void
		protected void AddFxts(string[] filePaths)
		{
			Debug.Assert(filePaths != null);

			foreach (string path in filePaths)
			{
				if (path.EndsWith(".xml~"))
					continue;	// ignore editor backup files.
				XmlDocument document = new XmlDocument();
				// If we have an xml file that can't be loaded, ignore it.
				try
				{
					document.Load(path);
				}
				catch
				{
					continue;
				}
				XmlNode node = document.SelectSingleNode("//FxtDocumentDescription");
				if (node == null)
					continue;
				string dataLabel = XmlUtils.GetOptionalAttributeValue(node,"dataLabel", "unknown");
				string formatLabel = XmlUtils.GetOptionalAttributeValue(node,"formatLabel", "unknown");
				string defaultExtension = XmlUtils.GetOptionalAttributeValue(node,"defaultExtension", "txt");
				string sDefaultFilter = ResourceHelper.FileFilter(FileFilterType.AllFiles);
				string filter = XmlUtils.GetOptionalAttributeValue(node,"filter", sDefaultFilter);
				string description = node.InnerText;
				if (description!=null)
					description = description.Trim();
				if (string.IsNullOrEmpty(description))
					description = xWorksStrings.NoDescriptionForItem;
				var item = new ListViewItem(new[]{dataLabel, formatLabel, defaultExtension, filter, description});
				item.Tag = path;
				m_exportList.Items.Add(item);
				ConfigureItem(document, item, node);
			}

			// Select the first available one
			foreach (ListViewItem lvi in m_exportList.Items)
			{
				if (!ItemDisabled((string)lvi.Tag))
				{
					lvi.Selected = true;
					m_exportItems.Add(lvi);
					break;
				}
			}

		}