示例#1
0
        void AnimateImageView( View imageView, PointF startPos, PointF endPos, System.Drawing.SizeF startSize, System.Drawing.SizeF endSize, float duration, SimpleAnimator.AnimationComplete completeDelegate )
        {
            // calculate the deltas once before we start
            float xDelta = endPos.X - startPos.X;
            float yDelta = endPos.Y - startPos.Y;

            float deltaWidth = endSize.Width - startSize.Width;
            float deltaHeight = endSize.Height - startSize.Height;

            // create an animator
            SimpleAnimator_Float imageAnimator = new SimpleAnimator_Float( 0.00f, 1.00f, duration,
                delegate( float percent, object value )
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread( delegate
                        {
                            // each update, interpolate the deltas and apply
                            imageView.SetX( startPos.X + ( xDelta * percent ) );
                            imageView.SetY( startPos.Y + ( yDelta * percent ) );

                            imageView.LayoutParameters.Width = (int)( startSize.Width + ( deltaWidth * percent ) );
                            imageView.LayoutParameters.Height = (int)( startSize.Height + ( deltaHeight * percent ) );

                            // force the image to re-evaluate its size
                            imageView.RequestLayout( );
                        } );
                },
                //ANIMATION COMPLETE
                delegate
                {
                    if ( completeDelegate != null )
                    {
                        Rock.Mobile.Threading.Util.PerformOnUIThread( delegate
                            {
                                completeDelegate( );
                            } );
                    }
                } );

            imageAnimator.Start( );
        }