SelectAtStart() public méthode

public SelectAtStart ( ) : InsertionPoint
Résultat SIL.FieldWorks.SharpViews.Selections.InsertionPoint
Exemple #1
0
		public void ValidSelections()
		{
			AssembledStyles styles = new AssembledStyles();
			var clientRuns = new List<IClientRun>();
			var run0 = new StringClientRun("First run", styles);
			var run1 = new StringClientRun("Middle run", styles);
			BlockBox box0 = new BlockBox(styles, Color.Red, 72000, 36000);
			var run2 = new StringClientRun("Last run", styles);
			clientRuns.Add(run0);
			clientRuns.Add(run1);
			clientRuns.Add(box0);
			clientRuns.Add(run2);
			TextSource source = new TextSource(clientRuns, null);
			ParaBox para0 = new ParaBox(styles, source);
			run0.Hookup = new LiteralStringParaHookup(para0, para0);
			run1.Hookup = new LiteralStringParaHookup(para0, para0);
			run2.Hookup = new LiteralStringParaHookup(para0, para0);
			DivBox div = new DivBox(styles);
			RootBox root = new RootBox(styles);
			para0.Container = div;
			MockGraphics graphics = new MockGraphics();
			LayoutInfo layoutArgs = ParaBuilderTests.MakeLayoutInfo(100, graphics);
			root.Layout(layoutArgs);

			root.AddBox(div);
			var sel = para0.SelectAtStart();
			root.Selection = sel;

			Assert.That(!root.Selection.IsValid);

			div.AddBox(para0);
			root.RemoveBoxes(div, div);
			div.Container = root;

			Assert.That(!root.Selection.IsValid);

			root.AddBox(div);

			Assert.That(root.Selection.IsValid);

			(root.Selection as InsertionPoint).Hookup.ClientRunIndex = 4;

			Assert.That(!root.Selection.IsValid);

			(root.Selection as InsertionPoint).Hookup.ClientRunIndex = 2;

			Assert.That(!root.Selection.IsValid);

			(root.Selection as InsertionPoint).Hookup.ClientRunIndex = 0;
			(root.Selection as InsertionPoint).StringPosition = 10;

			Assert.That(!root.Selection.IsValid);

			(root.Selection as InsertionPoint).StringPosition = 0;
			run0.Hookup = null;

			Assert.That(!root.Selection.IsValid);

			run0.Hookup = new LiteralStringParaHookup(para0, para0);
			sel = para0.SelectAtStart();
			root.Selection = sel;

			Assert.That(root.Selection.IsValid);
		}