闪烁光动画(如何使用Blend3) [英] Blinking Light Animation (How To With Blend3)
本文介绍了闪烁光动画(如何使用Blend3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力制作一个闪烁的灯光。关灯泡,你点击它,它动画开启和闪烁开/关,直到再次点击。简单而且很直接。我知道如何使用Blend 2(我创建一个动画,设置repeatBehavior并使用后面的代码控制动画开/关)。 Blend3是否有一个新的漂亮无代码背后的方法?
I'm working on making a blinking light. Off Bulb, you click on it, it animates on and blinks on/off until clicked again. Simple and pretty straight forward to do. I know how I'd do it with Blend 2 (I'd create an animation, set repeatBehavior and control the animation on/off with code behind). Is there a new spiffy no-code behind way to do it with Blend3?
推荐答案
我假设你已经创建了所有的动画。
1.切换到动画工作区,为动画命名,如LightOn,你可以记住你的名字。
2.转到设计工作区。
3.点击对象动画。单击看起来像灯泡的图标。这是活动图标。
4.寻找您想要的活动。在这种情况下MouseLeftButtonDown。这将带你到后面的C#代码。
5.在光标所在的地方添加以下代码:
private void Light_MouseLeftButtonDown(object sender,System.Windows.Input.MouseButtonEventArgs e)
{
this.LightOn.Begin(); // TODO:在这里添加事件处理程序实现。
}
6.为MouseLeftButtonUp做同样的事情.7。在光标所在的地方添加以下代码:
private void Light_MouseLeftButtonUp(object sender,System.Windows.Input.MouseButtonEventArgs e)
{
this.LightOn.Stop(); // TODO:在此处添加事件处理程序实现。
以下是整个代码的样子。
I'm assuming you've created all the animation.
1. Change to the animation workspace and give your animation a name you can remember like LightOn.
2. Change to Design workspace.
3. Click on the object with the animation. Click on the icon that looks like a lightingbolt. This the the event icon.
4. Look for the event your want. In this case MouseLeftButtonDown. This will take you to the C# code behind.
5. Add this code where the cursor is:
private void Light_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
this.LightOn.Begin(); // TODO: Add event handler implementation here.
}
6. Do the same thing for the MouseLeftButtonUp
7. Add this code where the cursor is:
}
private void Light_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
this.LightOn.Stop();// TODO: Add event handler implementation here.
}
Below is what the entire code looks like.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Blinking_light
{
public partial class MainPage : UserControl
{
public MainPage()
{
// Required to initialize variables
InitializeComponent();
}
private void Light_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
this.LightOn.Begin(); // TODO: Add event handler implementation here.
}
private void Light_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
this.LightOn.Stop();// TODO: Add event handler implementation here.
}
}
}
这篇关于闪烁光动画(如何使用Blend3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文