Ejemplo n.º 1
0
		private void ExportLift(TextWriter w, string folderPath,
			IEnumerable<ILexEntry> entries, int cEntries)
		{
			FolderPath = folderPath;
			if (SetProgressMessage != null)
			{
				var ma = new ProgressMessageArgs { Max = cEntries, MessageId = "ksExportingLift" };
				SetProgressMessage(this, ma);
			}

			// pre-emtively delete the audio folder so files of deleted/changed references
			// won't be orphaned
			if (Directory.Exists(Path.Combine(FolderPath,"audio")))
				Directory.Delete(Path.Combine(FolderPath, "audio"), true);

			w.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
			w.WriteLine("<!-- See http://code.google.com/p/lift-standard for more information on the format used here. -->");
			w.WriteLine("<lift producer=\"SIL.FLEx {0}\" version=\"0.13\">", GetVersion());

			//Determine which custom fields ones point to a CmPossibility List (either custom or standard).
			//Determine which ones point to a custom CmPossibility List and make sure we output that list as a range.
			//Also if a List is not referred to by standard fields, it might not be output as a range, so if the List
			//is referenced by a custom field, then that List does need to be output to the LIFT ranges file.
			m_CmPossibilityListsReferencedByFields = GetCmPossibilityListsReferencedByFields(entries);
			MapCmPossibilityListGuidsToLiftRangeNames(m_CmPossibilityListsReferencedByFields);

			WriteHeaderInformation(w);
			foreach (var entry in entries)
			{
				WriteLiftEntry(w, entry);
				if (UpdateProgress != null)
					UpdateProgress(this);
			}
			w.WriteLine("</lift>");
			w.Flush();

			ExportWsAsLdml(Path.Combine(folderPath, "WritingSystems"));
		}
Ejemplo n.º 2
0
 private void OnDumperSetProgressMessage(object sender, ProgressMessageArgs e)
 {
     Debug.Assert(m_progressDlg != null);
     string sMsg = xWorksStrings.ResourceManager.GetString(e.MessageId, xWorksStrings.Culture);
     if (!String.IsNullOrEmpty(sMsg))
         m_progressDlg.Message = sMsg;
     m_progressDlg.Position = 0;
     m_progressDlg.Minimum = 0;
     m_progressDlg.Maximum = e.Max;
     if (m_progressDlg.Canceled)
         m_dumper.Cancel();
 }
Ejemplo n.º 3
0
		void OnDumperSetProgressMessage(object sender, ProgressMessageArgs e)
		{
			if (_progressDlg == null)
				return;
			var message = ResourceHelper.GetResourceString(e.MessageId);
			if (!string.IsNullOrEmpty(message))
				_progressDlg.Message = message;
			_progressDlg.Minimum = 0;
			_progressDlg.Maximum = e.Max;
		}
Ejemplo n.º 4
0
		protected void DoTemplateElement(TextWriter contentsStream, XmlNode node)
		{
			m_templateRootNode = node;
			string sIcuNormalizationMode = XmlUtils.GetOptionalAttributeValue(m_templateRootNode, "normalization", "NFC");
			if (sIcuNormalizationMode == "NFD")
				m_eIcuNormalizationMode = Icu.UNormalizationMode.UNORM_NFD;
			else
				m_eIcuNormalizationMode = Icu.UNormalizationMode.UNORM_NFC;
			string style = XmlUtils.GetOptionalAttributeValue(m_templateRootNode, "writingSystemAttributeStyle", WritingSystemAttrStyles.FieldWorks.ToString());
			m_writingSystemAttrStyle = (WritingSystemAttrStyles) System.Enum.Parse(typeof(WritingSystemAttrStyles), style);
			string sFormatOutput = XmlUtils.GetOptionalAttributeValue(m_templateRootNode, "stringFormatOutputStyle", StringFormatOutputStyle.None.ToString());
			m_eStringFormatOutput = (StringFormatOutputStyle)System.Enum.Parse(typeof(StringFormatOutputStyle), sFormatOutput);
			m_requireClassTemplatesForEverything = XmlUtils.GetBooleanAttributeValue(node,"requireClassTemplatesForEverything");
			m_doUseBaseClassTemplatesIfNeeded = XmlUtils.GetBooleanAttributeValue(node, "doUseBaseClassTemplatesIfNeeded");

			if (UpdateProgress != null)
				UpdateProgress(this);
			string sProgressMsgId = XmlUtils.GetOptionalAttributeValue(m_templateRootNode, "messageId");
			if (!String.IsNullOrEmpty(sProgressMsgId) && SetProgressMessage != null)
			{
				var ma = new ProgressMessageArgs
					{
						MessageId = sProgressMsgId,
						Max = XmlUtils.GetOptionalIntegerValue(m_templateRootNode, "progressMax", 20)
					};
				SetProgressMessage.Invoke(this, ma);
			}
			if (String.IsNullOrEmpty(m_sAuxiliaryFxtFile))	// don't recurse in Go() more than once.
				ComputeAuxiliaryFilename(contentsStream, node);

			DumpObject(contentsStream, m_rootObject, null);
		}