当前位置: 首页>>代码示例>>C#>>正文


C# Storyboard.Seek方法代码示例

本文整理汇总了C#中System.Windows.Media.Animation.Storyboard.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.Seek方法的具体用法?C# Storyboard.Seek怎么用?C# Storyboard.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Animation.Storyboard的用法示例。


在下文中一共展示了Storyboard.Seek方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainWindow

 public MainWindow()
 {
     InitializeComponent();
       sb = (Storyboard)Resources["PeakBack"];
       sb.Begin();
       sb.Pause();
       sb.Seek(TimeSpan.FromSeconds(0));
       this.MouseEnter += new MouseEventHandler(MainWindow_MouseEnter);
       this.MouseLeave += new MouseEventHandler(MainWindow_MouseLeave);
 }
开发者ID:git109,项目名称:healthkick,代码行数:10,代码来源:MainWindow.xaml.cs

示例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);
        }
开发者ID:highzion,项目名称:Granular,代码行数:43,代码来源:StoryboardTest.cs

示例3: Transition

		private void Transition(Storyboard aStoryboard, Storyboard bStoryboard)
		{
			if (m_AnimationElement == null || bStoryboard == null)
				return;

			bStoryboard.Stop();

			// Give the target a unique name so we can find it later
			string name = Guid.NewGuid().ToString();
			bStoryboard.SetTargetName(name);
			m_AnimationElement.Tag = name;

			bStoryboard.SetTarget(m_AnimationElement);
			foreach (Timeline animation in bStoryboard.Children)
				animation.SetTarget(m_AnimationElement);

			//m_AnimationElement.Visibility = Visibility.Visible;
			m_AnimationElement.UpdateLayout();
			if (aStoryboard != null)
			{
				aStoryboard.Pause();
				Duration duration = bStoryboard.Duration;
				TimeSpan timeSpan = aStoryboard.GetCurrentTime();
				bStoryboard.Begin();
				if (timeSpan.TotalMilliseconds != 0 && duration.HasTimeSpan)
					bStoryboard.Seek(duration.TimeSpan - timeSpan);
			}
			else
				bStoryboard.Begin();
		}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例4: DisplaySuccessNotification

        private void DisplaySuccessNotification()
        {
            var c = new Canvas();
            c.Background = (SolidColorBrush)App.Current.Resources["PhoneAccentBrush"];
            c.Height = 72;
            c.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            c.Opacity = 0;
            c.RenderTransform = new CompositeTransform();
            c.Children.Add(new TextBlock()
            {
                Text = "Document saved successfully",
                Foreground = new SolidColorBrush(Colors.White),
                FontSize = 23,
                VerticalAlignment = System.Windows.VerticalAlignment.Center,
                Margin = new Thickness(10, 20, 0, 0)
            });
            LayoutRoot.Children.Add(c);

            var sbc = new Storyboard();
            EventHandler completed = (s, e) =>
            {
                sbc.BeginTime = TimeSpan.FromMilliseconds(1000);
                sbc.Children.Add(AnimationUtils.TranslateX(0, 500, 200, new ExponentialEase() { EasingMode = EasingMode.EaseInOut, Exponent = 2 }, c));
                sbc.Children.Add(AnimationUtils.FadeOut(150, c));
                sbc.Begin();
            };
            c.Tap += (s, e) =>
            {
                sbc.Seek(TimeSpan.FromMilliseconds(1000));
            };

            var sb = new Storyboard();
            sb.Children.Add(AnimationUtils.TranslateX(-500, 0, 200, new ExponentialEase() { EasingMode = EasingMode.EaseInOut, Exponent = 2 }, c));
            sb.Children.Add(AnimationUtils.FadeIn(150, c));
            sb.Completed += completed;
            sb.Begin();
        }
开发者ID:ireynolds,项目名称:Document-Store,代码行数:37,代码来源:DocumentEditor.xaml.cs

示例5: AnimateChildrenIn

        private void AnimateChildrenIn(bool reverse)
        {
            if (_popupContentControl == null) return;
            if (VisualTreeHelper.GetChildrenCount(_popupContentControl) != 1) return;
            var contentPresenter = VisualTreeHelper.GetChild(_popupContentControl, 0) as ContentPresenter;

            var controls = contentPresenter.VisualDepthFirstTraversal().OfType<ButtonBase>();
            double translateCoordinateFrom;
            if ((PlacementMode == PopupBoxPlacementMode.TopAndAlignCentres
                 || PlacementMode == PopupBoxPlacementMode.TopAndAlignLeftEdges
                 || PlacementMode == PopupBoxPlacementMode.TopAndAlignRightEdges
                 || PlacementMode == PopupBoxPlacementMode.LeftAndAlignBottomEdges
                 || PlacementMode == PopupBoxPlacementMode.RightAndAlignBottomEdges
                 || (UnfurlOrientation == Orientation.Horizontal &&
                     (
                         PlacementMode == PopupBoxPlacementMode.LeftAndAlignBottomEdges
                         || PlacementMode == PopupBoxPlacementMode.LeftAndAlignMiddles
                         || PlacementMode == PopupBoxPlacementMode.LeftAndAlignTopEdges
                         ))
                ))
            {
                controls = controls.Reverse();
                translateCoordinateFrom = 80;
            }
            else
                translateCoordinateFrom = -80;

            var translateCoordinatePath =
                "(UIElement.RenderTransform).(TransformGroup.Children)[1].(TranslateTransform."
                + (UnfurlOrientation == Orientation.Horizontal ? "X)" : "Y)");

            var sineEase = new SineEase();

            var i = 0;
            foreach (var uiElement in controls)
            {
                var deferredStart = i++*20;
                var deferredEnd = deferredStart+200.0;

                var absoluteZeroKeyTime = KeyTime.FromPercent(0.0);
                var deferredStartKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(deferredStart));
                var deferredEndKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(deferredEnd));

                var elementTranslateCoordinateFrom = translateCoordinateFrom * i;
                var translateTransform = new TranslateTransform(
                    UnfurlOrientation == Orientation.Vertical ? 0 : elementTranslateCoordinateFrom,
                    UnfurlOrientation == Orientation.Vertical ? elementTranslateCoordinateFrom : 0);

                var transformGroup = new TransformGroup
                {
                    Children = new TransformCollection(new Transform[]
                    {
                        new ScaleTransform(0, 0),
                        translateTransform
                    })
                };
                uiElement.SetCurrentValue(RenderTransformOriginProperty, new Point(.5, .5));
                uiElement.RenderTransform = transformGroup;

                var opacityAnimation = new DoubleAnimationUsingKeyFrames();
                opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, absoluteZeroKeyTime, sineEase));
                opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, deferredStartKeyTime, sineEase));
                opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, deferredEndKeyTime, sineEase));
                Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
                Storyboard.SetTarget(opacityAnimation, uiElement);

                var scaleXAnimation = new DoubleAnimationUsingKeyFrames();
                scaleXAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, absoluteZeroKeyTime, sineEase));
                scaleXAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, deferredStartKeyTime, sineEase));
                scaleXAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, deferredEndKeyTime, sineEase));
                Storyboard.SetTargetProperty(scaleXAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
                Storyboard.SetTarget(scaleXAnimation, uiElement);

                var scaleYAnimation = new DoubleAnimationUsingKeyFrames();
                scaleYAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, absoluteZeroKeyTime, sineEase));
                scaleYAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, deferredStartKeyTime, sineEase));
                scaleYAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, deferredEndKeyTime, sineEase));
                Storyboard.SetTargetProperty(scaleYAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
                Storyboard.SetTarget(scaleYAnimation, uiElement);

                var translateCoordinateAnimation = new DoubleAnimationUsingKeyFrames();
                translateCoordinateAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(elementTranslateCoordinateFrom, absoluteZeroKeyTime, sineEase));
                translateCoordinateAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(elementTranslateCoordinateFrom, deferredStartKeyTime, sineEase));
                translateCoordinateAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, deferredEndKeyTime, sineEase));

                Storyboard.SetTargetProperty(translateCoordinateAnimation, new PropertyPath(translateCoordinatePath));
                Storyboard.SetTarget(translateCoordinateAnimation, uiElement);

                var storyboard = new Storyboard();
                storyboard.Children.Add(opacityAnimation);
                storyboard.Children.Add(scaleXAnimation);
                storyboard.Children.Add(scaleYAnimation);
                storyboard.Children.Add(translateCoordinateAnimation);

                if (reverse)
                {
                    storyboard.AutoReverse = true;
                    storyboard.Begin();
                    storyboard.Seek(TimeSpan.FromMilliseconds(deferredEnd));
                    storyboard.Resume();
//.........这里部分代码省略.........
开发者ID:patchandthat,项目名称:MaterialDesignInXamlToolkit,代码行数:101,代码来源:PopupBox.cs

示例6: Invoke

    /// <summary> 
    ///     Called when it's time to execute this storyboard action
    /// </summary> 
    internal override void Invoke( FrameworkElement containingFE, FrameworkContentElement containingFCE, Storyboard storyboard ) 
    {
        Debug.Assert( containingFE != null || containingFCE != null, 
            "Caller of internal function failed to verify that we have a FE or FCE - we have neither." );

        if( containingFE != null )
        { 
            storyboard.Seek(containingFE, Offset, Origin);
        } 
        else 
        {
            storyboard.Seek(containingFCE, Offset, Origin); 
        }
    }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:17,代码来源:SeekStoryboard.cs

示例7: RotateInterstitialAd

 /// <summary>
 /// animation for banner ad
 /// </summary>
 private void RotateInterstitialAd()
 {
     Storyboard _storyBourd = new Storyboard();
     DoubleAnimation _doubleAnimation = new DoubleAnimation();
     _doubleAnimation.From = 90;
     _doubleAnimation.To = 0;
     PlaneProjection projection1 = new PlaneProjection();
     Maingrid.Projection = projection1;
     _doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(1.25));
     Storyboard.SetTarget(_doubleAnimation, Maingrid.Projection);
     Storyboard.SetTargetProperty(_doubleAnimation, new PropertyPath(PlaneProjection.RotationXProperty));
     _storyBourd.Children.Add(_doubleAnimation);
     _storyBourd.Seek(TimeSpan.FromSeconds(0.5));
     _storyBourd.Begin();
 }
开发者ID:tapit,项目名称:TapIt-Windows-SDK,代码行数:18,代码来源:InterstitialAdView.cs


注:本文中的System.Windows.Media.Animation.Storyboard.Seek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。