本文整理汇总了C#中TextSource.ClientRunChanged方法的典型用法代码示例。如果您正苦于以下问题:C# TextSource.ClientRunChanged方法的具体用法?C# TextSource.ClientRunChanged怎么用?C# TextSource.ClientRunChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextSource
的用法示例。
在下文中一共展示了TextSource.ClientRunChanged方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StringChangedTests
public void StringChangedTests()
{
string part0 = "abc";
AssembledStyles styles = new AssembledStyles().WithWs(wsEn);
StringClientRun clientRun0 = new StringClientRun(part0, styles);
var clientRuns = new List<IClientRun>();
clientRuns.Add(clientRun0);
TextSource source = new TextSource(clientRuns);
List<IRenderRun> renderRuns = source.RenderRuns;
VerifyRenderRun(renderRuns[0], 0, 3, "initial state has all in one run");
var clientRun1 = new StringClientRun("abcd", styles);
var output1 = source.ClientRunChanged(0, clientRun1);
Assert.AreEqual(1, output1.NewSource.RenderRuns.Count, "replacing single run with simple string should produce single render run.");
VerifyRenderRun(output1.NewSource.RenderRuns[0], 0, 4, "replacing client run should make a new source with modified single run");
Assert.AreEqual(3, output1.StartChange);
Assert.AreEqual(0, output1.DeleteCount);
Assert.AreEqual(1, output1.InsertCount);
// try changing the middle of three runs, from a simple one to a complex one.
clientRuns = new List<IClientRun>();
clientRuns.Add(clientRun0);
string part2 = "def";
var clientRun2 = new StringClientRun(part2, styles);
clientRuns.Add(clientRun2);
string part3 = " mnop";
var clientRun3 = new StringClientRun(part3, styles);
clientRuns.Add(clientRun3);
source = new TextSource(clientRuns, MockInterpretOrc);
string part4 = "q\xfffc";
var clientRun4 = new StringClientRun(part4, styles);
var output2 = source.ClientRunChanged(1, clientRun4);
Assert.AreEqual(3, output2.NewSource.RenderRuns.Count,
"three render runs because ORC interprets as french string.");
VerifyRenderRun(output2.NewSource.RenderRuns[0], 0, part0.Length + 1, "first run up to ORC");
VerifyRenderRun(output2.NewSource.RenderRuns[1], part0.Length + 1, orcText.Length, "second run is French from ORC");
VerifyRenderRun(output2.NewSource.RenderRuns[2], part0.Length + 1 + orcText.Length, part3.Length, "third run is stuff after ORC");
VerifyFetch(output2.NewSource, 0, output2.NewSource.Length, part0 + "q" + orcText + part3);
Assert.AreEqual(part0.Length, output2.StartChange);
Assert.AreEqual(part2.Length, output2.DeleteCount);
Assert.AreEqual(1 + orcText.Length, output2.InsertCount);
// Now do a variation where some of the new run survives at each end.
// To catch a tricky special case, we want to replace some regular text with an ORC
// that expands to the same thing.
var bldr = tsf.MakeString("de" + orcText, wsEn).GetBldr();
bldr.SetIntPropValues(2, 2 + orcText.Length, (int)FwTextPropType.ktptWs,
(int) FwTextPropVar.ktpvDefault, wsFrn);
var clientRunFakeOrc = new TssClientRun(bldr.GetString(), styles);
clientRuns = new List<IClientRun>();
clientRuns.Add(clientRun0);
clientRuns.Add(clientRunFakeOrc);
clientRuns.Add(clientRun3);
source = new TextSource(clientRuns, MockInterpretOrc);
string partDeqOrc = "deq\xfffc";
var clientRun5 = new StringClientRun(partDeqOrc, styles);
var output3 = source.ClientRunChanged(1, clientRun5);
Assert.AreEqual(3, output3.NewSource.RenderRuns.Count,
"three render runs because ORC interprets as french string.");
VerifyRenderRun(output3.NewSource.RenderRuns[0], 0, part0.Length + 3, "first run up to ORC");
VerifyRenderRun(output3.NewSource.RenderRuns[1], part0.Length + 3, orcText.Length, "second run is French from ORC");
VerifyRenderRun(output3.NewSource.RenderRuns[2], part0.Length + 3 + orcText.Length, part3.Length, "third run is stuff after ORC");
VerifyFetch(output3.NewSource, 0, output3.NewSource.Length, part0 + "deq" + orcText + part3);
// This should be interpreted as inserting the "q" after the "de" and before the orc text.
Assert.AreEqual(part0.Length + 2, output3.StartChange);
Assert.AreEqual(0, output3.DeleteCount);
Assert.AreEqual(1, output3.InsertCount);
// special case where nothing changes.
clientRuns = new List<IClientRun>();
clientRuns.Add(clientRun0);
clientRuns.Add(clientRun2);
source = new TextSource(clientRuns, MockInterpretOrc);
var output4 = source.ClientRunChanged(1, clientRun2);
Assert.AreEqual(1, output4.NewSource.RenderRuns.Count, "two client runs collapse to one render");
VerifyRenderRun(output4.NewSource.RenderRuns[0], 0, part0.Length + part2.Length, "run has expected length");
VerifyFetch(output4.NewSource, 0, output4.NewSource.Length, part0 + part2);
Assert.AreEqual(part0.Length, output4.StartChange);
Assert.AreEqual(0, output4.DeleteCount);
Assert.AreEqual(0, output4.InsertCount);
}