本文整理汇总了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;
}
示例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;
}
示例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));
}