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


C# Animation.Storyboard类代码示例

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


Storyboard类属于Windows.UI.Xaml.Media.Animation命名空间,在下文中一共展示了Storyboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AnimateVertexBackward

        public void AnimateVertexBackward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                target.RenderTransformOrigin = CenterScale ? new Point(.5, .5) : new Point(0, 0);
                return; //no need to back cause default already
            }

            if (transform.ScaleX <= 1 || transform.ScaleY <= 1) return;

            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation{ Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);

            //transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            //transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            sb.Begin();
        }
开发者ID:aliaspilote,项目名称:TX52,代码行数:27,代码来源:MouseOverScaleAnimation.cs

示例2: LoginPage

        //public LoginPageViewModel vm { get; private set; }
        public LoginPage()
        {
            this.InitializeComponent();
            DataContextChanged += LoginPage_DataContextChanged;
            _toRegSb = new Storyboard();
            Duration duration = new Duration(TimeSpan.FromSeconds(0.2));
            _logspda = new DoubleAnimation()
            {
                From = 0,
                To = -FrameWidth,
                AutoReverse = false,
                Duration = duration
            };
            _regspda = new DoubleAnimation()
            {
                From = FrameWidth,
                To = 0,
                AutoReverse = false,
                Duration = duration
            };
            Storyboard.SetTargetProperty(_regspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTargetProperty(_logspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTarget(_logspda, logSP);
            Storyboard.SetTarget(_regspda, regSP);

            _toRegSb.Children.Add(_regspda);
            _toRegSb.Children.Add(_logspda);

            Rect rect = new Rect(0, 0, FrameWidth, 300);
            RectangleGeometry reo = new RectangleGeometry();
            reo.Rect = rect;
            this.infoBorder.Clip = reo;
        }
开发者ID:csongysun,项目名称:HJXYT,代码行数:34,代码来源:LoginPage.xaml.cs

示例3: CreateAnimationCore

        /// <summary>
        /// Create a <see cref="Storyboard"/> to be used to animate the view, 
        /// based on the animation configuration supplied at initialization
        /// time and the new view position and size.
        /// </summary>
        /// <param name="view">The view to create the animation for.</param>
        /// <param name="dimensions">The view dimensions.</param>
        protected override IObservable<Unit> CreateAnimationCore(FrameworkElement view, Dimensions dimensions)
        {
            var fromValue = IsReverse ? 1.0 : 0.0;
            var toValue = IsReverse ? 0.0 : 1.0;

            var animatedProperty = AnimatedProperty;
            if (animatedProperty.HasValue)
            {
                var storyboard = new Storyboard();
                var @finally = default(Action);
                switch (animatedProperty.Value)
                {
                    case AnimatedPropertyType.Opacity:
                        view.Opacity = fromValue;
                        storyboard.Children.Add(CreateOpacityAnimation(view, fromValue, toValue));
                        @finally = () => view.Opacity = toValue;
                        break;
                    case AnimatedPropertyType.ScaleXY:
                        // TODO: implement this layout animation option
                        throw new NotImplementedException();
                    default:
                        throw new InvalidOperationException(
                            "Missing animation for property: " + animatedProperty.Value);
                }

                return new StoryboardObservable(storyboard, @finally);
            }

            throw new InvalidOperationException(
                "Missing animated property from the animation configuration.");
        }
开发者ID:chukcha-wtf,项目名称:react-native-windows,代码行数:38,代码来源:BaseLayoutAnimation.cs

示例4: StartAnimation

        private void StartAnimation(EasingFunctionBase easingFunction)
        {
            // show the chart
            chartControl.Draw(easingFunction);

            // animation
#if WPF
            NameScope.SetNameScope(translate1, new NameScope());
#endif

            var storyboard = new Storyboard();
            var ellipseMove = new DoubleAnimation();
            ellipseMove.EasingFunction = easingFunction;
            ellipseMove.Duration = new Duration(TimeSpan.FromSeconds(AnimationTimeSeconds));
            ellipseMove.From = 0;
            ellipseMove.To = 460;
#if WPF
            Storyboard.SetTargetName(ellipseMove, nameof(translate1));
            Storyboard.SetTargetProperty(ellipseMove, new PropertyPath(TranslateTransform.XProperty));
#else
            Storyboard.SetTarget(ellipseMove, translate1);
            Storyboard.SetTargetProperty(ellipseMove, "X");
#endif

            ellipseMove.BeginTime = TimeSpan.FromSeconds(0.5); // start animation in 0.5 seconds
            ellipseMove.FillBehavior = FillBehavior.HoldEnd; // keep position after animation

            storyboard.Children.Add(ellipseMove);
#if WPF
            storyboard.Begin(this);
#else
            storyboard.Begin();
#endif
        }
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:34,代码来源:EasingFunctions.xaml.cs

示例5: UIElement_OnPointerEntered

        private void UIElement_OnPointerEntered(object sender, PointerRoutedEventArgs e)
        {
            var border = (Border)sender;

            // Somehow ZIndex doesn't work in the UniformGrid
            // Perhaps if Jupiter had a method called Panel.GetVisualChild available to override...
            // See: http://blog.pixelingene.com/2007/12/controlling-z-index-of-children-in-custom-controls/
            //Canvas.SetZIndex(border, ++_maxZIndex);
            var sb = new Storyboard();

            var a1 = new DoubleAnimation();
            a1.Duration = TimeSpan.FromSeconds(0.2);
            a1.To = 0.9;
            a1.EasingFunction = new PowerEase { Power = 2, EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(a1, border.RenderTransform);
            Storyboard.SetTargetProperty(a1, "ScaleX");
            sb.Children.Add(a1);

            var a2 = new DoubleAnimation();
            a2.Duration = TimeSpan.FromSeconds(0.2);
            a2.To = 0.9;
            a2.EasingFunction = new PowerEase { Power = 2, EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(a2, border.RenderTransform);
            Storyboard.SetTargetProperty(a2, "ScaleY");
            sb.Children.Add(a2);

            sb.Begin();
        }
开发者ID:siatwangmin,项目名称:WinRTXamlToolkit,代码行数:28,代码来源:UniformGridTestView.xaml.cs

示例6: StartAnimation

        /// <summary>
        /// Starts new animation from given images. 
        /// </summary>
        /// <param name="imageNames">Names of images in assets folder</param>
        /// <param name="interval">Interval between animation frames</param>
        public void StartAnimation(IEnumerable<string> imageNames, TimeSpan interval)
        {
            Storyboard storyboard = new Storyboard();
            ObjectAnimationUsingKeyFrames animation = new ObjectAnimationUsingKeyFrames();

            // We're going to animate image inside our control.
            Storyboard.SetTarget(animation, image);
            // Animation relies on changing value of property source
            Storyboard.SetTargetProperty(animation, nameof(image.Source));

            TimeSpan currentInterval = TimeSpan.FromMilliseconds(0);
            foreach (string imageName in imageNames)
            {
                // We're creating individual frames from given images
                ObjectKeyFrame keyFrame = new DiscreteObjectKeyFrame();
                keyFrame.Value = CreateImageFromAssets(imageName);
                keyFrame.KeyTime = currentInterval;
                animation.KeyFrames.Add(keyFrame);
                currentInterval = currentInterval.Add(interval);
            }

            // We're configuring our storyboard which will play animations
            storyboard.RepeatBehavior = RepeatBehavior.Forever;
            storyboard.AutoReverse = true;
            storyboard.Children.Add(animation);
            storyboard.Begin();
        }
开发者ID:Arasz,项目名称:Invaders,代码行数:32,代码来源:AnimatedImage.xaml.cs

示例7: CreateDoubleSB

        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double from, Double to, EasingMode em)
        {
        //<Storyboard x:Name="Storyboard1">
        //    <DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="border">
        //        <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
        //    </DoubleAnimationUsingKeyFrames>
        //</Storyboard>
            DoubleAnimationUsingKeyFrames daKeyFrame = new DoubleAnimationUsingKeyFrames();
            EasingDoubleKeyFrame edKeyFrame = new EasingDoubleKeyFrame();
            edKeyFrame.KeyTime = TimeSpan.FromSeconds(secondTime);
            edKeyFrame.Value = to;
            CircleEase ce = new CircleEase();
            ce.EasingMode = em;
            edKeyFrame.EasingFunction = ce;

            daKeyFrame.KeyFrames.Add(edKeyFrame);
            daKeyFrame.EnableDependentAnimation = true;

            Storyboard.SetTarget(daKeyFrame, dpnObj);
            Storyboard.SetTargetProperty(daKeyFrame, property);
            Storyboard sb = new Storyboard();

            sb.Children.Add(daKeyFrame);
            return sb;
        }
开发者ID:wpdu,项目名称:ControlTest,代码行数:25,代码来源:DoubleAnimationTest.xaml.cs

示例8: AnimateOpacity

        static public void AnimateOpacity(FrameworkElement element, double start, double end, double duration)
        {
            element.Opacity = 0;

            Duration animationDuration = new Duration(TimeSpan.FromSeconds(duration));
            DoubleAnimation opacityAnimation = new DoubleAnimation();

            opacityAnimation.Duration = animationDuration;
            opacityAnimation.From = start;
            opacityAnimation.To = end;

            Storyboard sb = new Storyboard();
            sb.Duration = animationDuration;

            sb.Children.Add(opacityAnimation);

            Storyboard.SetTarget(opacityAnimation, element);

            // Set the X and Y properties of the Transform to be the target properties
            // of the two respective DoubleAnimations.
            Storyboard.SetTargetProperty(opacityAnimation, "Opacity");

            // Begin the animation.
            sb.Begin();
        }
开发者ID:grantamos,项目名称:decibel,代码行数:25,代码来源:AnimationLibrary.cs

示例9: MoveTo

        public void MoveTo(Point from, Point to, EventHandler<object> completed = null)
        {
            TranslateTransform trans = new TranslateTransform();

            _participant.Name = "MyTarget";
            _participant.RenderTransform = trans;

            DoubleAnimation anim1 = new DoubleAnimation() { From = from.X, To = to.X, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };
            DoubleAnimation anim2 = new DoubleAnimation() { From = from.Y, To = to.Y, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };

            Storyboard.SetTarget(anim1, _participant);
            Storyboard.SetTargetName(anim1, _participant.Name);
            Storyboard.SetTargetProperty(anim1, "(Canvas.Left)");

            Storyboard.SetTarget(anim2, _participant);
            Storyboard.SetTargetName(anim2, _participant.Name);
            Storyboard.SetTargetProperty(anim2, "(Canvas.Top)");

            Storyboard sb = new Storyboard();
            sb.Children.Add(anim1);
            sb.Children.Add(anim2);

            if (completed == null)
                sb.Completed += (object sender, object e) => { };
            else
                sb.Completed += completed;

            sb.Begin();
        }
开发者ID:bramom,项目名称:Bug.RS,代码行数:29,代码来源:Sprite.cs

示例10: GetStoryBoardControl

 private void GetStoryBoardControl(string name)
 {
     if (this.storyBoard == null)
     {
         this.storyBoard = this.GetTemplateChild(name) as Storyboard;
     }
 }
开发者ID:CuiXiaoDao,项目名称:cnblogs-UAP,代码行数:7,代码来源:NewsControl.cs

示例11: FadeIn

        private void FadeIn()
        {
            if (_Running)
            {
                DoubleAnimation fadeIn = new DoubleAnimation();

                fadeIn.From = 0.0;
                fadeIn.To = 1;
                fadeIn.Duration = new Duration(TimeSpan.FromSeconds(2));
                fadeIn.BeginTime = TimeSpan.FromSeconds(2);

                Storyboard sb = new Storyboard();

                Storyboard.SetTarget(fadeIn, _Control);
                Storyboard.SetTargetProperty(fadeIn, "Opacity");

                sb.Children.Add(fadeIn);

                _Control.Resources.Clear();
                _Control.Resources.Add("FaderEffect", sb);

                sb.Completed += this.OnFadeInCompleted;

                sb.Begin();
            }
        }
开发者ID:rllibby,项目名称:SignalR,代码行数:26,代码来源:MainPage.xaml.cs

示例12: VEManipulationEndX

        private void VEManipulationEndX( object sender, ManipulationCompletedRoutedEventArgs e )
        {
            double dv = e.Cumulative.Translation.X.Clamp( MinVT, MaxVT );
            ContentAway?.Stop();
            if ( VT < dv )
            {
                ContentAway = new Storyboard();
                SimpleStory.DoubleAnimation(
                    ContentAway, CGTransform, "TranslateX"
                    , CGTransform.TranslateX
                    , MainSplitView.ActualWidth );

                ContentBeginAwayX( false );
            }
            else if ( dv < -VT )
            {
                ContentAway = new Storyboard();
                SimpleStory.DoubleAnimation(
                    ContentAway, CGTransform, "TranslateX"
                    , CGTransform.TranslateX
                    , -MainSplitView.ActualWidth );

                ContentBeginAwayX( true );
            }
            else
            {
                ContentRestore.Begin();
            }
        }
开发者ID:tgckpg,项目名称:wenku10,代码行数:29,代码来源:ContentReader-VESwipe.xaml.cs

示例13: InitializeControl

        private void InitializeControl()
        {
            try
            {

                if (root == null)
                {
                    root = (Canvas)GetTemplateChild("root");
                    layerStoryboard = (Storyboard)root.Resources["layerStoryboard"];

                    layerAnimationX = (DoubleAnimation)layerStoryboard.Children[0];
                    layerAnimationY = (DoubleAnimation)layerStoryboard.Children[1];

                    layerState = new LayerState(SensitivityX, SensitivityY);

                    Conductor.Beat += Conductor_Beat;

                    rootParent = (Canvas)this.Parent;
                    //rootParent.PointerPressed += rootParent_PointerPressed;
                    rootParent.ManipulationDelta += rootParent_ManipulationDelta;
                    rootParent.ManipulationMode = this.ManipulationMode; // &ManipulationModes.TranslateY;

                }


            }
            catch { }
        }
开发者ID:liquidboy,项目名称:X,代码行数:28,代码来源:InnertialLayer.cs

示例14: AnimateVertexForward

        public void AnimateVertexForward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                if (CenterScale)
                    target.RenderTransformOrigin = new Point(.5, .5);
                else
                    target.RenderTransformOrigin = new Point(0, 0);
            }

            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);

            //transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            //transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            sb.Begin();
        }
开发者ID:aliaspilote,项目名称:TX52,代码行数:27,代码来源:MouseOverScaleAnimation.cs

示例15: EventToken

 public EventToken(Timeline animation, Storyboard storyboard)
 {
     _Children = new Dictionary<IAnimator, TimeSpan?>();
     _Animation = animation;
     _Animation.Completed += AnimationEventHandler;
     TokenStoryboard = storyboard;
 }
开发者ID:ThatLousyGuy,项目名称:Monolith,代码行数:7,代码来源:EventToken.cs


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