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


C# ITsString.GetBoundsOfRun方法代码示例

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


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

示例1: CrawlRuns

		/// <summary>
		/// Crawls all runs in the specified string. The run modifier is called for each run in the
		/// specified string. If the run modifier returns <c>null</c>, the run is removed from
		/// the string. If all runs are removed, this method returns <c>null</c>.
		/// </summary>
		/// <param name="str">The string.</param>
		/// <param name="runModifier">The run modifier.</param>
		/// <returns></returns>
		public static ITsString CrawlRuns(ITsString str, Func<ITsString, ITsString> runModifier)
		{
			ITsIncStrBldr tisb = TsIncStrBldrClass.Create();
			bool modified = false;
			bool empty = true;
			for (int i = 0; i < str.RunCount; i++)
			{
				int ichMin, ichLim;
				str.GetBoundsOfRun(i, out ichMin, out ichLim);
				var oldRun = str.GetSubstring(ichMin, ichLim);
				var newRun = runModifier(oldRun);
				modified = modified || newRun != oldRun;
				if (newRun != null)
				{
					tisb.AppendTsString(newRun);
					empty = false;
				}
			}

			if (empty)
				return null;

			return modified ? tisb.GetString() : str;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:32,代码来源:StringServices.cs

示例2: ConvertCVNumbersInStringForBT

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Return a TsString in which any CV numbers have been replaced by their BT equivalents
		/// (in the specified writing system). Other properties, including style, are copied
		/// from the input numbers.
		/// </summary>
		/// <param name="input">The input.</param>
		/// <param name="wsTrans">The ws trans.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public ITsString ConvertCVNumbersInStringForBT(ITsString input, int wsTrans)
		{
			ITsStrBldr bldr = null;
			// reverse order so we don't mess up offsets if new numbers differ in length.
			for (int iRun = input.RunCount - 1; iRun >= 0; iRun--)
			{
				string styleName = input.get_Properties(iRun).GetStrPropValue(
					(int)FwTextPropType.ktptNamedStyle);

				if (styleName == ScrStyleNames.ChapterNumber ||
					styleName == ScrStyleNames.VerseNumber)
				{
					string number = ConvertVerseChapterNumForBT(input.get_RunText(iRun));
					if (number == null)
						continue; // pathologically an empty string has verse number style??
					if (bldr == null)
						bldr = input.GetBldr(); // we have an actual change.
					int ichMin, ichLim;
					input.GetBoundsOfRun(iRun, out ichMin, out ichLim);
					bldr.SetIntPropValues(ichMin, ichLim, (int)FwTextPropType.ktptWs,
						(int)FwTextPropVar.ktpvDefault, wsTrans);
					bldr.Replace(ichMin, ichLim, number, null);
				}
			}
			if (bldr != null)
				return bldr.GetString();
			return input;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:38,代码来源:FdoScripture.cs

示例3: VerifyObjData

		private void VerifyObjData(ITsString tss, int ichMin, int ichLim, string newPath)
		{
			var objData = tss.get_StringPropertyAt(ichMin, (int)FwTextPropType.ktptObjData);
			Assert.That(objData, Is.Not.Null);
			Assert.That(objData.Length, Is.GreaterThan(1));
			Assert.That(objData[0], Is.EqualTo(Convert.ToChar((int)FwObjDataTypes.kodtExternalPathName)));
			Assert.That(objData.Substring(1), Is.EqualTo(newPath));
			int ichMinActual, ichLimActual;
			tss.GetBoundsOfRun(tss.get_RunAt(ichMin), out ichMinActual, out ichLimActual);
			Assert.That(ichLimActual, Is.EqualTo(ichLim));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:11,代码来源:StringServicesTests.cs


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