fxhomeSoft-silverlight版地图引擎开发教程 之 人物动画控件
返回目录查看更多
=========================================================================
闲聊:最近一直在忙着研发这个地图引擎,也没上我的博客。没想到我的上一篇博客大家还是很关注的,到目前为止已有700+的浏览量。看来我还真得花点时间来回报一下大家了。所以今天抽点时间,把一个小控件放上来和大家分享一下。
先来看看效果
=========================================================================
代码如下:
代码
<UserControl x:Class="fxhomeSoftMaps.peopleControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<Storyboard x:Name="Storyboard" AutoReverse="True" RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="rightArm">
<EasingDoubleKeyFrame KeyTime="0" Value="45"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-45"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="rightLeg">
<EasingDoubleKeyFrame KeyTime="0" Value="-30"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="30"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="leftLeg">
<EasingDoubleKeyFrame KeyTime="0" Value="30"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-30"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="leftArm">
<EasingDoubleKeyFrame KeyTime="0" Value="-45"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="45"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Viewbox x:Name="LayoutRoot">
<Grid>
<Grid x:Name="leftArm" Margin="60,116,0,0" Width="15" HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="0,0" UseLayoutRounding="False" d:LayoutRounding="Auto">
<Grid.RenderTransform>
<CompositeTransform Rotation="-45"/>
</Grid.RenderTransform>
<Line StrokeThickness="30" StrokeStartLineCap="Round" StrokeEndLineCap="Round" RenderTransformOrigin="0,0.25" Y2="60">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
<Grid x:Name="leftLeg" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="60,165,0,0" Width="15" RenderTransformOrigin="0,0" UseLayoutRounding="False" d:LayoutRounding="Auto">
<Grid.RenderTransform>
<CompositeTransform Rotation="30"/>
</Grid.RenderTransform>
<Line StrokeThickness="30" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Y2="75">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
<Grid x:Name="drive" Margin="60,89,0,0" Width="25" HorizontalAlignment="Left" VerticalAlignment="Top">
<Line StrokeThickness="50" StrokeStartLineCap="Round" Y2="70" StrokeEndLineCap="Round">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
<Ellipse x:Name="head" Height="100" Stroke="Black" VerticalAlignment="Top" Width="100" HorizontalAlignment="Left" Margin="9,0,0,0">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Grid x:Name="rightLeg" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="60,165,0,0" Width="15" RenderTransformOrigin="0,0" UseLayoutRounding="False" d:LayoutRounding="Auto">
<Grid.RenderTransform>
<CompositeTransform Rotation="-30"/>
</Grid.RenderTransform>
<Line StrokeThickness="30" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Y2="75">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
<Grid x:Name="rightArm" Margin="60,116,0,0" Width="15" HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="0,0" UseLayoutRounding="False" d:LayoutRounding="Auto">
<Grid.RenderTransform>
<CompositeTransform Rotation="45"/>
</Grid.RenderTransform>
<Line StrokeThickness="30" StrokeStartLineCap="Round" StrokeEndLineCap="Round" RenderTransformOrigin="0,0.25" Y2="60">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
</Grid>
</Viewbox>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<Storyboard x:Name="Storyboard" AutoReverse="True" RepeatBehavior="Forever">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="rightArm">
<EasingDoubleKeyFrame KeyTime="0" Value="45"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-45"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="rightLeg">
<EasingDoubleKeyFrame KeyTime="0" Value="-30"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="30"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="leftLeg">
<EasingDoubleKeyFrame KeyTime="0" Value="30"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-30"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="leftArm">
<EasingDoubleKeyFrame KeyTime="0" Value="-45"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="45"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Viewbox x:Name="LayoutRoot">
<Grid>
<Grid x:Name="leftArm" Margin="60,116,0,0" Width="15" HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="0,0" UseLayoutRounding="False" d:LayoutRounding="Auto">
<Grid.RenderTransform>
<CompositeTransform Rotation="-45"/>
</Grid.RenderTransform>
<Line StrokeThickness="30" StrokeStartLineCap="Round" StrokeEndLineCap="Round" RenderTransformOrigin="0,0.25" Y2="60">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
<Grid x:Name="leftLeg" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="60,165,0,0" Width="15" RenderTransformOrigin="0,0" UseLayoutRounding="False" d:LayoutRounding="Auto">
<Grid.RenderTransform>
<CompositeTransform Rotation="30"/>
</Grid.RenderTransform>
<Line StrokeThickness="30" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Y2="75">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
<Grid x:Name="drive" Margin="60,89,0,0" Width="25" HorizontalAlignment="Left" VerticalAlignment="Top">
<Line StrokeThickness="50" StrokeStartLineCap="Round" Y2="70" StrokeEndLineCap="Round">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
<Ellipse x:Name="head" Height="100" Stroke="Black" VerticalAlignment="Top" Width="100" HorizontalAlignment="Left" Margin="9,0,0,0">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Grid x:Name="rightLeg" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="60,165,0,0" Width="15" RenderTransformOrigin="0,0" UseLayoutRounding="False" d:LayoutRounding="Auto">
<Grid.RenderTransform>
<CompositeTransform Rotation="-30"/>
</Grid.RenderTransform>
<Line StrokeThickness="30" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Y2="75">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
<Grid x:Name="rightArm" Margin="60,116,0,0" Width="15" HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="0,0" UseLayoutRounding="False" d:LayoutRounding="Auto">
<Grid.RenderTransform>
<CompositeTransform Rotation="45"/>
</Grid.RenderTransform>
<Line StrokeThickness="30" StrokeStartLineCap="Round" StrokeEndLineCap="Round" RenderTransformOrigin="0,0.25" Y2="60">
<Line.Stroke>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FF00749B"/>
</RadialGradientBrush>
</Line.Stroke>
</Line>
</Grid>
</Grid>
</Viewbox>
</UserControl>
代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace fxhomeSoftMaps
{
public partial class peopleControl : UserControl
{
public peopleControl()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(peopleControl_Loaded);
}
void peopleControl_Loaded(object sender, RoutedEventArgs e)
{
this.Storyboard.Begin();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace fxhomeSoftMaps
{
public partial class peopleControl : UserControl
{
public peopleControl()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(peopleControl_Loaded);
}
void peopleControl_Loaded(object sender, RoutedEventArgs e)
{
this.Storyboard.Begin();
}
}
}


浙公网安备 33010602011771号