WPF开发者QQ群: 340500857

      由于微信群人数太多入群请添加小编微信号

 yanjinhuawechat 或 W_Feng_aiQ 入群

需备注WPF开发者 

PS:有更好的方式欢迎推荐。

01

代码如下

一、创建 SpeedRocketsExample.xaml 代码如下。

<Window x:Class="WPFDevelopers.Samples.ExampleViews.SpeedRocketsMini"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"xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"xmlns:sys="clr-namespace:System;assembly=mscorlib"mc:Ignorable="d" WindowStyle="None" ShowInTaskbar="False"WindowState="Maximized" Background="Transparent"ResizeMode="NoResize" AllowsTransparency="True"Height="450" Width="800" MaxHeight="{x:Static SystemParameters.MaximizedPrimaryScreenHeight}"><Window.Resources><local:ActualHeightConverters x:Key="actualHeightConverters"/></Window.Resources><Grid><Button Style="{StaticResource PrimaryButton}" Content="X" Width="60" Height="40" VerticalAlignment="Top" HorizontalAlignment="Right"Click="Button_Click"/><Grid VerticalAlignment="Bottom"HorizontalAlignment="Right"Margin="0,0,0,40"><Grid.Resources><Storyboard x:Key="StoryboardMouseDown"><DoubleAnimation Storyboard.TargetName="rotate_y" To="0" Duration="0:0:0"Storyboard.TargetProperty="Angle"/><DoubleAnimation Storyboard.TargetProperty="(Viewport3D.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)"Storyboard.TargetName="PART_Viewport3D"Duration="0:0:2" From="0" To="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window},Mode=FindAncestor}, Path=ActualHeight,Converter={StaticResource actualHeightConverters}}" EasingFunction="{StaticResource BackEaseEaseInOut}"/><RectAnimation Storyboard.TargetProperty="(Ellipse.Clip).(RectangleGeometry.Rect)"Storyboard.TargetName="Ellipse3"BeginTime="0:0:.5" To="0,80,100,100"Duration="0:0:2" From="0,10,100,100" AutoReverse="True"></RectAnimation><StringAnimationUsingKeyFrames Storyboard.TargetName="TextBlock1" Storyboard.TargetProperty="Text"BeginTime="0:0:.5" AutoReverse="True"><DiscreteStringKeyFrame Value="90"   KeyTime="0:0:0"/><DiscreteStringKeyFrame Value="85"   KeyTime="0:0:.30" /><DiscreteStringKeyFrame Value="70"   KeyTime="0:0:1" /><DiscreteStringKeyFrame Value="40"   KeyTime="0:0:1.5" /><DiscreteStringKeyFrame Value="10"   KeyTime="0:0:2" /></StringAnimationUsingKeyFrames><DoubleAnimation Storyboard.TargetProperty="(Viewport3D.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)"Storyboard.TargetName="PART_Viewport3D"Duration="0:0:0" BeginTime="0:0:2"To="0"/></Storyboard><Storyboard  x:Key="StoryboardMouseEnter"><DoubleAnimation Duration="00:00:.5" BeginTime="00:00:0"From="0"Storyboard.TargetName="PART_Viewport3D"Storyboard.TargetProperty="(Viewport3D.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.ScaleX)"To="1"/><DoubleAnimation Duration="00:00:.5" BeginTime="00:00:0"From="0"Storyboard.TargetName="PART_Viewport3D"Storyboard.TargetProperty="(Viewport3D.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.ScaleY)"To="1" /><DoubleAnimation Storyboard.TargetName="rotate_y" From="0" To="360"BeginTime="00:00:.5" Storyboard.TargetProperty="Angle"Duration="0:0:1.5" RepeatBehavior="Forever" /></Storyboard><Storyboard x:Key="StoryboardMouseLeave"><DoubleAnimation Duration="00:00:0" To="0" Storyboard.TargetProperty="Angle" Storyboard.TargetName="rotate_y" /><DoubleAnimation Duration="00:00:0" From="1"Storyboard.TargetName="PART_Viewport3D"Storyboard.TargetProperty="(Viewport3D.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.ScaleX)"To="0"/><DoubleAnimation Duration="00:00:0" From="1"Storyboard.TargetName="PART_Viewport3D"Storyboard.TargetProperty="(Viewport3D.RenderTransform).(TransformGroup.Children)[1].(ScaleTransform.ScaleY)"To="0" /></Storyboard></Grid.Resources><Grid Height="100" Width="100" ToolTip="按下加速~喵 (゜-゜)つロ "><Ellipse  Fill="White" Stroke="#FFAEABAB" StrokeThickness="1"></Ellipse><Ellipse  Fill="#FF5F9E74" Margin="4"></Ellipse><Ellipse  Fill="#FF6BCF77" Margin="8" x:Name="Ellipse3"><Ellipse.Clip><RectangleGeometry Rect="0,10,100,100"></RectangleGeometry></Ellipse.Clip></Ellipse><WrapPanel  HorizontalAlignment="Center" VerticalAlignment="Center"><TextBlock Foreground="White"FontSize="30"FontWeight="Bold" FontFamily="Agency FB"Text="90"x:Name="TextBlock1"></TextBlock><TextBlock Foreground="White"FontSize="30"Text="%"FontWeight="Bold" FontFamily="Agency FB"></TextBlock></WrapPanel><Grid.Triggers><EventTrigger RoutedEvent="MouseDown"><BeginStoryboard Storyboard="{StaticResource StoryboardMouseDown}"/></EventTrigger><EventTrigger RoutedEvent="MouseEnter"><BeginStoryboard Storyboard="{StaticResource StoryboardMouseEnter}"/></EventTrigger><EventTrigger RoutedEvent="MouseLeave"><BeginStoryboard Storyboard="{StaticResource StoryboardMouseLeave}"/></EventTrigger></Grid.Triggers></Grid><!--<Ellipse Height="80" Width="80" x:Name="Ellipse1"StrokeThickness="2" Stroke="{StaticResource PrimaryNormalSolidColorBrush}"ToolTip="按下加速~喵 (゜-゜)つロ "><Ellipse.Fill><LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"><GradientStop Color="#FFF7D1A3"/><GradientStop Color="#FFF98C0C" Offset="1"/><GradientStop Color="#FFF49F39" Offset="0.5"/></LinearGradientBrush></Ellipse.Fill><Ellipse.Triggers><EventTrigger RoutedEvent="MouseDown"><BeginStoryboard Storyboard="{StaticResource StoryboardY}"/></EventTrigger><EventTrigger RoutedEvent="MouseEnter"><BeginStoryboard Storyboard="{StaticResource StoryboardAngleY}"/></EventTrigger><EventTrigger RoutedEvent="MouseLeave"><BeginStoryboard Storyboard="{StaticResource StoryboardNormal}"/></EventTrigger></Ellipse.Triggers></Ellipse>--><Viewport3D Width="60" Height="60"RenderTransformOrigin=".5,.5"x:Name="PART_Viewport3D"IsHitTestVisible="False"><Viewport3D.RenderTransform><TransformGroup><TranslateTransform Y="0"/><ScaleTransform ScaleX="0" ScaleY="0"/></TransformGroup></Viewport3D.RenderTransform><!--<Viewport3D.Triggers><EventTrigger RoutedEvent="Viewport3D.MouseDown"><BeginStoryboard><Storyboard><DoubleAnimation Storyboard.TargetName="rotate_y"
To="0" Duration="0:0:0"
Storyboard.TargetProperty="Angle"/><DoubleAnimation Storyboard.TargetProperty="(Viewport3D.RenderTransform).(TranslateTransform.Y)"Duration="0:0:1"To="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window},Mode=FindAncestor}, Path=ActualHeight,Converter={StaticResource actualHeightConverters}}" EasingFunction="{StaticResource BackEaseEaseInOut}"/></Storyboard></BeginStoryboard></EventTrigger><EventTrigger RoutedEvent="Viewport3D.MouseEnter"><BeginStoryboard><Storyboard TargetProperty="Angle"><DoubleAnimation Storyboard.TargetName="rotate_y" From="0" To="360" Duration="0:0:1.5" RepeatBehavior="Forever" /></Storyboard></BeginStoryboard></EventTrigger><EventTrigger RoutedEvent="MouseLeave"><BeginStoryboard><Storyboard Storyboard.TargetProperty="Angle" Storyboard.TargetName="rotate_y"><DoubleAnimation Duration="00:00:0" To="0" /></Storyboard></BeginStoryboard></EventTrigger></Viewport3D.Triggers>--><Viewport3D.Camera><OrthographicCamera LookDirection="0,0,-50" Position="0,0,50" UpDirection="0,1,0"/></Viewport3D.Camera><Viewport3D.Children><ModelVisual3D><ModelVisual3D.Content><AmbientLight Color="Transparent"/></ModelVisual3D.Content></ModelVisual3D><ContainerUIElement3D><Viewport2DVisual3D><Viewport2DVisual3D.Geometry><MeshGeometry3D Positions="-1,1,1 -1,-1,1 1,-1,1 1,1,1" TriangleIndices="0 1 2 0 2 3" TextureCoordinates="0,0 0,1 1,1 1,0"/></Viewport2DVisual3D.Geometry><Viewport2DVisual3D.Material><DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True"/></Viewport2DVisual3D.Material><Image Source="/Images/SpeedRockets/飞机.png"/></Viewport2DVisual3D><Viewport2DVisual3D><Viewport2DVisual3D.Material><DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True"/></Viewport2DVisual3D.Material><Viewport2DVisual3D.Geometry><MeshGeometry3D Positions="1,1,1 1,-1,1 -1,-1,1 -1,1,1"
TextureCoordinates="0,0 0,1 1,1 1,0"
TriangleIndices="0 1 2 0 2 3"/></Viewport2DVisual3D.Geometry><Image Source="/Images/SpeedRockets/飞机.png"/></Viewport2DVisual3D><ContainerUIElement3D.Transform><Transform3DGroup><RotateTransform3D CenterX="0" CenterY="0" CenterZ="1"><RotateTransform3D.Rotation><AxisAngleRotation3D x:Name="rotate_y" Axis="0 1 0" /></RotateTransform3D.Rotation></RotateTransform3D></Transform3DGroup></ContainerUIElement3D.Transform></ContainerUIElement3D></Viewport3D.Children></Viewport3D></Grid></Grid>
</Window>

二、SnowCanvas.xamlSpeedRocketsExample.xaml.cs 代码如下

using System;
using System.Windows;
using System.Windows.Data;namespace WPFDevelopers.Samples.ExampleViews
{/// <summary>/// SpeedRocketsMini.xaml 的交互逻辑/// </summary>public partial class SpeedRocketsMini : Window{public SpeedRocketsMini(){InitializeComponent();}private void Button_Click(object sender, RoutedEventArgs e){Close();}}public class ActualHeightConverters : IValueConverter{public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture){return 0 - (double)value;}public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture){return null;}}
}

02

效果预览

鸣谢素材提供者 - 王路飞

源码地址如下

Github:https://github.com/WPFDevelopersOrg

Gitee:https://gitee.com/WPFDevelopersOrg

WPF开发者QQ群: 340500857 

Github:https://github.com/WPFDevelopersOrg

出处:https://www.cnblogs.com/yanjinhua

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

转载请著名作者 出处 https://github.com/WPFDevelopersOrg

扫一扫关注我们,

更多知识早知道!

点击阅读原文可跳转至源代码

WPF 实现加速小火箭~相关推荐

  1. 360悬浮加速小火箭,内存清理,加速缓存

    360悬浮加速小火箭,内存清理,加速缓存 关于我 最近时间都比较的紧,处理不同项目的BUG,今天偷得半日闲,把剩下项目的一部分扔给了组长.有个问题没解决,做了两天也没完成,实在是没有办法了.也很感谢, ...

  2. [Android] android 实现加速小火箭动画效果 位移+透明渐变 动画

    [需求分析] 最近要实现一个类似于加速火箭移动的动画,需要带有位置移动和透明度转变的动画.类似于从A到B发生位移动画,且加速小火箭主键显示.而从B到C发生位移动画,且加速小火箭逐渐变暗消失.实现效果如 ...

  3. 高仿QQ的手机管家的小火箭加速

    高仿QQ的手机管家的小火箭加速 1.前言 腾讯的手机管家,用过这个App的人都应该知道桌面的火箭一键加速这个功能,研究一下这个小火箭是怎么做出来的.先来了解一下小火箭有神马动作,首先在没有触碰它时,就 ...

  4. 百度正在加速小程序的开放趋势

    从推动开放角度而言,百度在加速小程序的开放能力,其成立的开源联盟则是BAT中目前唯一,也是最有能力将小程序进行全网分发的开放体系. 百度从站长时代,就致力于扮演赋能网站的主角,对于广告主.网站都有着赋 ...

  5. Android桌面悬浮窗进阶,QQ手机管家小火箭效果实现

    这次我们将代码的重点放在火箭升空的效果上,因此简单起见,就直接在模仿360手机卫士悬浮窗的那份代码的基础上继续开发了,如果你还没有看过那篇文章的话,建议先去阅读 Android桌面悬浮窗效果实现,仿3 ...

  6. 返回顶部小火箭(仿电脑管家)

    偶然得到一张图片素材,想要实现返回顶部的小火箭效果. 素材: 实现思路 一张图片上有多张图片的不同运动状态,可以用偏移来拼接动画运动状态, 图片中含有动画的好几帧,想要让小火箭的火苗动起来,可以分别设 ...

  7. 拖拽升空的Android小火箭

    先上演示效果 1.MainActivity 主布局就两个Button按钮 :一开启.二关闭 就不贴主布局xml了 因为小火箭是游离在activity之外的,所以不能依赖activity的生命周期 需要 ...

  8. 添加底部小火箭+目录

    1.添加返回小火箭 页脚Html代码 <span id="back-to-top"><a href="#top"><img src ...

  9. Android仿腾讯手机管家实现桌面悬浮窗小火箭发射的动画效果

    功能分析:  1.小火箭游离在activity之外,不依附于任何activity,不管activity是否开启,不影响小火箭的代码逻辑,所以小火箭的代码逻辑是要写在服务中:  2.小火箭挂载在手机窗体 ...

最新文章

  1. python def函数报错详解_【python】详解python函数定义 def()与参数args、可变参数*args、关键参数**args使用实例...
  2. Xamarin Essentials教程振动Vibration
  3. 移动端判断手机横竖屏状态
  4. Fluent NHibernate之旅
  5. 第一次冲刺阶段(三)
  6. 同事删库跑路后,我连表名都不能修改了?
  7. 牛客小白月赛13-H(单调栈+树状数组)
  8. Java的native方法
  9. Pure公司发布机架规模FlashBlade对象与文件存储方案
  10. python基础其他(二十一)
  11. C++回声服务器_6-多进程pipe版本服务器
  12. Hibernate框架 基础
  13. MySQL用什么输入法_最好用的输入法是什么?
  14. 京沪广深同日发布网约车新规细则草案 滴滴回应称或将导致车辆供给骤减
  15. DevOps落地实践:BAT系列:代码托管:iCode vs TGit
  16. 计算机光盘无法格式化,win10无法格式化dvd光盘
  17. Python——基础语法
  18. 记一次频繁YoungGC生产问题排查思路及解决方案
  19. scanf_s()函数的用法
  20. RS232电平 RS485电平 RS422电平

热门文章

  1. 使用eclipse运行mapreduce程序
  2. MVC应用程序实现文件库(FlexPaper)
  3. mysql数据库的新特性_【数据库】MySQL新特性归档介绍
  4. 暑假集训-8.06总结
  5. h5c3 part6 flex
  6. Java Decompiler(Java反编译工具)
  7. h5的formData 上传文件及.net后台
  8. GitHub项目管理维护实用教程
  9. andriod之应用内置浏览器 webview
  10. java--用 * 打印出各种图形(新手请进)