Silverlight3实现按路径运动[原创]
??? 這幾天需要給終端機做個一組Logo沿圓形軌跡轉動效果, 直接用Winform實現太卡(通過不斷繪圖方式), 考慮到SL3可以脫機運行, 就用它來實現.
??? 網上也找了很多教程, 發現沒有較好的方法, 最后自己"研究"出一種可行的方法, 供大家討論:
?
??? 1.運行效果:
?
Code
<Window?x:Class="SLTest.test"
????xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
????xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
????Title="test"?Height="600"?Width="800">
????<Window.Resources>
????????<Storyboard?x:Key="Storyboard1">
????????????<PointAnimationUsingPath?Storyboard.TargetName="MyAnimatedEllipseGeometry"?Storyboard.TargetProperty="Center"?Duration="0:0:5"?RepeatBehavior="Forever">
????????????????<PointAnimationUsingPath.PathGeometry>
????????????????????<PathGeometry?Figures="M?299.9?300?A?100,100?360?1?1?300.1,300?Z"/>
????????????????</PointAnimationUsingPath.PathGeometry>
????????????</PointAnimationUsingPath>
????????</Storyboard>
????</Window.Resources>
????<Window.Triggers>
????????<EventTrigger?RoutedEvent="FrameworkElement.Loaded">
????????????<BeginStoryboard?Storyboard="{StaticResource?Storyboard1}"/>
????????</EventTrigger>
????</Window.Triggers>
????<Grid>
????????<Path?x:Name="pt"?Stroke="Black"?Fill="Gray"?Data="M?299.9?300?A?100,100?360?1?1?300.1,300?Z"?/>
????????<Path?Fill="Blue">
????????????<Path.Data>
????????????????<!--?Describes?an?ellipse.?-->
????????????????<EllipseGeometry?x:Name="MyAnimatedEllipseGeometry"
?????????????Center="300,300"?RadiusX="15"?RadiusY="15"?/>
????????????</Path.Data>
????????</Path>
????</Grid>
</Window>
?
???? 相信大家都能看得懂代碼的意思, 這里由于時間原因(馬上要下班走人了)我就不多啰嗦了, 大家有什么好的方案也歡迎一同討論.
???? 程序運行環境: VS2008SP1
???? 源代碼下載
轉載于:https://www.cnblogs.com/yimi329/archive/2009/11/17/1604822.html
總結
以上是生活随笔為你收集整理的Silverlight3实现按路径运动[原创]的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 红帽:虚拟化关键业务应用需突破五大障碍
- 下一篇: 研读代码必须掌握的五个Eclipse快捷