TX Text Control提供了非常强大的图形功能,可以将许多不同类型的形状插入文档中。
Text Control GmbH公司的文档处理控件功能强大,能帮助您轻松创建能与Microsoft Word功能媲美的应用程序。
了解Text Control
TX Text Control提供了非常强大的图形功能,可以将许多不同类型的形状插入文档中。 功能区的“插入”选项卡提供了开箱即用的UI,可将形状添加到文档中:

添加单一形状
为了以编程方式插入这些形状,需要执行几个步骤:
// create a drawing control that contains the shape(s)TXTextControl.Drawing.TXDrawingControl drawing = new TXTextControl.Drawing.TXDrawingControl(3000, 3000);// create a new donut shapeTXTextControl.Drawing.Shape shape = new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Donut);// set the color and border widthshape.ShapeFill.Color = Color.Red;shape.ShapeOutline.Color = Color.Yellow;shape.ShapeOutline.Width = 200;// add the shape to the drawing controldrawing.Shapes.Add( shape, TXTextControl.Drawing.ShapeCollection.AddStyle.Fill);// create a new drawing frame object from the created drawing controlTXTextControl.DataVisualization.DrawingFrame frame = new TXTextControl.DataVisualization.DrawingFrame(drawing);// add the frame to the documenttextControl1.Drawings.Add(frame, -1);

上面的代码在当前输入位置插入一个形状。 如果希望用户将创建的形状“绘制”到文档上,则可以使用DrawingCollection.Add方法的以下实现:
textControl1.Drawings.Add(frame, TXTextControl.FrameInsertionMode.DisplaceText);
添加容器组框架
以下代码显示了如何在组框架中插入更多形状。 如果容器组框架被移动,则所有包含的形状将一起移动:
// create a drawing control that contains the shape(s)TXTextControl.Drawing.TXDrawingControl drawingGroup = new TXTextControl.Drawing.TXDrawingControl(3000, 3000);// create a new donut shapeTXTextControl.Drawing.Shape donut = new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Donut) { Location = new Point(100, 100), Size = new Size(500,500) };TXTextControl.Drawing.Shape diamond = new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Diamond);// add the shape to the drawing controldrawingGroup.Shapes.Add(donut);drawingGroup.Shapes.Add(diamond);// create a new drawing frame object from the created drawing controlTXTextControl.DataVisualization.DrawingFrame frame = new TXTextControl.DataVisualization.DrawingFrame(drawingGroup);// add the frame to the documenttextControl1.Drawings.Add( frame, textControl1.InputPosition.Location, TXTextControl.FrameInsertionMode.DisplaceText);
以下屏幕截图显示了已激活的组容器框架,其中插入了2个形状:

向容器添加其他形状
如果激活了容器框架(虚线边框),则可以添加其他形状。 以下代码将新形状插入到已激活的容器框架中:
// create a new donut shapeTXTextControl.Drawing.Shape shape = new TXTextControl.Drawing.Shape(TXTextControl.Drawing.ShapeType.Donut);// set the color and border widthshape.ShapeFill.Color = Color.Red;shape.ShapeOutline.Color = Color.Yellow;shape.ShapeOutline.Width = 200;if (textControl1.Drawings.GetActivatedItem() != null){ // add the shape to the drawing control ((TXDrawingControl)textControl1.Drawings.GetActivatedItem().Drawing).Shapes.Add(shape);}
如果希望用户将其他形状绘制到容器中,则必须在Shapes.Add方法中使用MouseCreation成员。
((TXDrawingControl)textControl1.Drawings.GetActivatedItem().Drawing).Shapes.Add( shape, ShapeCollection.AddStyle.MouseCreation);

文章推荐:
TX Text Control系列教程— ASP.NET :创建文字处理器和模板设计器
如果您对Text Control感兴趣,可以咨询在线客服>>购买正版授权软件。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!