本文整理汇总了C#中System.Windows.FrameworkElement.SetAnimatableRootClock方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.SetAnimatableRootClock方法的具体用法?C# FrameworkElement.SetAnimatableRootClock怎么用?C# FrameworkElement.SetAnimatableRootClock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkElement
的用法示例。
在下文中一共展示了FrameworkElement.SetAnimatableRootClock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SequentialTimelineClockStoryboardTest
public void SequentialTimelineClockStoryboardTest()
{
DoubleAnimation animation1 = new DoubleAnimation { To = 100, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)) };
DoubleAnimation animation2 = new DoubleAnimation { To = 200, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(0)) };
DoubleAnimation animation3 = new DoubleAnimation { To = 300, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)) };
SequentialTimeline sequentialTimeline = new SequentialTimeline();
sequentialTimeline.Children.Add(animation1);
sequentialTimeline.Children.Add(animation2);
sequentialTimeline.Children.Add(animation3);
Storyboard storyboard = new Storyboard();
storyboard.Children.Add(sequentialTimeline);
FrameworkElement element = new FrameworkElement { Width = 0, Height = 0 };
Storyboard.SetTarget(animation1, element);
Storyboard.SetTargetProperty(animation1, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty));
Storyboard.SetTarget(animation2, element);
Storyboard.SetTargetProperty(animation2, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty));
Storyboard.SetTarget(animation3, element);
Storyboard.SetTargetProperty(animation3, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty));
TestRootClock rootClock = new TestRootClock();
element.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true));
storyboard.Begin(element);
rootClock.Tick(TimeSpan.FromSeconds(0));
Assert.AreEqual(0, element.Width);
rootClock.Tick(TimeSpan.FromSeconds(0.9));
Assert.AreEqual(90, element.Width);
rootClock.Tick(TimeSpan.FromSeconds(1));
Assert.AreEqual(200, element.Width);
rootClock.Tick(TimeSpan.FromSeconds(1.5));
Assert.AreEqual(250, element.Width);
rootClock.Tick(TimeSpan.FromSeconds(2));
Assert.AreEqual(300, element.Width);
}
示例2: StoryboardBasicTest
public void StoryboardBasicTest()
{
DoubleAnimation widthAnimation = new DoubleAnimation { To = 100 };
DoubleAnimation heightAnimation = new DoubleAnimation { From = 100 };
Storyboard storyboard = new Storyboard();
storyboard.Children.Add(widthAnimation);
storyboard.Children.Add(heightAnimation);
FrameworkElement element = new FrameworkElement { Width = 0, Height = 0 };
Storyboard.SetTarget(widthAnimation, element);
Storyboard.SetTargetProperty(widthAnimation, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty));
Storyboard.SetTarget(heightAnimation, element);
Storyboard.SetTargetProperty(heightAnimation, PropertyPath.FromDependencyProperty(FrameworkElement.HeightProperty));
TestRootClock rootClock = new TestRootClock();
element.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true));
storyboard.Begin(element);
rootClock.Tick(TimeSpan.FromSeconds(0));
Assert.AreEqual(0, element.Width);
Assert.AreEqual(100, element.Height);
rootClock.Tick(TimeSpan.FromSeconds(0.1));
Assert.AreEqual(10, element.Width);
Assert.AreEqual(90, element.Height);
rootClock.Tick(TimeSpan.FromSeconds(1));
Assert.AreEqual(100, element.Width);
Assert.AreEqual(0, element.Height);
storyboard.Seek(element, TimeSpan.FromSeconds(0.5));
rootClock.Tick(TimeSpan.FromSeconds(1));
Assert.AreEqual(50, element.Width);
Assert.AreEqual(50, element.Height);
storyboard.Remove(element);
rootClock.Tick(TimeSpan.FromSeconds(1));
Assert.AreEqual(0, element.Width);
Assert.AreEqual(0, element.Height);
}
示例3: AnimatableRootClockConnectionTest
public void AnimatableRootClockConnectionTest()
{
TestRootClock rootClock = new TestRootClock();
FrameworkElement element = new FrameworkElement();
element.SetAnimatableRootClock(new AnimatableRootClock(rootClock, false));
Assert.AreEqual(0, rootClock.Clocks.Count());
Assert.IsFalse(element.IsVisible);
element.IsRootElement = true;
Assert.IsTrue(element.IsVisible);
DoubleAnimation animation = new DoubleAnimation { From = 0, To = 1 };
element.BeginAnimation(FrameworkElement.WidthProperty, animation);
Assert.AreEqual(1, rootClock.Clocks.Count());
rootClock.Tick(TimeSpan.FromSeconds(0.1));
Assert.AreEqual(0.1, element.Width);
element.IsRootElement = false;
Assert.IsFalse(element.IsVisible);
Assert.AreEqual(0, rootClock.Clocks.Count());
rootClock.Tick(TimeSpan.FromSeconds(0.2));
Assert.AreEqual(0.1, element.Width);
element.IsRootElement = true;
Assert.IsTrue(element.IsVisible);
Assert.AreEqual(1, rootClock.Clocks.Count());
Assert.AreEqual(0.2, element.Width);
rootClock.Tick(TimeSpan.FromSeconds(2));
Assert.AreEqual(0, rootClock.Clocks.Count());
element.IsRootElement = false;
element.IsRootElement = true;
Assert.AreEqual(0, rootClock.Clocks.Count());
}