用于图像形状的多行自动包装文本装饰器 [英] Multi-line and auto-wrapping text decorator for image shapes

查看:69
本文介绍了用于图像形状的多行自动包装文本装饰器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图像形状,其中包含一个位于其外部顶部居中的文本装饰器.我希望这个装饰器是多行的,并根据其文本大小自动包装(最大行大小可以由我,语言设计师指定).因此,例如,如果文本太大,则装饰器将上升,以免与下面的图像形状混合.像这样的东西(水平条代表图像):

I have an image shape, which contains a text decorator centered on its outer top. I'd like this decorator to be multi-line and auto-wrapped according to its text size (the max line size could be specified by me, the language designer). So, for example, if the text is too big, the decorator would go up so that it doesn't get mixed with the image shape below. Something like this (the horizontal bars represent the image):

文本-文本

|

|

文本-文本

文本-文本

文本-文本

|

|

在形状子类中,我重写了InititlizeDecorators方法,获取了装饰器的TextField并将其DefaultMultipleLine设置为true,并尝试了其锚定行为,但始终无法获得结果(文本似乎总是被剪切且显示不正确).有什么解决办法吗?

In the shape partial class, I've overridden the InititlizeDecorators method, got the decorator's TextField and set its DefaultMultipleLine to true, and tried something with its anchoring behavior, but was never able to get the result (the text seems always to be cut and not displayed properly). Is there any solution for this?

谢谢

-AFurtado

推荐答案

将以下代码添加到InititlizeDecorators()方法中.

Add bellow code to InititlizeDecorators() method.

base.InitializeDecorators(shapeFields, decorators);
TextField textField = (TextField) FindShapeField(shapeFields, "Text");
textField.DefaultMultipleLine = true;
textField.DefaultAutoSize = false;
textField.AnchoringBehavior.Clear();
textField.AnchoringBehavior.SetLeftAnchor(AnchoringBehavior.Edge.Left, 0.01);
textField.AnchoringBehavior.SetRightAnchor(AnchoringBehavior.Edge.Right, 0.01);
textField.AnchoringBehavior.SetTopAnchor(AnchoringBehavior.Edge.Top, 0.01);
textField.AnchoringBehavior.SetBottomAnchor(AnchoringBehavior.Edge.Bottom, 0.01);


这篇关于用于图像形状的多行自动包装文本装饰器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆