コード例 #1
0
ファイル: TeScrInitializer.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Preloads the data used by TE.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="splashScreen">The splash screen (can be null).</param>
		/// ------------------------------------------------------------------------------------
		public static void PreloadData(FdoCache cache, IFwSplashScreen splashScreen)
		{
			if (splashScreen != null)
			{
				splashScreen.ProgressBar.SetRange(0, 21); // we call 21 x UpdateProgress() below
				splashScreen.ProgressBar.StepSize = 1;
				splashScreen.ProgressBar.Position = 0;
			}

			// Preload all vectors for scripture
			// NOTE: splitting up the loading of flids off of the same object type (e.g. StText)
			// lets us create a smoother progress bar and doesn't seem to produce any noticable
			// performance hit!
			cache.PreloadIfMissing(cache.LangProject.TranslatedScriptureOAHvo,
				(int)Scripture.ScriptureTags.kflidScriptureBooks, 0);
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningVectorProp((int)ScrBook.ScrBookTags.kflidSections, "ScrBook");
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningVectorProp((int)Scripture.ScriptureTags.kflidStyles, "Scripture");
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningAtomicProp((int)ScrSection.ScrSectionTags.kflidHeading, "ScrSection");
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningAtomicProp((int)ScrSection.ScrSectionTags.kflidContent, "ScrSection");
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningVectorProp((int)StText.StTextTags.kflidParagraphs, "StText",
				new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes });
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningVectorProp((int)StText.StTextTags.kflidParagraphs, "StText",
				new int[] { (int)ScrBook.ScrBookTags.kflidTitle });
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningVectorProp((int)StText.StTextTags.kflidParagraphs, "StText",
				new int[] { (int)ScrSection.ScrSectionTags.kflidHeading });
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningVectorProp((int)StText.StTextTags.kflidParagraphs, "StText",
				new int[] { (int)ScrSection.ScrSectionTags.kflidContent });
			UpdateProgress(splashScreen);
			cache.LoadAllOfAnOwningVectorProp((int)StTxtPara.StTxtParaTags.kflidTranslations, "StTxtPara");
			UpdateProgress(splashScreen);

			// also preload all scripture, sections, paragraphs and footnotes
			CmObject.LoadDataForFlids(typeof(Scripture), cache, null,
				LangProject.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(StStyle), cache,
				new int[] { (int)LangProject.LangProjectTags.kflidTranslatedScripture },
				Scripture.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(ScrSection), cache,
				new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks },
				ScrBook.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(StFootnote), cache,
				new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks },
				ScrBook.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(StTxtPara), cache,
				new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes }, StText.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(StTxtPara), cache,
				new int[] { (int)ScrBook.ScrBookTags.kflidTitle }, StText.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(StTxtPara), cache,
				new int[] { (int)ScrSection.ScrSectionTags.kflidHeading }, StText.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(StTxtPara), cache,
				new int[] { (int)ScrSection.ScrSectionTags.kflidContent }, StText.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(CmTranslation), cache,
				new int[] { (int)CmTranslation.CmTranslationTags.kflidStatus }, CmTranslation.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(CmTranslation), cache,
				new int[] { (int)CmTranslation.CmTranslationTags.kflidTranslation }, CmTranslation.FullViewName);
			UpdateProgress(splashScreen);
			CmObject.LoadDataForFlids(typeof(CmTranslation), cache,
				new int[] { (int)CmTranslation.CmTranslationTags.kflidType }, CmTranslation.FullViewName);
			UpdateProgress(splashScreen);
		}
コード例 #2
0
ファイル: ITextUtils.cs プロジェクト: sillsdev/WorldPad
		internal static List<int> ConcordParagraphs(FdoCache cache, int[] hvosStTxtPara, ProgressState progress,
			IMatcher matcher, ConcordanceControl.ConcordanceLines line)
		{
			using (ParagraphParser pp = new ParagraphParser(cache))
			{
				// this will effectively clear ConcordanceWordforms, which seems overkill, but
				// since we are changing the occurrences on those wordforms,
				// and also possibly adding many new wordforms, we should just allow RecordLists that use
				// ConcordanceWordforms to reload the list.
				// (Enhance: is there any way we can make those lists be smart about when they need to reload,
				// rather than forcing them to?)
				(pp.m_wfi as WordformInventory).SuspendUpdatingConcordanceWordforms = true;
				pp.CreateDummyWordforms = true;
				pp.m_hvosStTxtPara = hvosStTxtPara;
				if (matcher != null)
					pp.m_matchingAnnotations = new List<int>();
				ParagraphParser.ResetParseSessionDependentStaticData();

				// Estimate the number of total number of milestones we'll set.
				// Enhance: we could construct a way to set percentage done based upon
				// number of texts and paragraphs in each text.
				if (progress is MilestoneProgressState)
				{
					MilestoneProgressState mp = progress as SIL.FieldWorks.Common.Controls.MilestoneProgressState;
					for (int i = 0; i < pp.m_hvosStTxtPara.Length; ++i)
					{
						mp.AddMilestone(1);
					}
				}

				// Preload all the paragraphs.
				cache.PreloadIfMissing(hvosStTxtPara, (int)StTxtPara.StTxtParaTags.kflidContents, 0, false);

				// Parse each text to load our paragraph and wordform segment annotations.
				int cPara = 0;
				using (SuppressSubTasks suppressor = new SuppressSubTasks(cache, true))
				{
					foreach (IStTxtPara para in new FdoObjectSet<IStTxtPara>(cache, pp.m_hvosStTxtPara, false))
					{
						++cPara;
						pp.Parse(para, matcher, line);
						progress.SetMilestone();
						progress.Breath();
						if (pp.m_matchingAnnotations != null &&
							pp.m_matchingAnnotations.Count >= ConcordanceControl.MaxConcordanceMatches())
						{
							MessageBox.Show(String.Format(ITextStrings.ksShowingOnlyTheFirstXXXMatches,
								pp.m_matchingAnnotations.Count, cPara, pp.m_hvosStTxtPara.Length),
								ITextStrings.ksNotice, MessageBoxButtons.OK, MessageBoxIcon.Information);
							break;
						}
					}
					pp.CleanupLeftoverAnnotations(progress);
				}
				progress.SetMilestone();
				progress.Breath();
				(pp.m_wfi as WordformInventory).SuspendUpdatingConcordanceWordforms = false;
				return pp.m_matchingAnnotations;
			}
		}