当前位置: 首页>>代码示例>>C#>>正文


C# IProgress.Step方法代码示例

本文整理汇总了C#中IProgress.Step方法的典型用法代码示例。如果您正苦于以下问题:C# IProgress.Step方法的具体用法?C# IProgress.Step怎么用?C# IProgress.Step使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProgress的用法示例。


在下文中一共展示了IProgress.Step方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FwData

		/// <summary>
		/// Constructor.  Reads the file and stores any data needed for corrections later on.
		/// </summary>
		public FwData(string filename, IProgress progress)
		{
			m_filename = filename;
			m_progress = progress;

			m_progress.Minimum = 0;
			m_progress.Maximum = 1000;
			m_progress.Position = 0;
			m_progress.Message = String.Format(Strings.ksReadingTheInputFile, m_filename);
			m_crt = 0;
			using (XmlReader xrdr = XmlReader.Create(m_filename))
			{
				xrdr.MoveToContent();
				if (xrdr.Name != "languageproject")
					throw new Exception(String.Format("Unexpected outer element (expected <Lists>): {0}", xrdr.Name));
				xrdr.Read();
				xrdr.MoveToContent();
				if (xrdr.Name == "AdditionalFields")
					xrdr.ReadToFollowing("rt");
				while (xrdr.Name == "rt")
				{
					string rtXml = xrdr.ReadOuterXml();
					XElement rt = XElement.Parse(rtXml);
					StoreGuidInfo(rt);
					xrdr.MoveToContent();
					++m_crt;
					if (m_progress.Position == m_progress.Maximum)
						m_progress.Position = 0;
					if ((m_crt % 1000) == 0)
						m_progress.Step(1);
				}
				xrdr.Close();
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:37,代码来源:FwData.cs

示例2: DetermineSectionOverlapClusters

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This static method steps through all the sections of the given Current and Revision
		/// books and determines which clusters of sections have overlapping verse ref ranges.
		/// </summary>
		/// <param name="bookCurr">the given current book</param>
		/// <param name="bookRev">the given book revision</param>
		/// <param name="cache">The database cache.</param>
		/// <param name="progressDlg">The progress dialog box.</param>
		/// <returns>
		/// list of Cluster objects for the sections of the books
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static List<Cluster> DetermineSectionOverlapClusters(IScrBook bookCurr,
			IScrBook bookRev, FdoCache cache, IProgress progressDlg)
		{
			int nSectionsCurr = bookCurr.SectionsOS.Count;
			int nSectionsRev = bookRev.SectionsOS.Count;

			// build the current and rev proxy lists, of OverlapInfo objects
			List<OverlapInfo> sectionProxyListCurr = new List<OverlapInfo>(nSectionsCurr);
			List<OverlapInfo> sectionProxyListRev = new List<OverlapInfo>(nSectionsRev);
			foreach (IScrSection section in bookRev.SectionsOS)
			{
				//REVIEW: should we skip intro sections in these lists??
				sectionProxyListRev.Add(new OverlapInfo(section, true));
				Debug.Assert(BCVRef.GetChapterFromBcv(section.VerseRefMin) > 0); // catch test that forgot to set section refs
				if (progressDlg != null)
					progressDlg.Step(1);
			}
			foreach (IScrSection section in bookCurr.SectionsOS)
			{
				sectionProxyListCurr.Add(new OverlapInfo(section, false));
				Debug.Assert(BCVRef.GetChapterFromBcv(section.VerseRefMin) > 0); // catch test that forgot to set section refs
				if (progressDlg != null)
					progressDlg.Step(1);
			}

			// Now build the list of section overlap clusters
			ClusterListHelper clh = new ClusterListHelper(cache);
			clh.DetermineOverlapClusters(sectionProxyListCurr, sectionProxyListRev);
			return clh.m_clusterList;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:43,代码来源:Cluster.cs

示例3: FwDataFixer

		/// <summary>
		/// Constructor.  Reads the file and stores any data needed for corrections later on.
		/// </summary>
		public FwDataFixer(string filename, IProgress progress, ErrorLogger logger)
		{
			m_filename = filename;
			m_progress = progress;
			errorLogger = logger;

			m_progress.Minimum = 0;
			m_progress.Maximum = 1000;
			m_progress.Position = 0;
			m_progress.Message = String.Format(Strings.ksReadingTheInputFile, m_filename);
			m_crt = 0;
			// The following fixers will be run on each rt element during FixErrorsAndSave()
			// Note: every change to the file MUST log an error. This is used in FixFwData to set a return code indicating whether anything changed.
			// This in turn is used in Send/Receive to determine whether we need to re-split the file before committing.
			// N.B.: Order is important here!!!!!!!
			m_rtLevelFixers.Add(new DuplicateStyleFixer());
			m_rtLevelFixers.Add(new OriginalFixer());
			m_rtLevelFixers.Add(new CustomPropertyFixer());
			m_rtLevelFixers.Add(new BasicCustomPropertyFixer());
			var senseFixer = new GrammaticalSenseFixer();
			m_rtLevelFixers.Add(senseFixer);
			m_rtLevelFixers.Add(new MorphBundleFixer(senseFixer)); // after we've possibly removed MSAs in GrammaticalSenseFixer
			m_rtLevelFixers.Add(new SequenceFixer());
			m_rtLevelFixers.Add(new HomographFixer());
			m_rtLevelFixers.Add(new DuplicateWordformFixer());
			m_rtLevelFixers.Add(new CustomListNameFixer());
			using (XmlReader xrdr = XmlReader.Create(m_filename))
			{
				xrdr.MoveToContent();
				if (xrdr.Name != "languageproject")
					throw new Exception(String.Format("Unexpected outer element (expected <Lists>): {0}", xrdr.Name));
				xrdr.Read();
				xrdr.MoveToContent();
				if (xrdr.Name == "AdditionalFields")
				{
					string customsNode = xrdr.ReadOuterXml();
					XElement additionalFieldsElem = XElement.Parse(customsNode);
					// Give each fixer a chance to gather data on defined custom fields.
					foreach (var fixer in m_rtLevelFixers)
						fixer.InspectAdditionalFieldsElement(additionalFieldsElem);
					xrdr.ReadToFollowing("rt");
				}
				while (xrdr.Name == "rt")
				{
					string rtXml = xrdr.ReadOuterXml();
					XElement rt = XElement.Parse(rtXml);
					StoreGuidInfoAndOwnership(rt, errorLogger);
					// Give each fixer a chance to gather data on the first pass,
					// if it needs two passes to fix its sort of problem.
					foreach (var fixer in m_rtLevelFixers)
						fixer.InspectElement(rt);
					xrdr.MoveToContent();
					++m_crt;
					if (m_progress.Position == m_progress.Maximum)
						m_progress.Position = 0;
					if ((m_crt % 1000) == 0)
						m_progress.Step(1);
				}
				foreach (var fixer in m_rtLevelFixers)
					fixer.FinalFixerInitialization(m_owners, m_guids, m_parentToOwnedObjsur, m_rtElementsToDelete);
				xrdr.Close();
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:66,代码来源:FwDataFixer.cs

示例4: FixDuplicates

		/// <summary>
		/// Find and fix duplicate wordforms (any two or more that have the same form for default vernacular and all non-empty writing systems).
		/// All anlyses (and WfiGlosses) are preserved, even if duplicated.
		/// Spelling status is correct if any of the merged items are correct, then false if any is false, otherwise stays unknown.
		/// Note: caller is responsible to create Unit of Work.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="progressBar"></param>
		/// <returns>A string containing a list of wordforms that could not be merged because they have differing values for other WSs</returns>
		public static string FixDuplicates(FdoCache cache, IProgress progressBar)
		{
			var failures = new HashSet<string>();
			var wfRepo = cache.ServiceLocator.GetInstance<IWfiWordformRepository>();
			// Note that we may change AllInstances in this loop, so the copy done by ToArray() is essential.
			var wfiWordforms = wfRepo.AllInstances().ToArray();
			progressBar.Minimum = 0;
			progressBar.Maximum = wfiWordforms.Length;
			progressBar.StepSize = 1;
			foreach (var wf in wfiWordforms)
			{
				progressBar.Step(1);
				var text = wf.Form.VernacularDefaultWritingSystem.Text;
				if (string.IsNullOrEmpty(text))
					continue;
				var canonicalWf = wfRepo.GetMatchingWordform(cache.DefaultVernWs, text);
				if (canonicalWf == wf)
					continue;
				if (HaveInconsistentAlternatives(wf, canonicalWf))
				{
					failures.Add(text);
					continue; // can't merge.
				}
				// Move all analyses to survivor.
				foreach (var wa in wf.AnalysesOC)
					canonicalWf.AnalysesOC.Add(wa);
				foreach (var source in wf.ReferringObjects)
				{
					var srcSegment = source as ISegment;
					if (srcSegment != null)
					{
						for (;;)
						{
							int index = srcSegment.AnalysesRS.IndexOf(wf);
							if (index == -1)
								break;
							srcSegment.AnalysesRS[index] = canonicalWf;
						}
						continue;
					}
					var wordset = source as IWfiWordSet;
					if (wordset != null)
					{
						if (wordset.CasesRC.Contains(wf))
							wordset.CasesRC.Add(canonicalWf); // does nothing if already present.
						continue;
					}
					var rendering = source as IChkRendering;
					if (rendering != null)
					{
						rendering.SurfaceFormRA = canonicalWf;
						continue;
					}
					var chkRef = source as IChkRef;
					if (chkRef != null)
					{
						chkRef.RenderingRA = canonicalWf;
					}
				}
				if (wf.SpellingStatus == (int)SpellingStatusStates.correct)
					canonicalWf.SpellingStatus = (int)SpellingStatusStates.correct; // may be already, but ensures this wins
				else if (canonicalWf.SpellingStatus == (int)SpellingStatusStates.undecided)
					canonicalWf.SpellingStatus = wf.SpellingStatus; // the only case that does something is undecided => incorrect
				canonicalWf.Checksum = 0; // reset so parser will recheck whole group of analyses.

				// Copy over other alternatives
				foreach (var ws in wf.Form.AvailableWritingSystemIds)
				{
					if(string.IsNullOrEmpty(canonicalWf.Form.get_String(ws).Text))
						canonicalWf.Form.set_String(ws, wf.Form.get_String(ws));
				}
				wf.Delete();
			}
			if (failures.Count == 0)
				return "";
			return failures.OrderBy(x=>x).Aggregate((x,y) => x + " " + y);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:86,代码来源:WfiWordformServices.cs

示例5: MergeDuplicateAnalyses

		/// <summary>
		/// Merge duplicate analyses on all wordforms. (Also merges duplicate WfiGlosses.)
		/// </summary>
		/// <returns></returns>
		public static void MergeDuplicateAnalyses(FdoCache cache, IProgress progressBar)
		{
			var wfiWordforms = cache.ServiceLocator.GetInstance<IWfiWordformRepository>().AllInstances().ToList();
			progressBar.Minimum = 0;
			progressBar.Maximum = wfiWordforms.Count;
			progressBar.StepSize = 1;
			foreach (var wf in wfiWordforms)
			{
				progressBar.Step(1);
				var analyses = wf.AnalysesOC.ToList();
				for (int i = 0; i < analyses.Count; i++)
				{
					var waKeep = analyses[i];
					for (int j = analyses.Count - 1; j > i; j--)
					{
						var waDup = analyses[j];
						if (DuplicateAnalyses(waKeep, waDup))
						{
							foreach (var wg in waDup.MeaningsOC)
								waKeep.MeaningsOC.Add(wg);
							CmObject.ReplaceReferences(waDup, waKeep);
							waDup.Delete();
							analyses.RemoveAt(j);
						}
					}
					MergeDuplicateGlosses(waKeep);
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:33,代码来源:WfiWordformServices.cs

示例6: ExportSection

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Export the heading and contents of the given section.
		/// </summary>
		/// <param name="progressDlg">The progress dialog.</param>
		/// <param name="section">current section in the book</param>
		/// <param name="outputImplicitChapter">if true, output implicit chapter number</param>
		/// ------------------------------------------------------------------------------------
		protected void ExportSection(IProgress progressDlg, IScrSection section,
			bool outputImplicitChapter)
		{
			m_currentSectionIsIntro = section.IsIntro;
			m_textOutputBegunInCurrentSection = false;
			BCVRef sectionRefStart = section.VerseRefStart;

			// Pre-process the first paragraph of the section. If this first paragraph begins with
			// a chapter number, we need to export the chapter marker now, before the section marker.
			RefElement runTypeFound;
			ITsString tss = ((IStTxtPara)section.ContentOA.ParagraphsOS[0]).Contents;
			ProcessParaStart(tss, section.VerseRefStart, out runTypeFound);

			// If m_currentChapterRef was not set during ProcessParaStart
			//  (i.e. the section does not begin with a chapter number run)...
			if (m_currentChapterRef == 0)
			{
				// Set the current chapter & verse ref state from the section start ref,
				//  so the vref markers and annotation matching will be correct.
				m_currentChapterRef = sectionRefStart.Chapter;
				m_lastNumericBeginVerseNum = m_lastNumericEndVerseNum = sectionRefStart.Verse;
				m_currentVerseNumString = null;
			}

			// Handle the special output needed if there is an implicit chapter 1.
			// If the section ref start indicates chapter 1, and the section is not an introduction, and
			// the first paragraph does not begin with a chapter run and no chapter has been written ...
			if (runTypeFound != RefElement.Chapter && m_lastChapterWritten == 0 &&
				sectionRefStart.Chapter == 1 && !m_currentSectionIsIntro)
			{
				// If we are to output implicit first chapter number...
				if (outputImplicitChapter)
				{
					// output the "\c 1" and record marker.
					// also see if the chapter we just wrote out needs to get an
					//  implicit first verse marker.
					if (WriteChapterTag(1))
						m_v1NeededForImplicitFirstVerse = ParaBeginsWithImplicitFirstVerse(tss, 0);
				}
				else
				{
					// book has only one chapter; output only the record marker, not a \c.
					m_file.WriteLine(); //always start on new line
					WriteRecordMark(m_currentBookCode, 1);
					m_v1NeededForImplicitFirstVerse = ParaBeginsWithImplicitFirstVerse(tss, 0);
				}
			}

			// Write out the section heading paragraphs
			m_currentParaIsHeading = true;
			foreach (IStTxtPara para in section.HeadingOA.ParagraphsOS)
				ExportParagraph(para, (IScrBook)section.Owner);

			// Write out the section contents
			m_currentParaIsHeading = false;
			foreach (IStTxtPara para in section.ContentOA.ParagraphsOS)
				ExportParagraph(para, (IScrBook)section.Owner);

			progressDlg.Step(0);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:68,代码来源:ExportUsfm.cs

示例7: UpdateKeyTermEquivalentsInternal

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the key term equivalents.
		/// </summary>
		/// <param name="progressDlg">The progress dialog box.</param>
		/// ------------------------------------------------------------------------------------
		protected void UpdateKeyTermEquivalentsInternal(IProgress progressDlg)
		{
			List<InvalidRendering> invalidRenderings = new List<InvalidRendering>();
			try
			{
				// first build a map from verses to the keyterms that should have renderings.
				Set<IChkTerm> chkTerms = m_ktTree.ChkTermsWithRefs;
				if (progressDlg != null)
				{
					progressDlg.Message = TeResourceHelper.GetResourceString("kstidUpdateKeyTermEquivalentsProgressLoading");
					progressDlg.Minimum = 0;
					progressDlg.Maximum = chkTerms.Count;
				}
				Dictionary<int, List<KeyTermRef>> bcvToChkRefs = new Dictionary<int, List<KeyTermRef>>();
				foreach (IChkTerm keyTerm in chkTerms)
				{
					AddChkRefsToBCVmap(keyTerm, ref bcvToChkRefs);
					if (progressDlg != null)
						progressDlg.Step(0);
				}
				// set progress bar to the number of verses to step through.
				if (progressDlg != null)
				{
					progressDlg.Minimum = 0;
					progressDlg.Maximum = bcvToChkRefs.Count;
				}
				// for each keyterm occurrences in each verse, make sure renderings are up to date.
				List<int> sortedKeys = new List<int>(bcvToChkRefs.Keys);
				sortedKeys.Sort();
				foreach (int bcv in sortedKeys)
				{
					// REVIEW (TE-6532): For now, all Key Term Refs in the DB use the Original
					// versisifcation. Should we support other versifications?
					ScrReference currentVerse = new ScrReference(bcv, ScrVers.Original,
						m_scr.Versification);
					if (progressDlg != null)
					{
						progressDlg.Message = String.Format(TeResourceHelper.GetResourceString("kstidUpdateKeyTermEquivalentsProgressMessage"),
							currentVerse.AsString);
					}
					List<KeyTermRef> chkRefsForVerse = bcvToChkRefs[bcv];
					foreach (KeyTermRef keyRef in chkRefsForVerse)
					{
						// skip doing anything about references that have been marked as "Ignore"
						if (keyRef.RenderingStatus == KeyTermRenderingStatus.Ignored)
							continue;
						if (keyRef.ChkRef.RenderingRA != null)
						{
							if (CanFindTextInVerse(keyRef.ChkRef.RenderingRA, currentVerse))
							{
								if (keyRef.RenderingStatus == KeyTermRenderingStatus.Missing)
									keyRef.RenderingStatus = KeyTermRenderingStatus.Assigned;
								continue;
							}
						}
						// if an expected rendering is not found (or there was no previous assignment)
						// see if we can find an alternative rendering to AutoAssign.
						IChkTerm parentKeyTerm = (IChkTerm)keyRef.ChkRef.Owner;
						bool fFound = false;
						foreach (IChkRendering rendering in parentKeyTerm.RenderingsOC)
						{
							if (rendering.SurfaceFormRA == null)
							{
								// We found a surface form that is not defined. Later we'll need to
								// remove this rendering, but for now we'll continue to the next one.
								invalidRenderings.Add(new InvalidRendering(parentKeyTerm, rendering));
								continue;
							}
							if (CanFindTextInVerse(rendering.SurfaceFormRA, currentVerse))
							{
								try
								{
									keyRef.ChkRef.RenderingRA = rendering.SurfaceFormRA;
									if (keyRef.RenderingStatus != KeyTermRenderingStatus.AutoAssigned)
										keyRef.RenderingStatus = KeyTermRenderingStatus.AutoAssigned;
									fFound = true;
									break;
								}
								catch
								{
									// Unable to set rendering because it is invalid.
									invalidRenderings.Add(new InvalidRendering(parentKeyTerm, rendering));
									continue;
								}
							}
						}
						if (!fFound)
						{
							if (keyRef.RenderingStatus == KeyTermRenderingStatus.Assigned &&
								keyRef.ChkRef.RenderingRA != null)
							{
								// keep RenderingsRA info, so we know what is missing.
								keyRef.RenderingStatus = KeyTermRenderingStatus.Missing;
							}
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:KeyTermsViewWrapper.cs

示例8: CreateHfSets

		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Create a HeaderFooterSet for each HeaderFooterSet node in the given xml node list.
		/// </summary>
		/// <param name="progressDlg">Progress dialog</param>
		/// <param name="hfSetNodes">the xml nodes to read</param>
		/// -------------------------------------------------------------------------------------
		protected void CreateHfSets(IProgress progressDlg, XmlNodeList hfSetNodes)
		{
			//create each HeaderFooterSet
			foreach (XmlNode hfSetNode in hfSetNodes)
			{
				progressDlg.Step(0);

				IPubHFSet hfSet = m_scr.FindHeaderFooterSetByName(GetString(hfSetNode.Attributes, "Name"));
				if (hfSet == null)
				{
					hfSet = m_cache.ServiceLocator.GetInstance<IPubHFSetFactory>().Create();
					m_scr.HeaderFooterSetsOC.Add(hfSet);
				}
				// ENHANCE(TE-5897): If a user has modified a header/footer set, then changes
				// to it in the factory H/F set should not be applied
				ReadHeaderFooterSet(hfSet, hfSetNode, true, true);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:25,代码来源:TePublicationsInit.cs

示例9: CreatePublications

		private void CreatePublications(IProgress progressDlg, XmlNodeList publicationNodes,
			XmlNodeList hfSetNodes)
		{
			// Remove any previously-defined publications.
			m_scr.PublicationsOC.Clear();

			//create each publication
			foreach (XmlNode publicationNode in publicationNodes)
			{
				progressDlg.Step(0);

				XmlAttributeCollection attributes = publicationNode.Attributes;
				string pubName = GetString(attributes, "Name");

				// Determine the measurement unit to be used for all measurements in this pub
				m_conversion = GetUnitConversion(attributes, "MeasurementUnits", kMpPerInch);

				// Create the new Publication object and set non-variable properties
				IPublication pub = m_cache.ServiceLocator.GetInstance<IPublicationFactory>().Create();
				m_scr.PublicationsOC.Add(pub);

				pub.Name = pubName;
				// We'll build a TsString to populate it.
				ITsStrFactory strFactory = TsStrFactoryClass.Create();
				pub.Description =
					strFactory.MakeString(GetString(attributes, "Description"),
					m_defUserWs);
				pub.IsLandscape = GetBoolean(attributes, "IsLandscape", false);
				GetPageHeightAndWidth(attributes, pub,
					publicationNode.SelectSingleNode("SupportedPublicationSizes"));
				pub.PaperHeight = 0;
				pub.PaperWidth = 0;
				pub.GutterMargin = GetMeasurement(attributes, "GutterMargin", 0, m_conversion);
				pub.BindingEdge = GetGutterLoc(attributes, "BindingSide", BindingSide.Left);
				pub.BaseFontSize = GetMeasurement(attributes, "BaseCharSize", 0, 1000);
				// Line spacing < 0 means "exact", which is all we support currently
				pub.BaseLineSpacing = -Math.Abs(GetMeasurement(attributes, "BaseLineSize", 0, 1000));
				pub.SheetLayout = GetSheetLayout(attributes, MultiPageLayout.Simplex);

				XmlNodeList divisionNodes = publicationNode.SelectNodes("Divisions/Division");
				CreateDivisions(pub, divisionNodes, hfSetNodes);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:43,代码来源:TePublicationsInit.cs

示例10: ExportRecords

        private void ExportRecords(TextWriter writer, IProgress progress)
        {
            m_mdc = m_cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>();
            foreach (int flid in m_mdc.GetFields(RnGenericRecTags.kClassId, true,
                (int)CellarPropertyTypeFilter.All))
            {
                if (m_mdc.IsCustom(flid))
                    m_customFlids.Add(flid);
            }

            writer.WriteLine("<Entries docRightToLeft=\"{0}\">",
                m_fRightToLeft ? "true" : "false");
            foreach (var record in m_cache.LangProject.ResearchNotebookOA.RecordsOC)
            {
                ExportRecord(writer, record, 0);
                progress.Step(1);
            }
            writer.WriteLine("</Entries>");
        }
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:19,代码来源:NotebookExportDialog.cs

示例11: ExportNotebook

 object ExportNotebook(IProgress progress, object[] args)
 {
     string outPath = (string)args[0];
     string fxtPath = (string)args[1];
     FxtType ft = (FxtType)args[2];
     progress.Minimum = 0;
     progress.Maximum = m_cache.LangProject.ResearchNotebookOA.RecordsOC.Count + 6;
     using (var writer = new StreamWriter(outPath)) // defaults to UTF-8
     {
         writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
         writer.WriteLine("<Notebook exportVersion=\"2.0\" project=\"{0}\" dateExported=\"{1}\">",
             m_cache.ProjectId.UiName, DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss"));
         progress.Message = "Exporting data records...";
         ExportRecords(writer, progress);
         progress.Message = "Exporting writing systems...";
         ExportLanguages(writer);
         progress.Step(3);
         progress.Message = "Exporting styles...";
         ExportStyles(writer);
         progress.Step(3);
         writer.WriteLine("</Notebook>");
     }
     if (!String.IsNullOrEmpty(ft.m_sXsltFiles))
     {
         string[] rgsXslts = ft.m_sXsltFiles.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
         int cXslts = rgsXslts.Length;
         if (cXslts > 0)
         {
             progress.Position = 0;
             progress.Minimum = 0;
             progress.Maximum = cXslts;
             progress.Message = xWorksStrings.ProcessingIntoFinalForm;
             string basePath = Path.GetDirectoryName(fxtPath);
             for (int ix = 0; ix < cXslts; ++ix)
             {
                 string sXsltPath = Path.Combine(basePath, rgsXslts[ix]);
                 // Apply XSLT to the output file, first renaming it so that the user sees
                 // the expected final output file.
                 CollectorEnv.ProcessXsltForPass(sXsltPath, outPath, ix + 1);
                 progress.Step(1);
             }
         }
     }
     return null;
 }
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:45,代码来源:NotebookExportDialog.cs

示例12: SetNamesAndAbbreviations

		protected void SetNamesAndAbbreviations(IProgress progressDlg, XmlNode rootNode)
		{
			IScrRefSystem srs = m_cache.ServiceLocator.GetInstance<IScrRefSystemRepository>().Singleton;
			Debug.Assert(srs != null && srs.BooksOS.Count == BCVRef.LastBook);

			XmlNodeList tagList = rootNode.SelectNodes("/ScrBookRef/writingsystem");
			progressDlg.Minimum = 0;
			progressDlg.Maximum = tagList.Count * BCVRef.LastBook;
			progressDlg.Position = 0;
			progressDlg.Title = TeResourceHelper.GetResourceString("kstidCreatingBookNames");
			ITsStrFactory tsf = m_cache.TsStrFactory;
			IWritingSystem ws;

			foreach (XmlNode writingSystem in tagList)
			{
				XmlAttributeCollection attributes = writingSystem.Attributes;
				string sWsTag = attributes.GetNamedItem("xml:lang").Value;
				m_cache.ServiceLocator.WritingSystemManager.GetOrSet(sWsTag, out ws);

				XmlNodeList WSBooks = writingSystem.SelectNodes("book");
				foreach (XmlNode book in WSBooks)
				{
					XmlAttributeCollection bookAttributes = book.Attributes;
					string sSilBookId = bookAttributes.GetNamedItem("SILBookId").Value;
					Debug.Assert(sSilBookId != null);
					int nCanonicalBookNum = BCVRef.BookToNumber(sSilBookId);
					string sName = bookAttributes.GetNamedItem("Name").Value;
					string sAbbrev = bookAttributes.GetNamedItem("Abbreviation").Value;
					string sAltName = bookAttributes.GetNamedItem("AlternateName").Value;
					progressDlg.Message = string.Format(
						TeResourceHelper.GetResourceString("kstidCreatingBookNamesStatusMsg"), sName);
					progressDlg.Step(0);

					// check for the book id
					IScrBookRef bookRef = srs.BooksOS[nCanonicalBookNum - 1];

					int wsHandle = ws.Handle;
					if (sName != null)
						bookRef.BookName.set_String(wsHandle, tsf.MakeString(sName, wsHandle));
					if (sAbbrev != null)
						bookRef.BookAbbrev.set_String(wsHandle, tsf.MakeString(sAbbrev, wsHandle));
					if (sAltName != null)
						bookRef.BookNameAlt.set_String(wsHandle, tsf.MakeString(sAltName, wsHandle));
				}
			}
			// Finally, update resource version in database.
			SetNewResourceVersion(GetVersion(rootNode));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:48,代码来源:TeScrBookRefsInit.cs


注:本文中的IProgress.Step方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。