• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# AssembledStyles类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AssembledStyles的典型用法代码示例。如果您正苦于以下问题:C# AssembledStyles类的具体用法?C# AssembledStyles怎么用?C# AssembledStyles使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AssembledStyles类属于命名空间,在下文中一共展示了AssembledStyles类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DrawIPMultiRunPara

		public void DrawIPMultiRunPara()
		{
			var styles = new AssembledStyles();
			RootBox root = new RootBoxFdo(styles);
			root.Builder.Show(Paragraph.Containing(
				Display.Of("first"), Display.Of("second"), Display.Of("third")));
			SetupFakeRootSite(root);
			var layoutInfo = HookupTests.MakeLayoutInfo(int.MaxValue / 2, m_gm.VwGraphics, 55);
			root.Layout(layoutInfo);
			InsertionPoint ip = root.SelectAtEnd();
			ip.Install();
			var para = (ParaBox) root.FirstBox;
			Assert.AreEqual(ip, root.Selection);
			Assert.AreEqual(para, ip.Para, "IP should know about the paragraph it is in");
			Assert.AreEqual("third".Length, ip.StringPosition, "IP position is relative to run");
			Assert.AreEqual(true, ip.AssociatePrevious, "selection at end should always associate previous in non-empty para");


			StringBox sbox = para.FirstBox as StringBox;
			Assert.That(sbox, Is.EqualTo(para.LastBox), "uniform text in infinite width should make one string box");
			var seg = sbox.Segment as FakeSegment;
			Assert.IsNotNull(seg);
			PaintTransform ptrans = new PaintTransform(2, 4, 96, 100, 0, -10, 120, 128);
			ip.Draw(m_gm.VwGraphics, ptrans);
			VerifySegmentDrawing(para, sbox, seg.LastDrawIpCall, -4);

			seg.NextPosIpResult = new MockSegment.PositionsOfIpResults();
			seg.NextPosIpResult.RectPrimary = new Rect(5, 6, 7, 9);
			seg.NextPosIpResult.PrimaryHere = true;
			Rectangle selRect = ip.GetSelectionLocation(m_gm.VwGraphics, ptrans);
			VerifySelLocation(para, sbox, seg.LastPosIpCall, -4);
			Assert.AreEqual(new Rectangle(5, 6, 2, 3), selRect);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:33,代码来源:InsertionPointTests.cs


示例2: Relayout

		public void Relayout()
		{
			var styles = new AssembledStyles();
			var box = new MockBox(styles);
			var fixMap = new Dictionary<Box, Rectangle>();
			var layoutInfo = ParaBuilderTests.MakeLayoutInfo(100, m_gm.VwGraphics);
			var site = new MockSite();
			var root = new RootBox(styles);
			root.Site = site;

			using (var lcb = new LayoutCallbacks(root))
			{
				Assert.IsFalse(box.Relayout(layoutInfo, fixMap, lcb),
					"Relayout of box never laid out should return false (can't have old loc)");
			}
			Assert.AreEqual(layoutInfo, box.LastLayoutTransform, "Relayout of box never laid out should call Layout() with same transform");
			Assert.AreEqual(0, site.RectsInvalidated.Count, "Relayout of box never laid out should not invalidate anything");

			box.LastLayoutTransform = null;
			using (var lcb = new LayoutCallbacks(root))
				Assert.IsFalse(box.Relayout(layoutInfo, fixMap, lcb), "Relayout of box not in map should return false");
			Assert.IsNull(box.LastLayoutTransform, "Relayout of box not in map should not call Layout()");
			Assert.AreEqual(0, site.RectsInvalidated.Count, "Relayout of box not in map should not invalidate anything");

			fixMap[box] = new Rectangle(2,3,4,7);
			using (var lcb = new LayoutCallbacks(root))
				Assert.IsTrue(box.Relayout(layoutInfo, fixMap, lcb), "Relayout of box in map should return true");
			Assert.AreEqual(layoutInfo, box.LastLayoutTransform, "Relayout of box in map should call Layout() with same transform");
			Assert.AreEqual(1, site.RectsInvalidatedInRoot.Count, "Relayout of box in map should invalidate rect from map");
			Assert.AreEqual(new Rectangle(2, 3, 4, 7), site.RectsInvalidatedInRoot[0], "Relayout of box in map should invalidate proper rect");
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:31,代码来源:BoxTests.cs


示例3: PaintParaBox

		public void PaintParaBox()
		{
			AssembledStyles styles = new AssembledStyles();
			var clientRuns = new List<IClientRun>();
			BlockBox box0 = new BlockBox(styles, Color.Red, 72000, 36000);
			clientRuns.Add(box0);
			BlockBox box1 = new BlockBox(styles, Color.Blue, 36000, 18000);
			clientRuns.Add(box1);
			BlockBox box2 = new BlockBox(styles, Color.Red, 24000, 18000);
			clientRuns.Add(box2);
			BlockBox box3 = new BlockBox(styles, Color.Red, 72000, 36000);
			clientRuns.Add(box3);
			BlockBox box4 = new BlockBox(styles, Color.Red, 36000, 36000);
			clientRuns.Add(box4);

			TextSource source = new TextSource(clientRuns, null);
			ParaBox para = new ParaBox(styles, source);
			RootBox root = new RootBox(styles);
			root.AddBox(para);

			MockGraphics graphics = new MockGraphics();
			LayoutInfo layoutArgs = ParaBuilderTests.MakeLayoutInfo(100, graphics);
			root.Layout(layoutArgs);

			PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96);
			root.Paint(graphics, ptrans);
			Assert.AreEqual(5, graphics.RectanglesDrawn.Count);
			VerifyRect(2, 2, 96, 48, graphics, 0, Color.Red);
			VerifyRect(2, 48+2, 48, 24, graphics, 1, Color.Blue);
			VerifyRect(2+48, 48 + 2, 32, 24, graphics, 2, Color.Red);
			VerifyRect(2, 24 + 48 + 2, 96, 48, graphics, 3, Color.Red);
			VerifyRect(2, 48 + 24 + 48 + 2, 48, 48, graphics, 4, Color.Red);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:33,代码来源:ParaTests.cs


示例4: Select

		public void Select()
		{
			var styles = new AssembledStyles();
			var root = new RootBoxFdo(styles);
			var mock1 = new MockData1(23, 23);
			mock1.SimpleThree = "new old contents";
			var engine = new FakeRenderEngine() { Ws = 23, SegmentHeight = 13 };
			var factory = new FakeRendererFactory();
			factory.SetRenderer(23, engine);
			root.Builder.Show(Display.Of(() => mock1.SimpleThree, 23));
			var layoutArgs = MakeLayoutInfo(Int32.MaxValue / 2, m_gm.VwGraphics, factory);
			root.Layout(layoutArgs);
			PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96);
			MockSite site = new MockSite();
			site.m_transform = ptrans;
			site.m_vwGraphics = m_gm.VwGraphics;
			root.Site = site;

			int x = FakeRenderEngine.SimulatedWidth("new ") + 2;
			var location = new Point(x, 8);
			EventArgs e = new EventArgs();
			MouseEventArgs m = new MouseEventArgs(MouseButtons.Left, 1, location.X, location.Y, 0);

			root.OnMouseDown(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnDoubleClick(e);
			Assert.That(!root.Selection.IsInsertionPoint, "Should be ranged selection");
			Assert.That((root.Selection as RangeSelection).SelectedText(), Is.EqualTo("old "));

			mock1.SimpleThree = "new old:contents";
			x = FakeRenderEngine.SimulatedWidth("new o") + 2;
			location = new Point(x, 8);
			m = new MouseEventArgs(MouseButtons.Left, 1, location.X, location.Y, 0);
			root.OnMouseDown(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnMouseClick(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnDoubleClick(e);
			Assert.That(!root.Selection.IsInsertionPoint, "Should be ranged selection");
			Assert.That((root.Selection as RangeSelection).SelectedText(), Is.EqualTo("old"));

			mock1.SimpleThree = "new(old contents";
			x = FakeRenderEngine.SimulatedWidth("new ol") + 2;
			location = new Point(x, 8);
			m = new MouseEventArgs(MouseButtons.Left, 1, location.X, location.Y, 0);
			root.OnMouseDown(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnMouseClick(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnDoubleClick(e);
			Assert.That(!root.Selection.IsInsertionPoint, "Should be ranged selection");
			Assert.That((root.Selection as RangeSelection).SelectedText(), Is.EqualTo("old "));

			mock1.SimpleThree = "newo1dcontents";
			x = FakeRenderEngine.SimulatedWidth("new o1d") + 2;
			location = new Point(x, 8);
			m = new MouseEventArgs(MouseButtons.Left, 1, location.X, location.Y, 0);
			root.OnMouseDown(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnMouseClick(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnDoubleClick(e);
			Assert.That(!root.Selection.IsInsertionPoint, "Should be ranged selection");
			Assert.That((root.Selection as RangeSelection).SelectedText(), Is.EqualTo("newo1dcontents"));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:58,代码来源:DoubleClickTests.cs


示例5: StringsInSource

		public void StringsInSource()
		{
			ITsString tss = tsf.MakeString("abc def", wsEn);
			AssembledStyles styles = new AssembledStyles();
			TssClientRun clientRun = new TssClientRun(tss, styles);
			var clientRuns = new List<IClientRun>();
			clientRuns.Add(clientRun);
			TextSource ts = new TextSource(clientRuns);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:9,代码来源:TextSourceTests.cs


示例6: MakeBlockBox

		public void MakeBlockBox()
		{
			AssembledStyles styles = new AssembledStyles();
			BlockBox box = new BlockBox(styles, Color.Red, 72000, 36000);

			LayoutInfo transform = MakeLayoutInfo();
			box.Layout(transform);
			Assert.AreEqual(48, box.Height);
			Assert.AreEqual(96, box.Width);
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:10,代码来源:SimpleBoxTests.cs


示例7: BasicDrop

		public void BasicDrop()
		{
			var styles = new AssembledStyles();
			var root = new RootBoxFdo(styles);
			var mock1 = new MockData1(23, 23);
			mock1.SimpleThree = "old contents";
			var engine = new FakeRenderEngine() { Ws = 23, SegmentHeight = 13 };
			var factory = new FakeRendererFactory();
			factory.SetRenderer(23, engine);
			root.Builder.Show(Display.Of(() => mock1.SimpleThree, 23));
			var layoutArgs = MakeLayoutInfo(Int32.MaxValue / 2, m_gm.VwGraphics, factory);
			root.Layout(layoutArgs);
			PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96);
			MockSite site = new MockSite();
			site.m_transform = ptrans;
			site.m_vwGraphics = m_gm.VwGraphics;
			root.Site = site;

			var dataObj = new DataObject(DataFormats.StringFormat, "new ");
			int x = FakeRenderEngine.SimulatedWidth("old ") + 2;
			var location = new Point(x, 8);

			// A drag to where we can drop, allowing both copy and move, no keys held
			var dragArgs = new DragEventArgs(dataObj, (int) DragDropKeyStates.None, 200,300,
				DragDropEffects.Copy | DragDropEffects.Move,
				DragDropEffects.None);
			root.OnDragEnter(dragArgs, location, m_gm.VwGraphics, ptrans);
			Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.Move));
			Assert.That(root.DragState, Is.EqualTo(WindowDragState.DraggingHere));
			root.OnDragLeave();
			Assert.That(root.DragState, Is.EqualTo(WindowDragState.None));

			// Though other factors would favor move, only copy is allowed here.
			dragArgs = new DragEventArgs(dataObj, (int)DragDropKeyStates.None, 200,300,
				DragDropEffects.Copy,
				DragDropEffects.None);
			root.OnDragEnter(dragArgs, location, m_gm.VwGraphics, ptrans);
			Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.Copy));

			// Though otherwise we could copy, there is no text data in the data object.
			dragArgs = new DragEventArgs(new DataObject(), (int)DragDropKeyStates.None, 200,300,
				DragDropEffects.Copy | DragDropEffects.Move,
				DragDropEffects.None);
			root.OnDragEnter(dragArgs, location, m_gm.VwGraphics, ptrans);
			Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.None));

			dragArgs = new DragEventArgs(dataObj, (int)DragDropKeyStates.ControlKey, 200,300,
				DragDropEffects.Copy | DragDropEffects.Move,
				DragDropEffects.None);
			root.OnDragEnter(dragArgs, location, m_gm.VwGraphics, ptrans);
			Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.Copy));

			root.OnDragDrop(dragArgs, location, m_gm.VwGraphics, ptrans);
			Assert.That(mock1.SimpleThree, Is.EqualTo("old new contents"));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:55,代码来源:DragAndDropTests.cs


示例8: DragStartsOnMoveInSelection

		public void DragStartsOnMoveInSelection()
		{
			string contents = "This is the day.";
			var engine = new FakeRenderEngine() {Ws = 34, SegmentHeight = 13};
			var factory = new FakeRendererFactory();
			factory.SetRenderer(34, engine);
			var styles = new AssembledStyles().WithWs(34);
			var clientRuns = new List<IClientRun>();
			var run = new StringClientRun(contents, styles);
			clientRuns.Add(run);
			var source = new TextSource(clientRuns, null);
			var para = new ParaBox(styles, source);
			var extraBox = new BlockBox(styles, Color.Red, 50, 72000); // tall, narrow spacer at top
			var root = new RootBoxFdo(styles);
			root.AddBox(extraBox);
			root.AddBox(para);
			var layoutArgs = MakeLayoutInfo(Int32.MaxValue/2, m_gm.VwGraphics, factory);
			root.Layout(layoutArgs);
			Assert.That(root.Height, Is.EqualTo(96 + 13));
			Assert.That(root.Width, Is.EqualTo(FakeRenderEngine.SimulatedWidth(contents)));

			var ip1 = run.SelectAt(para, 5, false);
			var ip2 = run.SelectAt(para, 7, true);
			var range = new RangeSelection(ip1, ip2);
			range.Install();
			PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96);
			var sbox = para.FirstBox as StringBox;
			MockSite site = new MockSite();
			site.m_transform = ptrans;
			site.m_vwGraphics = m_gm.VwGraphics;
			root.Site = site;
			int indent = FakeRenderEngine.SimulatedWidth("This ");
			root.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, indent + 5, 100, 0), Keys.None, m_gm.VwGraphics, ptrans);
			root.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, indent + 5, 100, 0), Keys.None, m_gm.VwGraphics, ptrans);
			Assert.That(GetStringDropData(site), Is.EqualTo("is"));
			Assert.That(site.LastDoDragDropArgs.AllowedEffects, Is.EqualTo(DragDropEffects.Copy),
				"editing not possible in this paragraph, we can only copy");
			Assert.That(root.Selection, Is.EqualTo(range), "selection should not be changed by drag drop");
			site.LastDoDragDropArgs = null;
			root.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 3, 100, 0), Keys.None, m_gm.VwGraphics, ptrans);
			Assert.That(site.LastDoDragDropArgs, Is.Null, "click outside selection should not initiate drag");

			// Tack on an extra check that a read-only view does not handle drop.
			var dataObj = new DataObject(DataFormats.StringFormat, "new ");
			var dragArgs = new DragEventArgs(dataObj, (int)DragDropKeyStates.ControlKey, 10, 8,
				DragDropEffects.Copy | DragDropEffects.Move,
				DragDropEffects.None);
			root.OnDragEnter(dragArgs, new Point(14, 8), m_gm.VwGraphics, ptrans);
			Assert.That(dragArgs.Effect, Is.EqualTo(DragDropEffects.None));
			Assert.That(root.DragState, Is.EqualTo(WindowDragState.DraggingHere));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:51,代码来源:DragAndDropTests.cs


示例9: MakeRootBox

		public void MakeRootBox()
		{
			AssembledStyles styles = new AssembledStyles();
			BlockBox box = new BlockBox(styles, Color.Red, 72000, 36000);

			RootBox root = new RootBox(styles);
			root.AddBox(box);
			LayoutInfo transform = MakeLayoutInfo();
			root.Layout(transform);

			Assert.AreEqual(48, box.Height);
			Assert.AreEqual(96, box.Width);
			Assert.AreEqual(48, root.Height);
			Assert.AreEqual(96, root.Width);

		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:16,代码来源:SimpleBoxTests.cs


示例10: PaintBarBox

		public void PaintBarBox()
		{
			AssembledStyles styles = new AssembledStyles();
			BlockBox box = new BlockBox(styles, Color.Red, 72000, 36000);

			RootBox root = new RootBox(styles);
			root.AddBox(box);
			LayoutInfo transform = MakeLayoutInfo();
			root.Layout(transform);

			PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96);
			MockGraphics graphics = new MockGraphics();
			root.Paint(graphics, ptrans);
			Assert.AreEqual(1, graphics.RectanglesDrawn.Count);
			Assert.AreEqual(new Rectangle(2, 2, 96, 48), graphics.RectanglesDrawn[0]);
			Assert.AreEqual((int)ColorUtil.ConvertColorToBGR(Color.Red), graphics.BackColor);
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:17,代码来源:SimpleBoxTests.cs


示例11: OneBlockPara

		public void OneBlockPara()
		{
			AssembledStyles styles = new AssembledStyles();
			List<IClientRun> clientRuns = new List<IClientRun>();
			BlockBox box = new BlockBox(styles, Color.Red, 72000, 36000);
			clientRuns.Add(box);

			TextSource source = new TextSource(clientRuns, null);
			ParaBox para = new ParaBox(styles, source);
			RootBox root = new RootBox(styles);
			root.AddBox(para);
			LayoutInfo layoutArgs = MakeLayoutInfo();
			root.Layout(layoutArgs);
			Assert.AreEqual(48, box.Height);
			Assert.AreEqual(96, box.Width);
			Assert.AreEqual(48, root.Height);
			Assert.AreEqual(96, root.Width);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:18,代码来源:ParaBuilderTests.cs


示例12: PaintPictureBox

		public void PaintPictureBox()
		{
			AssembledStyles styles = new AssembledStyles();
			Bitmap bm = new Bitmap(20, 30);
			ImageBox box = new ImageBox(styles.WithMargins(new Thickness(72.0 / 96.0 * 2.0))
				.WithBorders(new Thickness(72.0 / 96.0 * 3.0))
				.WithPads(new Thickness(72.0 / 96.0 * 7.0, 72.0 / 96.0 * 8.0, 72.0 / 96.0 * 11.0, 72.0 / 96.0 * 13.0)), bm);

			RootBox root = new RootBox(styles);
			BlockBox block = new BlockBox(styles, Color.Yellow, 2000, 4000);
			root.AddBox(block);
			root.AddBox(box);
			LayoutInfo transform = MakeLayoutInfo();
			root.Layout(transform);
			Assert.That(box.Height, Is.EqualTo(30 + 2*2+3*2+8+13));
			Assert.That(box.Width, Is.EqualTo(20 + 2*2 +3*2 + 7 + 11));
			Assert.That(box.Ascent, Is.EqualTo(box.Height));

			PaintTransform ptrans = new PaintTransform(2, 4, 96, 96, 10, 40, 96, 96);
			MockGraphics graphics = new MockGraphics();
			root.Paint(graphics, ptrans);
			Assert.That(graphics.LastRenderPictureArgs, Is.Not.Null);
			Assert.That(graphics.LastRenderPictureArgs.Picture, Is.EqualTo(box.Picture));
			Assert.That(graphics.LastRenderPictureArgs.X, Is.EqualTo(2-10 + 2 + 3 + 7));
			Assert.That(graphics.LastRenderPictureArgs.Y, Is.EqualTo(4 - 40 + block.Height + 2 + 3 + 8));
			Assert.That(graphics.LastRenderPictureArgs.Cx, Is.EqualTo(20));
			Assert.That(graphics.LastRenderPictureArgs.Cy, Is.EqualTo(30));
			int hmWidth = box.Picture.Width;
			int hmHeight = box.Picture.Height;
			Assert.That(graphics.LastRenderPictureArgs.XSrc, Is.EqualTo(0));
			Assert.That(graphics.LastRenderPictureArgs.YSrc, Is.EqualTo(hmHeight));
			Assert.That(graphics.LastRenderPictureArgs.CxSrc, Is.EqualTo(hmWidth));
			Assert.That(graphics.LastRenderPictureArgs.CySrc, Is.EqualTo(-hmHeight));
			Assert.That(graphics.LastRenderPictureArgs.RcWBounds.left, Is.EqualTo(2 - 10 + 2 + 3 + 7));
			Assert.That(graphics.LastRenderPictureArgs.RcWBounds.top, Is.EqualTo(4 - 40 + block.Height + 2 + 3 + 8));
			Assert.That(graphics.LastRenderPictureArgs.RcWBounds.right, Is.EqualTo(2 - 10 + 2 + 3 + 7 + 20));
			Assert.That(graphics.LastRenderPictureArgs.RcWBounds.bottom, Is.EqualTo(4 - 40 + block.Height + 2 + 3 + 8 + 30));
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:38,代码来源:SimpleBoxTests.cs


示例13: PrepareDivFixupMap

		public void PrepareDivFixupMap()
		{
			var styles = new AssembledStyles();
			var div = new FixedSizeDiv(styles, 27, 37);
			var root = new FixedSizeRoot(styles, 49, 59);
			var block = new BlockBox(styles, Color.Red, 6000, 8000);
			div.AddBox(block);
			root.AddBox(div);
			div.Left = 5;
			div.Top = 7;
			block.Left = 10;
			block.Top = 20;
			var transform = new LayoutInfo(0, 0, 72, 72, 1000, m_gm.VwGraphics, new MockRendererFactory());
			block.Layout(transform);
			//Assert.AreEqual(6, block.Width); // sanity check: we made it 4000 mp wide at 72 dpi, that's 4 points at one point per dot
			var map = block.PrepareFixupMap();
			var invalidRect = map[block];
			Assert.AreEqual(new Rectangle(5 + 10 - 2, 7 + 20 - 2, 6 + 4, 8 + 4), invalidRect);
			invalidRect = map[div];
			Assert.AreEqual(new Rectangle(5 - 2, 7 - 2, 27 + 4, 37 + 4), invalidRect);
			invalidRect = map[root];
			Assert.AreEqual(new Rectangle(- 2, - 2, 49 + 4, 59 + 4), invalidRect);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:23,代码来源:BoxTests.cs


示例14: TssRuns

		public void TssRuns()
		{
			string part1 = "abc def";
			ITsString tss = tsf.MakeString(part1, wsEn);
			AssembledStyles styles = new AssembledStyles();
			TssClientRun clientRun = new TssClientRun(tss, styles);
			Assert.AreEqual(1, clientRun.UniformRunCount);
			Assert.AreEqual(part1, clientRun.UniformRunText(0));
			AssembledStyles style1 = clientRun.UniformRunStyles(0);
			Assert.AreEqual(wsEn, style1.Ws);
			Assert.AreEqual(0, clientRun.UniformRunStart(0));
			Assert.AreEqual(part1.Length, clientRun.UniformRunLength(0));

			string part2 = " ghi";
			ITsStrBldr bldr = tss.GetBldr();
			bldr.Replace(part1.Length, part1.Length, part2, ttpFrn);
			TssClientRun clientRun2 = new TssClientRun(bldr.GetString(), styles);
			Assert.AreEqual(2, clientRun2.UniformRunCount);
			Assert.AreEqual(part1, clientRun2.UniformRunText(0));
			Assert.AreEqual(part2, clientRun2.UniformRunText(1));
			style1 = clientRun2.UniformRunStyles(0);
			Assert.AreEqual(wsEn, style1.Ws);
			AssembledStyles style2 = clientRun2.UniformRunStyles(1);
			Assert.AreEqual(wsFrn, style2.Ws);
			Assert.AreEqual(0, clientRun2.UniformRunStart(0));
			Assert.AreEqual(part1.Length, clientRun2.UniformRunLength(0));
			Assert.AreEqual(part1.Length, clientRun2.UniformRunStart(1));
			Assert.AreEqual(part2.Length, clientRun2.UniformRunLength(1));

			var source = new TextSource(new List<IClientRun>(new [] {clientRun2}));
			var runs = source.Runs;
			Assert.That(runs.Length, Is.EqualTo(2));
			Assert.That(runs[0].LogLength, Is.EqualTo(part1.Length));
			Assert.That(runs[1].LogLength, Is.EqualTo(part2.Length));
			Assert.That(runs[1].LogStart, Is.EqualTo(part1.Length));
			Assert.That(runs[1].Offset, Is.EqualTo(0)); // nothing fancy with ORCs, run starts at 0 in uniform run.
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:37,代码来源:TextSourceTests.cs


示例15: PileOfBlocksLayout

		public void PileOfBlocksLayout()
		{
			var styles = new AssembledStyles();
			BlockBox box1 = new BlockBox(styles, Color.Red, 72000, 36000);
			BlockBox box2 = new BlockBox(styles, Color.Blue, 108000, 18000);
			BlockBox box3 = new BlockBox(styles, Color.Orange, 72000, 18000);
			RootBox root = new RootBox(styles);
			root.AddBox(box1);
			root.AddBox(box2);
			root.AddBox(box3);
			LayoutInfo layoutArgs = MakeLayoutInfo();
			root.Layout(layoutArgs);
			Assert.That(box1.Height, Is.EqualTo(48));
			Assert.That(box2.Height, Is.EqualTo(24));
			Assert.That(root.Height, Is.EqualTo(48 + 24 + 24) );
			Assert.That(box1.Left, Is.EqualTo(0));
			Assert.That(box2.Left, Is.EqualTo(0));
			Assert.That(box1.Top, Is.EqualTo(0));
			Assert.That(box2.Top, Is.EqualTo(48));
			Assert.That(box3.Top, Is.EqualTo(48 + 24));
			Assert.That(box1.Width, Is.EqualTo(96));
			Assert.That(box2.Width, Is.EqualTo(144));
			Assert.That(root.Width, Is.EqualTo(144));
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:24,代码来源:PileTests.cs


示例16: DivClippedPaint

		public void DivClippedPaint()
		{
			var styles = new AssembledStyles();
			var box1 = new FgBlockBox(styles, Color.Red, 72000, 36000);
			var box2 = new FgBlockBox(styles, Color.Blue, 108000, 18000);
			var box3 = new FgBlockBox(styles, Color.Orange, 72000, 18000);
			var box4 = new FgBlockBox(styles, Color.Orange, 72000, 18000);
			var div1 = new DivBox(styles);
			div1.AddBox(box1);
			div1.AddBox(box2);
			div1.AddBox(box3);
			div1.AddBox(box4);
			RootBox root = new RootBox(styles);
			root.AddBox(div1);
			LayoutInfo layoutArgs = MakeLayoutInfo();
			root.Layout(layoutArgs);
			var rect1 = new Rectangle(0, 0, 96, 48);
			var rect2 = new Rectangle(0, 0, 144, 24);
			rect2.Offset(0, rect1.Bottom);
			var rect3 = new Rectangle(0, 0, 96, 24);
			rect3.Offset(0, rect2.Bottom);
			var rect4 = new Rectangle(0, 0, 96, 24);
			rect4.Offset(0, rect3.Bottom);
			var paintRects = new[] { rect1, rect2, rect3, rect4 };
			VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 2000), 0, 0, paintRects);
			// Clipping off the top part, but not the whole, of a box does not prevent drawing it.
			VerifyPaint(root, new Rectangle(-1000, 10, 2000, -10 + rect4.Bottom - 10), 0, 0, paintRects);
			// Even clipping all but one pixel does not prevent drawing.
			VerifyPaint(root, new Rectangle(-1000, 47, 2000, -47 + rect3.Bottom + 1), 0, 0, paintRects);
			// However if we clip a bit more we should draw less
			var middleTwo = new[] {rect2, rect3};
			VerifyPaint(root, new Rectangle(-1000, 48, 2000, -48 + rect3.Bottom - 2), 0, 0, middleTwo);
			// If the clip covers just a bit of the first box we paint just that.
			var firstOne = new[] {rect1};
			VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 1000 + 10), 0, 0, firstOne);
			// If the clip covers just a bit of the last box we paint just that.
			var lastOne = new[] { rect4 };
			VerifyPaint(root, new Rectangle(-1000, rect4.Bottom - 2, 2000, 1000), 0, 0, lastOne);
			// If the clip is entirely above the pile we draw nothing.
			VerifyPaint(root, new Rectangle(-1000, -1000, 2000, 990), 0, 0, null);
			// Likewise if entirely below.
			VerifyPaint(root, new Rectangle(-1000, rect4.Bottom + 10, 2000, 10), 0, 0, null);
			// Now try with simulated scrolling. Use a normal clip rectangle, but pretend the first two
			// and a bit boxes are scrolled off.
			var offset = rect2.Bottom + 10;
			var rect3Offset = rect3;
			rect3Offset.Offset(0, -offset);
			var rect4Offset = rect4;
			rect4Offset.Offset(0, -offset);
			var lastTwoOffset = new[] {rect3Offset, rect4Offset};
			VerifyPaint(root, new Rectangle(-1000, 0, 2000, 200), 0, offset, lastTwoOffset);
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:52,代码来源:PileTests.cs


示例17: SetWeakDirections

		public void SetWeakDirections()
		{
			var line = new ParaLine();
			var styles = new AssembledStyles();

			// no  boxes (pathological)
			line.SetWeakDirections(0);

			// no weak boxes
			line = new ParaLine();
			line.Add(MakeStringBox(styles, 3, false));
			line.SetWeakDirections(0);
			VerifyDepth(line, 0, 3);

			// one weak box alone: no change
			line = new ParaLine();
			line.Add(MakeStringBox(styles, 3, true));
			line.SetWeakDirections(1);
			VerifyDepth(line, 0, 1);

			//  one at start, followed by a non-weak
			line = new ParaLine();
			line.Add(MakeStringBox(styles, 2, true));
			line.Add(MakeStringBox(styles, 1, false));
			line.SetWeakDirections(0);
			VerifyDepth(line, 0, 0); // adjacent to paragraph boundary, topDepth wins
			line.SetWeakDirections(2);
			VerifyDepth(line, 0, 1); // adjacent box has lower depth.

			// two at start, followed by non-weak; also two at end and four in middle.
			line = new ParaLine();
			line.Add(MakeStringBox(styles, 2, true));
			line.Add(MakeStringBox(styles, 3, true));
			line.Add(MakeStringBox(styles, 1, false));
			line.Add(MakeStringBox(styles, 2, false));
			line.Add(MakeStringBox(styles, 4, true));
			line.Add(MakeStringBox(styles, 4, true));
			line.Add(MakeStringBox(styles, 4, true));
			line.Add(MakeStringBox(styles, 4, true));
			line.Add(MakeStringBox(styles, 3, false));
			line.Add(MakeStringBox(styles, 4, false));
			line.Add(MakeStringBox(styles, 5, true));
			line.Add(MakeStringBox(styles, 5, true));
			line.SetWeakDirections(6); // let the adjacent boxes rather than the paragraph depth win.
			VerifyDepth(line, 0, 1); // first two set to depth of following box
			VerifyDepth(line, 1, 1);
			VerifyDepth(line, 4, 2); // middle four set to depth of preceding box
			VerifyDepth(line, 5, 2);
			VerifyDepth(line, 6, 2);
			VerifyDepth(line, 7, 2);
			VerifyDepth(line, 10, 4); // last two set to depth of preceding
			VerifyDepth(line, 11, 4);
			line.SetWeakDirections(0); // let the adjacent boxes rather than the paragraph depth win.
			VerifyDepth(line, 0, 0); // topdepth from para boundary
			VerifyDepth(line, 1, 0);
			VerifyDepth(line, 4, 2); // middle four set to depth of preceding box
			VerifyDepth(line, 5, 2);
			VerifyDepth(line, 6, 2);
			VerifyDepth(line, 7, 2);
			VerifyDepth(line, 10, 0); // topdepth from para boundary
			VerifyDepth(line, 11, 0);

			line= new ParaLine();
			line.Add(MakeStringBox(styles, 2, false));
			line.Add(MakeStringBox(styles, 3, true));
			line.Add(new BlockBox(styles, Color.Red, 200, 300));
			line.SetWeakDirections(1); // The block box is considered to have depth 1 and wins
			VerifyDepth(line, 1, 1);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:69,代码来源:ParaBuilderTests.cs


示例18: DiffWS

		public void DiffWS()
		{
			var tsf = TsStrFactoryClass.Create();
			var styles = new AssembledStyles();
			var root = new RootBoxFdo(styles);
			var mock1 = new MockData1(23, 23);
			mock1.SimpleTwo = tsf.MakeString("newoldcontents", 23);
			var bldr = mock1.SimpleTwo.GetBldr();
			bldr.SetIntPropValues(3, 6, (int)FwTextPropType.ktptWs,
				(int)FwTextPropVar.ktpvDefault, 24);
			bldr.SetIntPropValues(6, 14, (int)FwTextPropType.ktptWs,
				(int)FwTextPropVar.ktpvDefault, 25);
			mock1.SimpleTwo = bldr.GetString();
			var engine = new FakeRenderEngine() { Ws = 23, SegmentHeight = 13 };
			var factory = new FakeRendererFactory();
			factory.SetRenderer(23, engine);
			root.Builder.Show(Display.Of(() => mock1.SimpleTwo));
			var layoutArgs = MakeLayoutInfo(Int32.MaxValue / 2, m_gm.VwGraphics, factory);
			root.Layout(layoutArgs);
			PaintTransform ptrans = new PaintTransform(2, 2, 96, 96, 0, 0, 96, 96);
			MockSite site = new MockSite();
			site.m_transform = ptrans;
			site.m_vwGraphics = m_gm.VwGraphics;
			root.Site = site;

			int x = FakeRenderEngine.SimulatedWidth("ne") + 2;
			var location = new Point(x, 8);
			EventArgs e = new EventArgs();
			MouseEventArgs m = new MouseEventArgs(MouseButtons.Left, 1, location.X, location.Y, 0);

			root.OnMouseDown(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnMouseClick(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnDoubleClick(e);
			Assert.That(!root.Selection.IsInsertionPoint, "Should be ranged selection");
			Assert.That((root.Selection as RangeSelection).SelectedText(), Is.EqualTo("new"));

			x = FakeRenderEngine.SimulatedWidth("new") + 2;
			location = new Point(x, 8);
			m = new MouseEventArgs(MouseButtons.Left, 1, location.X, location.Y, 0);
			root.OnMouseDown(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnMouseClick(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnDoubleClick(e);
			Assert.That(!root.Selection.IsInsertionPoint, "Should be ranged selection");
			Assert.That((root.Selection as RangeSelection).SelectedText(), Is.EqualTo("old"));

			x = FakeRenderEngine.SimulatedWidth("newold") + 2;
			location = new Point(x, 8);
			m = new MouseEventArgs(MouseButtons.Left, 1, location.X, location.Y, 0);
			root.OnMouseDown(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnMouseClick(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnDoubleClick(e);
			Assert.That(!root.Selection.IsInsertionPoint, "Should be ranged selection");
			Assert.That((root.Selection as RangeSelection).SelectedText(), Is.EqualTo("contents"));

			x = FakeRenderEngine.SimulatedWidth("newold");
			location = new Point(x, 8); // at the right edge of the d at the end of newold
			m = new MouseEventArgs(MouseButtons.Left, 1, location.X, location.Y, 0);
			root.OnMouseDown(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnMouseClick(m, Keys.None, site.m_vwGraphics, site.m_transform);
			root.OnDoubleClick(e);
			Assert.That(!root.Selection.IsInsertionPoint, "Should be ranged selection");
			Assert.That((root.Selection as RangeSelection).SelectedText(), Is.EqualTo("old"));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:63,代码来源:DoubleClickTests.cs


示例19: MakeStringBox

		StringBox MakeStringBox(AssembledStyles styles, int depth, bool weak)
		{
			var seg = new MockDirectionSegment() {WeakDirection = weak, DirectionDepth = depth};
			return new StringBox(styles, seg, 0);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:5,代码来源:ParaBuilderTests.cs


示例20: ReverseUpstreamBoxes

		public void ReverseUpstreamBoxes()
		{
			var line = new ParaLine();
			var styles = new AssembledStyles();

			// no  boxes (pathological)
			line.ReverseUpstreamBoxes(0, new List<Box>(), 0);

			// one box
			line = new ParaLine();
			line.Add(MakeStringBox(styles, 3, false));
			var boxes = new List<Box>(line.Boxes);
			line.ReverseUpstreamBoxes(0, boxes, 0);
			VerifyBoxOrder(line, boxes, new [] {0});

			//  two boxes: should re-order only if depth is small enough.
			line = new ParaLine();
			line.Add(MakeStringBox(styles, 2, false));
			line.Add(MakeStringBox(styles, 1, false));
			boxes = new List<Box>(line.Boxes);
			line.ReverseUpstreamBoxes(3, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 0, 1 }); // not re-ordered, all depths too small
			line.ReverseUpstreamBoxes(2, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 0, 1 }); // not re-ordered, just one that could be
			line.ReverseUpstreamBoxes(1, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 1, 0 }); // re-ordered, all <= depth
			line.ReverseUpstreamBoxes(0, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 0, 1 }); // re-ordered again, all < depth

			// quite a mixture!
			line = new ParaLine();
			MockDirectionSegment.NextIndex = 0;
			line.Add(MakeStringBox(styles, 2, false));
			line.Add(MakeStringBox(styles, 3, false));
			line.Add(MakeStringBox(styles, 1, false));
			line.Add(MakeStringBox(styles, 2, false));
			line.Add(MakeStringBox(styles, 4, false));
			line.Add(MakeStringBox(styles, 4, false));
			line.Add(MakeStringBox(styles, 4, false));
			line.Add(MakeStringBox(styles, 4, false));
			line.Add(MakeStringBox(styles, 3, false));
			line.Add(MakeStringBox(styles, 4, false));
			line.Add(MakeStringBox(styles, 5, false));
			line.Add(MakeStringBox(styles, 5, false));
			boxes = new List<Box>(line.Boxes);
			line.ReverseUpstreamBoxes(0, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 11,10,9,8,7,6,5,4,3,2,1,0 }); // reverse everything
			line.ReverseUpstreamBoxes(1, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 0,1,2,3,4,5,6,7,8,9,10,11 }); // back again
			// now the level 1 box at index 2 does not move
			line.ReverseUpstreamBoxes(2, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 1, 0, 2, 11, 10, 9, 8, 7, 6, 5, 4, 3 });
			line.ReverseUpstreamBoxes(2, boxes, 0); // put them back!
			VerifyBoxOrder(line, boxes, new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }); // back again
			line.ReverseUpstreamBoxes(4, boxes, 0); // only the groups with more 4 or more reverse
			VerifyBoxOrder(line, boxes, new[] { 0, 1, 2, 3, 7, 6, 5, 4, 8, 11, 10, 9 }); // back again

			boxes = new List<Box>(line.Boxes);
			line.ReverseUpstreamBoxes(1, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 });
			line.ReverseUpstreamBoxes(2, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 0, 1 });
			line.ReverseUpstreamBoxes(3, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 3, 11, 10, 9, 8, 7, 6, 5, 4, 2, 0, 1 });
			line.ReverseUpstreamBoxes(4, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 3, 9, 10, 11, 8, 4, 5, 6, 7, 2, 0, 1 });
			line.ReverseUpstreamBoxes(5, boxes, 0);
			VerifyBoxOrder(line, boxes, new[] { 3, 9, 11, 10, 8, 4, 5, 6, 7, 2, 0, 1 });

			boxes = new List<Box>(line.OrderedBoxes(0));
			// This should do all in one step the reversals indicated in the previous test
			// sequence. The results above indicate how the final sequence is arrived at.
			VerifyBoxOrder(line, boxes, new[] { 3, 9, 11, 10, 8, 4, 5, 6, 7, 2, 0, 1 });

			line = new ParaLine();
			line.Add(new BlockBox(styles, Color.Red, 200, 300));
			line.Add(MakeStringBox(styles, 2, true));
			line.Add(MakeStringBox(styles, 2, true));
			line.Add(new BlockBox(styles, Color.Red, 200, 300));
			boxes = new List<Box>(line.Boxes);
			line.ReverseUpstreamBoxes(2, boxes, 1);
			VerifyBoxOrder(line, boxes, new[] { 0,  2, 1, 3}); // reverse just the string boxes
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:83,代码来源:ParaBuilderTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Assembly类代码示例发布时间:2022-05-24
下一篇:
C# Generator.Pdf类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap