我使用WPF渲染XPS。这是完全动态的(不含XAML)。
在我的代码中,我有以下代码来设置文本轮换。
Private Shared Sub ApplyRotation(style As BoxStyleData, run As TextElement)
If style IsNot Nothing Then
If Math.Abs(style.TextRotation) > Double.Epsilon Then
Dim effects = New TextEffectCollection
Dim effect = New TextEffect()
effect.Transform = New RotateTransform(style.TextRotation)
effect.PositionCount = 100
effects.Add(effect)
run.TextEffects = effects
End If
End If
End Sub
它在FlowPanel内部,因此一些错误阻止我为整个段落设置旋转(更多关于此http://social.msdn.microsoft.com/Forums/nl/wpf/thread/931f1995-d039-4364-b09b-fcd0a43fd737)
我的问题是,即使我使用修复程序,结果也不正确。在一定数量的字符后,文本不再旋转:
请注意,该截图来自我呈现结果的XPS。
当我将其呈现给XAML时,您可以看到该效果已正确映射到文本中的所有Runs
。
<Paragraph Margin="0,0,0,0" Padding="0,18.9,0,0" TextAlignment="Center" ClearFloaters="None" FontSize="14.62">
<Span FontSize="14.62"><Run><Run.TextEffects><TextEffect PositionCount="100"><TextEffect.Transform><RotateTransform Angle="356.7" /></TextEffect.Transform></TextEffect></Run.TextEffects>Denken Sie frühzeitig</Run></Span><LineBreak />
<Span FontSize="14.62"><Run><Run.TextEffects><TextEffect PositionCount="100"><TextEffect.Transform><RotateTransform Angle="356.7" /></TextEffect.Transform></TextEffect></Run.TextEffects>an den</Run></Span><LineBreak />
<Span FontSize="14.62"><Run><Run.TextEffects><TextEffect PositionCount="100"><TextEffect.Transform><RotateTransform Angle="356.7" /></TextEffect.Transform></TextEffect></Run.TextEffects>Räderwechsel!</Run></Span><LineBreak />
<LineBreak />
<Span FontSize="14.62"><Run><Run.TextEffects><TextEffect PositionCount="100"><TextEffect.Transform><RotateTransform Angle="356.7" /></TextEffect.Transform></TextEffect></Run.TextEffects>Unser</Run></Span><LineBreak />
<Span FontWeight="Bold" FontSize="14.62"><Run><Run.TextEffects><TextEffect PositionCount="100"><TextEffect.Transform><RotateTransform Angle="356.7" /></TextEffect.Transform></TextEffect></Run.TextEffects>Winter Check-Point</Run></Span><LineBreak />
<Span FontSize="14.62"><Run><Run.TextEffects><TextEffect PositionCount="100"><TextEffect.Transform><RotateTransform Angle="356.7" /></TextEffect.Transform></TextEffect></Run.TextEffects>ist für Sie offen!</Run></Span></Paragraph>
现在,有没有人知道如何实现全文的旋转,因为我真的需要它。
由于
编辑: 为了快速测试它无法正常工作,您可以创建WPF应用程序,只需粘贴以下XAML代码
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<FlowDocumentPageViewer>
<FlowDocument>
<Paragraph Margin="0,0,0,0" Padding="0,18.9,0,0" TextAlignment="Center" ClearFloaters="None" FontSize="14.62">
<Span FontSize="14.62">
<Run>
<Run.TextEffects>
<TextEffect PositionCount="100">
<TextEffect.Transform>
<RotateTransform Angle="356.7" />
</TextEffect.Transform>
</TextEffect>
</Run.TextEffects> Denken Sie frühzeiti
</Run>
</Span>
<LineBreak />
<Span FontSize="14.62">
<Run>
<Run.TextEffects>
<TextEffect PositionCount="100">
<TextEffect.Transform>
<RotateTransform Angle="356.7" />
</TextEffect.Transform>
</TextEffect>
</Run.TextEffects> an den
</Run>
</Span>
<LineBreak />
<Span FontSize="14.62">
<Run>
<Run.TextEffects>
<TextEffect PositionCount="100">
<TextEffect.Transform>
<RotateTransform Angle="356.7" />
</TextEffect.Transform>
</TextEffect>
</Run.TextEffects> Räderwechsel!
</Run>
</Span>
<LineBreak />
<LineBreak />
<Span FontSize="14.62">
<Run>
<Run.TextEffects>
<TextEffect PositionCount="100">
<TextEffect.Transform>
<RotateTransform Angle="356.7" />
</TextEffect.Transform>
</TextEffect>
</Run.TextEffects> Unser
</Run>
</Span>
<LineBreak />
<Span FontWeight="Bold" FontSize="14.62">
<Run>
<Run.TextEffects>
<TextEffect PositionCount="100">
<TextEffect.Transform>
<RotateTransform Angle="356.7" />
</TextEffect.Transform>
</TextEffect>
</Run.TextEffects> Winter Check-Point
</Run>
</Span>
<LineBreak />
<Span FontSize="14.62">
<Run>
<Run.TextEffects>
<TextEffect PositionCount="100">
<TextEffect.Transform>
<RotateTransform Angle="356.7" />
</TextEffect.Transform>
</TextEffect>
</Run.TextEffects> ist für Sie offen!
</Run>
</Span>
</Paragraph>
</FlowDocument>
</FlowDocumentPageViewer>
</Grid>
</Window>
答案 0 :(得分:0)
所以,我通过切换
来修复它effect.PositionCount = 100
到
effect.PositionCount = Integer.Max
解决了这个问题。
我没有正确理解它代表什么,并认为它意味着完成效果的百分比。