コード例 #1
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        private void CreateRotateAnimation(StrokeCollection strokes, Point centerOffset, Point from, Point to)
        {
            Rect         bound = strokes.GetBounds();
            AnimationObj obj   = AnimationEngine.AddDurationActionAnimation(strokes, AnimationActionType.Rotate, centerOffset, 5, from, to, true);

            obj.Begin();
        }
コード例 #2
0
ファイル: Drawingboard.xaml.cs プロジェクト: tingxin/Kiosk
        void GoAnimation(StrokeCollection strokes, ATowardto atoward)
        {
            Rect  bound       = strokes.GetBounds();
            Rect  screenBound = new Rect(0, 0, this.ActualWidth, this.ActualHeight);
            Point from        = new Point(bound.Left + bound.Width / 2, bound.Top + bound.Height / 2);

            AnimationLibrary.Current.GetGoAnimationSync(bound, screenBound, atoward, false, (position) =>
            {
                AnimationObj ani1 = AnimationEngine.AddDurationActionAnimation(strokes, AnimationActionType.Translate, center, (int)position[0].Duration, from, position[0].To);
                AnimationObj ani2 = AnimationEngine.AddDurationActionAnimation(strokes, AnimationActionType.Translate, center, (int)position[2].Duration, position[1].To, position[2].To);


                ani1.AnimationCompleted += (sender, ex) =>
                {
                    Matrix maritx  = new Matrix();
                    double tChange = 0;
                    switch (atoward)
                    {
                    case ATowardto.ToLeft:
                    case ATowardto.ToRight:
                        tChange = position[1].To.X - position[0].To.X;
                        maritx.Translate(tChange, 0);
                        break;

                    case ATowardto.ToTop:
                    case ATowardto.ToBottom:
                        tChange = position[1].To.Y - position[0].To.Y;
                        maritx.Translate(0, tChange);
                        break;

                    default:
                        break;
                    }

                    strokes.Transform(maritx, false);
                    ani2.Begin();
                };

                ani2.AnimationCompleted += (sender, ex) =>
                {
                    Matrix maritx  = new Matrix();
                    double tChange = 0;
                    switch (atoward)
                    {
                    case ATowardto.ToLeft:
                    case ATowardto.ToRight:
                        tChange = position[1].To.X - position[0].To.X;
                        maritx.Translate(tChange, 0);
                        break;

                    case ATowardto.ToTop:
                    case ATowardto.ToBottom:
                        tChange = position[1].To.Y - position[0].To.Y;
                        maritx.Translate(0, tChange);
                        break;

                    default:
                        break;
                    }

                    strokes.Transform(maritx, false);
                    ani2.Begin();
                };

                ani1.Begin();
            });
        }