大一开始学的GIS,最近才开始真正真正的开始做WebGIS开发,之前没有带路人,都是自己个人在那里瞎起整,走了很多弯路,现在觉得积累真心重要,所以今天贴上文,对自己来说是个积累,希望和大家共同学习,同时需要的人也可以拿来主义。
废话不多说了,这只是个动画,鹰眼常用的动画。
代码如下:
View Code
1 <UserControl 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6 mc:Ignorable="d" 7 x:Class="EyeStoryboard.UserControl1" 8 d:DesignWidth="640" d:DesignHeight="480"> 9 10 <UserControl.Resources> 11 <Storyboard x:Name="sbEye"> 12 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="canvas"> 13 <SplineDoubleKeyFrame KeyTime="0" Value="0"/> 14 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="1"/> 15 </DoubleAnimationUsingKeyFrames> 16 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="canvas"> 17 <SplineDoubleKeyFrame KeyTime="0" Value="0"/> 18 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="1"/> 19 </DoubleAnimationUsingKeyFrames> 20 <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="canvas"> 21 <SplinePointKeyFrame KeyTime="0" Value="0,0"/> 22 <SplinePointKeyFrame KeyTime="0:0:1" Value="0,0"/> 23 </PointAnimationUsingKeyFrames> 24 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="canvas"> 25 <SplineDoubleKeyFrame KeyTime="0" Value="180"/> 26 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 27 </DoubleAnimationUsingKeyFrames> 28 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="canvas"> 29 <SplineDoubleKeyFrame KeyTime="0" Value="180"/> 30 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 31 </DoubleAnimationUsingKeyFrames> 32 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="button"> 33 <SplineDoubleKeyFrame KeyTime="0" Value="0"/> 34 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="-147"/> 35 </DoubleAnimationUsingKeyFrames> 36 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="button"> 37 <SplineDoubleKeyFrame KeyTime="0" Value="0"/> 38 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="-147"/> 39 </DoubleAnimationUsingKeyFrames> 40 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="button"> 41 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="-1"/> 42 </DoubleAnimationUsingKeyFrames> 43 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="button"> 44 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="-1"/> 45 </DoubleAnimationUsingKeyFrames> 46 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="button"> 47 <SplineDoubleKeyFrame KeyTime="0" Value="180"/> 48 <SplineDoubleKeyFrame KeyTime="0:0:1" Value="180"/> 49 </DoubleAnimationUsingKeyFrames> 50 <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="button"> 51 <EasingPointKeyFrame KeyTime="0" Value="0.5,0.5"/> 52 <EasingPointKeyFrame KeyTime="0:0:1" Value="1,1"/> 53 </PointAnimationUsingKeyFrames> 54 </Storyboard> 55 <Style x:Key="ButtonStyle1" TargetType="Button"> 56 <Setter Property="Template"> 57 <Setter.Value> 58 <ControlTemplate TargetType="Button"> 59 <Canvas Background="#FFF3F1F1"> 60 <Image Height="32" Source="up.png" Stretch="Fill" Width="32" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto"> 61 <Image.RenderTransform> 62 <CompositeTransform Rotation="90"/> 63 </Image.RenderTransform> 64 </Image> 65 <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> 66 </Canvas> 67 </ControlTemplate> 68 </Setter.Value> 69 </Setter> 70 </Style> 71 <Storyboard x:Name="sbEyecopy"> 72 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="button"> 73 <EasingDoubleKeyFrame KeyTime="0" Value="-147"/> 74 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 75 </DoubleAnimationUsingKeyFrames> 76 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="button"> 77 <EasingDoubleKeyFrame KeyTime="0" Value="-147"/> 78 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 79 </DoubleAnimationUsingKeyFrames> 80 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="button"> 81 <EasingDoubleKeyFrame KeyTime="0" Value="1"/> 82 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="-1"/> 83 </DoubleAnimationUsingKeyFrames> 84 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="button"> 85 <EasingDoubleKeyFrame KeyTime="0" Value="1"/> 86 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="-1"/> 87 </DoubleAnimationUsingKeyFrames> 88 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="canvas"> 89 <EasingDoubleKeyFrame KeyTime="0" Value="1"/> 90 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 91 </DoubleAnimationUsingKeyFrames> 92 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="canvas"> 93 <EasingDoubleKeyFrame KeyTime="0" Value="1"/> 94 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 95 </DoubleAnimationUsingKeyFrames> 96 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="canvas"> 97 <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 98 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 99 </DoubleAnimationUsingKeyFrames> 100 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="canvas"> 101 <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 102 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 103 </DoubleAnimationUsingKeyFrames> 104 <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="canvas"> 105 <EasingPointKeyFrame KeyTime="0" Value="1,1"/> 106 <EasingPointKeyFrame KeyTime="0:0:1" Value="1,1"/> 107 </PointAnimationUsingKeyFrames> 108 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="button"> 109 <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 110 <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/> 111 </DoubleAnimationUsingKeyFrames> 112 <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="button"> 113 <EasingPointKeyFrame KeyTime="0" Value="0.5,0.5"/> 114 <EasingPointKeyFrame KeyTime="0:0:1" Value="0.5,0.5"/> 115 </PointAnimationUsingKeyFrames> 116 </Storyboard> 117 </UserControl.Resources> 118 119 <Grid x:Name="LayoutRoot" Background="White"> 120 <Canvas x:Name="canvas" HorizontalAlignment="Right" Width="180" Height="180" VerticalAlignment="Bottom" Background="#FFFF1A1A" RenderTransformOrigin="1,1"> 121 <Canvas.RenderTransform> 122 <CompositeTransform ScaleX="0" ScaleY="0"/> 123 </Canvas.RenderTransform> 124 </Canvas> 125 <Button x:Name="button" Height="32" Style="{StaticResource ButtonStyle1}" Width="32" HorizontalAlignment="Right" VerticalAlignment="Bottom" RenderTransformOrigin="0.5,0.5" Click="button_Click"> 126 <Button.RenderTransform> 127 <CompositeTransform Rotation="180"/> 128 </Button.RenderTransform> 129 </Button> 130 </Grid> 131 </UserControl>
后台控制代码如下:
View Code
1 public partial class UserControl1 : UserControl 2 { 3 public UserControl1() 4 { 5 // 为初始化变量所必需 6 InitializeComponent(); 7 } 8 bool a=true; 9 private void button_Click(object sender, System.Windows.RoutedEventArgs e) 10 { 11 12 if(a) 13 { 14 this.sbEye.Begin(); 15 a=false; 16 } 17 else 18 { 19 this.sbEyecopy.Begin(); 20 a=true; 21 } 22 23 } 24 }