feat: 15-动画基础-1修改按钮动画-P354
This commit is contained in:
parent
0e8af30072
commit
e75f0b2053
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<RootNamespace>_15_动画基础_1修改按钮动画_P354</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="public\003540AH4M72.jpg"/>
|
||||
<Resource Include="public\bunny.png"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="_15_动画基础_1修改按钮动画_P354.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:_15_动画基础_1修改按钮动画_P354"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,12 @@
|
|||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace _15_动画基础_1修改按钮动画_P354;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
|
@ -0,0 +1,17 @@
|
|||
<Window x:Class="_15_动画基础_1修改按钮动画_P354.MainWindow"
|
||||
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"
|
||||
Icon="public/003540AH4M72.jpg" Title="15-动画基础-1修改按钮动画-P354" Height="450" Width="800">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button Name="ButtonAnimation" Click="ButtonAnimation_OnClick" >
|
||||
<Button.Effect>
|
||||
<DropShadowEffect BlurRadius="2" Color="Red" Direction="-20" Opacity="0.7" RenderingBias="Quality"
|
||||
ShadowDepth="10" />
|
||||
</Button.Effect>
|
||||
<Button.Content>ButtonAnimation</Button.Content>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Window>
|
|
@ -0,0 +1,52 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace _15_动画基础_1修改按钮动画_P354;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ButtonAnimation_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var doubleAnimation = new DoubleAnimation
|
||||
{
|
||||
// 开始值
|
||||
From = 160,
|
||||
// 结束值
|
||||
To = Width - 30,
|
||||
// 增大10个单位,不使用To而是使用By
|
||||
// By = 10,
|
||||
// 翻转动画
|
||||
AutoReverse = true,
|
||||
// 比原来快5倍
|
||||
SpeedRatio = 5,
|
||||
// 持续2秒
|
||||
Duration = TimeSpan.FromSeconds(2),
|
||||
// 一直循环
|
||||
// RepeatBehavior = RepeatBehavior.Forever
|
||||
// 循环四次
|
||||
// RepeatBehavior = new RepeatBehavior(4)
|
||||
// 循环3秒
|
||||
RepeatBehavior = new RepeatBehavior(TimeSpan.FromSeconds(3))
|
||||
};
|
||||
ButtonAnimation.BeginAnimation(WidthProperty, doubleAnimation);
|
||||
}
|
||||
|
||||
private void ButtonAnimation2_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var doubleAnimation = new DoubleAnimation
|
||||
{
|
||||
From = ButtonAnimation.ActualWidth,
|
||||
To = Width - 30,
|
||||
Duration = TimeSpan.FromSeconds(2)
|
||||
};
|
||||
ButtonAnimation.BeginAnimation(WidthProperty, doubleAnimation);
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
|
@ -70,6 +70,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "14-效果和可视化对象
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "14-效果和可视化对象-3DropShadowEffect-P339", "14-效果和可视化对象-3DropShadowEffect-P339\14-效果和可视化对象-3DropShadowEffect-P339.csproj", "{8F8691A8-DB44-4F3E-BCDE-E58A8AF18A5B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15-动画基础-1修改按钮动画-P354", "15-动画基础-1修改按钮动画-P354\15-动画基础-1修改按钮动画-P354.csproj", "{D902EB37-13C3-4763-9B21-5A6EB368F352}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -216,5 +218,9 @@ Global
|
|||
{8F8691A8-DB44-4F3E-BCDE-E58A8AF18A5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8F8691A8-DB44-4F3E-BCDE-E58A8AF18A5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8F8691A8-DB44-4F3E-BCDE-E58A8AF18A5B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D902EB37-13C3-4763-9B21-5A6EB368F352}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D902EB37-13C3-4763-9B21-5A6EB368F352}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D902EB37-13C3-4763-9B21-5A6EB368F352}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D902EB37-13C3-4763-9B21-5A6EB368F352}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
Loading…
Reference in New Issue