private void TurnPage(int duration) { Status = PageStatus.TurnAnimation; UIElement source = this as UIElement; CornerPoint = _cornerPoint; //this.BeginAnimation(UCPage.CornerPointProperty, null); //PointAnimation anim = // new PointAnimation( // OriginToOppositePoint(this, origin), // new Duration(TimeSpan.FromMilliseconds(duration))); //anim.AccelerationRatio = 0.6; //anim.CurrentTimeInvalidated +=new EventHandler(anim_CurrentTimeInvalidated); //anim.Completed += new EventHandler(anim_Completed); //this.BeginAnimation(UCPage.CornerPointProperty, anim); var anim = new TimerAnimation <Point>(this, UCPage.CornerPointProperty, OriginToOppositePoint(this, origin), new Duration(TimeSpan.FromMilliseconds(duration)), (from, to, percent) => new Point { X = from.X + (to.X - from.X) * percent, Y = from.Y + (to.Y - from.Y) * percent }); anim.Completed += new EventHandler(anim_Completed); anim.Begin(); }
private void DropPage(int duration) { Status = PageStatus.DropAnimation; UIElement source = this as UIElement; CornerPoint = _cornerPoint; //this.BeginAnimation(UCPage.CornerPointProperty, null); //PointAnimation anim = // new PointAnimation() // { // To = OriginToPoint(this, origin), // Duration = new Duration(TimeSpan.FromMilliseconds(duration)) // }; //anim.AccelerationRatio = 0.6; //anim.CurrentTimeInvalidated += new EventHandler(anim_CurrentTimeInvalidated); //anim.Completed += new EventHandler(anim_TurnPageCompleted); //var sb = new Storyboard(); //sb.Duration = anim.Duration; //sb.Children.Add(anim); //Storyboard.SetTarget(anim, this); //Storyboard.SetTargetProperty(anim, "CornerPoint"); //(this.Parent as FrameworkElement).Resources.Add(sb); //this.Resources.Add(sb); //sb.Completed += new EventHandler(anim_TurnPageCompleted); //sb.Begin(); //this.BeginAnimation(UCPage.CornerPointProperty, anim); var anim = new TimerAnimation <Point>(this, UCPage.CornerPointProperty, OriginToPoint(this, origin), new Duration(TimeSpan.FromMilliseconds(duration)), (from, to, percent) => new Point { X = from.X + (to.X - from.X) * percent, Y = from.Y + (to.Y - from.Y) * percent }); anim.Completed += new EventHandler(anim_DropPageCompleted); anim.Begin(); //MessageBox.Show("DropPage"); }
public void AutoTurnPage(CornerOrigin fromCorner, int duration) { if (Status != PageStatus.None) { return; } Status = PageStatus.TurnAnimation; UIElement source = this as UIElement; Point startPoint = OriginToPoint(this, fromCorner); Point endPoint = OriginToOppositePoint(this, fromCorner); origin = fromCorner; CornerPoint = startPoint; //BezierSegment bs = // new BezierSegment { Point1 = startPoint, Point2 = new Point(endPoint.X + (startPoint.X - endPoint.X) / 3, 250), Point3 = endPoint }; //PathGeometry path = new PathGeometry(); //PathFigure figure = new PathFigure(); //figure.StartPoint = startPoint; //figure.Segments.Add(bs); //figure.IsClosed = false; //path.Figures.Add(figure); //PointAnimationUsingPath anim = // new PointAnimationUsingPath(); //anim.PathGeometry = path; //anim.Duration = new Duration(TimeSpan.FromMilliseconds(duration)); //anim.AccelerationRatio = 0.6; //anim.CurrentTimeInvalidated += new EventHandler(anim_CurrentTimeInvalidated); var anim = new TimerAnimation <Point>(this, UCPage.CornerPointProperty, endPoint, new Duration(TimeSpan.FromMilliseconds(duration)), (from, to, percent) => ComputeAutoAnimationPoints(from, to, percent)); anim.Completed += new EventHandler(anim_Completed); anim.Begin(); }