protected override void Init() { SetBaseView(); TranslateTransform translation = new TranslateTransform(0, 0); dauY = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new TranslateTransform(0, 0); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as TranslateTransform; if (translation != null) { break; } } if (translation != null) { var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); } } else { translation = new TranslateTransform(0, 0); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion Win.RegisterResource(Story); Story = (Storyboard)Story.CloneCurrentValue(); var k2 = new EasingDoubleKeyFrame(OneValue, TimeSpan.FromMilliseconds(0)); var k2_0 = new EasingDoubleKeyFrame(TwoValue, TimeSpan.FromMilliseconds(AniTime(0.2))); var k2_1 = new EasingDoubleKeyFrame(ThreeValue, TimeSpan.FromMilliseconds(AniTime(0.4))); var k2_2 = new EasingDoubleKeyFrame(ThreeValue, TimeSpan.FromMilliseconds(AniTime(0.45))); var k2_3 = new EasingDoubleKeyFrame(FourValue, TimeSpan.FromMilliseconds(AniTime(1))); Storyboard.SetTargetName(dauY, Win.GetName(translation)); Storyboard.SetTargetProperty(dauY, new PropertyPath(TranslateTransform.YProperty)); dauY.KeyFrames.Add(k2); dauY.KeyFrames.Add(k2_0); dauY.KeyFrames.Add(k2_1); dauY.KeyFrames.Add(k2_2); dauY.KeyFrames.Add(k2_3); Story.Children.Add(dauY); dauY.FillBehavior = FillBehavior.Stop; dauOpacty = new DoubleAnimationUsingKeyFrames(); var k3 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(AniTime(0))); var k3_0 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(AniTime(0.45))); var k3_1 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(1))); dauOpacty.KeyFrames.Add(k3); dauOpacty.KeyFrames.Add(k3_0); dauOpacty.KeyFrames.Add(k3_1); Storyboard.SetTarget(dauOpacty, Element); dauOpacty.FillBehavior = FillBehavior.Stop; Storyboard.SetTargetProperty(dauOpacty, new PropertyPath(UIElement.OpacityProperty)); Story.Children.Add(dauOpacty); Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); dau = new DoubleAnimationUsingKeyFrames(); TranslateTransform translation = new TranslateTransform(0, 0); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new TranslateTransform(0, 0); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as TranslateTransform; if (translation != null) { break; } } if (translation != null) { //当前Y值 var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); } } else { translation = new TranslateTransform(0, 0); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion if (FromDistance == 0) { FromDistance = Element.RenderSize.Width * (-1.5); } var k2 = new EasingDoubleKeyFrame(FromDistance, TimeSpan.FromMilliseconds(AniTime(0))); var k3 = new EasingDoubleKeyFrame(ToDistance, TimeSpan.FromMilliseconds(AniTime(1))); if (EasingFunction != null) { k3.EasingFunction = EasingFunction; } Storyboard.SetTargetName(dau, Win.GetName(translation)); Storyboard.SetTargetProperty(dau, new PropertyPath(TranslateTransform.XProperty)); dau.FillBehavior = AniEndBehavior; Win.RegisterResource(Story); Story = (Storyboard)Story.CloneCurrentValue(); dau.KeyFrames.Add(k2); dau.KeyFrames.Add(k3); Story.Children.Add(dau); if (OpacityNeed) { dauOpacty = new DoubleAnimationUsingKeyFrames(); var k6 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(0))); var k6_1 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(AniTime(1))); dauOpacty.KeyFrames.Add(k6); dauOpacty.KeyFrames.Add(k6_1); Storyboard.SetTarget(dauOpacty, Element); dauOpacty.FillBehavior = FillBehavior.Stop; Storyboard.SetTargetProperty(dauOpacty, new PropertyPath(UIElement.OpacityProperty)); Story.Children.Add(dauOpacty); } Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); TranslateTransform translation = new TranslateTransform(); dau1 = new DoubleAnimationUsingKeyFrames(); dau2 = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new TranslateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as TranslateTransform; if (translation != null) { break; } } if (translation != null) { //当前Y值 var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation); } } else { translation = new TranslateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion double sx = translation.X; double sy = translation.Y; if (!TranslateXFrom.HasValue && !TranslateYFrom.HasValue && TranslateXTo.HasValue && TranslateXTo == sx && TranslateYTo.HasValue && TranslateYTo == sy) { return; } EasingDoubleKeyFrame k2_xFrom = null; EasingDoubleKeyFrame k2_yFrom = null; if (TranslateXFrom.HasValue) { k2_xFrom = new EasingDoubleKeyFrame(TranslateXFrom.Value, TimeSpan.FromMilliseconds(AniTime(0))); } if (TranslateYFrom.HasValue) { k2_yFrom = new EasingDoubleKeyFrame(TranslateYFrom.Value, TimeSpan.FromMilliseconds(AniTime(0))); } EasingDoubleKeyFrame k2_x = null; EasingDoubleKeyFrame k2_y = null; if (TranslateXAdd.HasValue) { k2_x = new EasingDoubleKeyFrame(TranslateXAdd.Value + sx, TimeSpan.FromMilliseconds(AniTime(1))); } else if (TranslateXTo.HasValue) { k2_x = new EasingDoubleKeyFrame(TranslateXTo.Value, TimeSpan.FromMilliseconds(AniTime(1))); } if (TranslateYAdd.HasValue) { k2_y = new EasingDoubleKeyFrame(TranslateYAdd.Value + sx, TimeSpan.FromMilliseconds(AniTime(1))); } else if (TranslateYTo.HasValue) { k2_y = new EasingDoubleKeyFrame(TranslateYTo.Value, TimeSpan.FromMilliseconds(AniTime(1))); } if (EasingFunction != null) { k2_x.EasingFunction = EasingFunction; k2_y.EasingFunction = EasingFunction; } Storyboard.SetTargetName(dau1, Win.GetName(translation)); Storyboard.SetTargetProperty(dau1, new PropertyPath(TranslateTransform.XProperty)); Storyboard.SetTargetName(dau2, Win.GetName(translation)); Storyboard.SetTargetProperty(dau2, new PropertyPath(TranslateTransform.YProperty)); if (AniAutoReverse.HasValue) { Story.AutoReverse = AniAutoReverse.Value; } if (k2_xFrom != null) { dau1.KeyFrames.Add(k2_xFrom); } if (k2_yFrom != null) { dau2.KeyFrames.Add(k2_yFrom); } if (k2_x != null) { dau1.KeyFrames.Add(k2_x); } if (k2_y != null) { dau2.KeyFrames.Add(k2_y); } Win.RegisterResource(Story); Story = (Storyboard)Story.CloneCurrentValue(); Story.Children.Add(dau1); Story.Children.Add(dau2); Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); RotateTransform translation = new RotateTransform(); ScaleTransform translationScale = new ScaleTransform(1, 1); dau = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new RotateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Win.RegisterName(translationScale); tg.Children.Add(translationScale); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as RotateTransform; if (translation != null) { break; } } foreach (var item in tg.Children) { translationScale = item as ScaleTransform; if (translationScale != null) { break; } } if (translation != null) { //当前Y值 var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation); } } else { translation = new RotateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } if (translationScale != null) { var tex = translationScale.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translationScale); } } else { translationScale = new ScaleTransform(1, 1); Win.RegisterName(translationScale); tg.Children.Add(translationScale); Element.RenderTransform = tg; } } #endregion translation.CenterX = 0.5; translation.CenterY = 0; double angle = translation.Angle; var k2 = new EasingDoubleKeyFrame(angle - 3, TimeSpan.FromMilliseconds(AniTime(0.1))); var k2_1 = new EasingDoubleKeyFrame(angle - 3, TimeSpan.FromMilliseconds(AniTime(0.2))); var k2_2 = new EasingDoubleKeyFrame(angle + 3, TimeSpan.FromMilliseconds(AniTime(0.3))); var k2_3 = new EasingDoubleKeyFrame(angle + 3, TimeSpan.FromMilliseconds(AniTime(0.5))); var k2_4 = new EasingDoubleKeyFrame(angle + 3, TimeSpan.FromMilliseconds(AniTime(0.7))); var k2_5 = new EasingDoubleKeyFrame(angle + 3, TimeSpan.FromMilliseconds(AniTime(0.9))); var k2_6 = new EasingDoubleKeyFrame(angle - 3, TimeSpan.FromMilliseconds(AniTime(0.4))); var k2_7 = new EasingDoubleKeyFrame(angle - 3, TimeSpan.FromMilliseconds(AniTime(0.6))); var k2_8 = new EasingDoubleKeyFrame(angle - 3, TimeSpan.FromMilliseconds(AniTime(0.8))); var k2_9 = new EasingDoubleKeyFrame(angle, TimeSpan.FromMilliseconds(AnimateSpeed)); Story = (Storyboard)Story.Clone(); Storyboard.SetTargetName(dau, Win.GetName(translation)); Storyboard.SetTargetProperty(dau, new PropertyPath(RotateTransform.AngleProperty)); Win.RegisterResource(Story); dau.KeyFrames.Add(k2); dau.KeyFrames.Add(k2_1); dau.KeyFrames.Add(k2_2); dau.KeyFrames.Add(k2_3); dau.KeyFrames.Add(k2_4); dau.KeyFrames.Add(k2_5); dau.KeyFrames.Add(k2_6); dau.KeyFrames.Add(k2_7); dau.KeyFrames.Add(k2_8); dau.KeyFrames.Add(k2_9); Story.Children.Add(dau); dauScaleX = new DoubleAnimationUsingKeyFrames(); dauScaleY = new DoubleAnimationUsingKeyFrames(); double scaleX = translationScale.ScaleX; double scaleY = translationScale.ScaleY; double s1 = scaleX + tadaScale; double s2 = scaleX - tadaScale; double s3 = scaleY + tadaScale; double s4 = scaleY - tadaScale; var k3 = new EasingDoubleKeyFrame(s2, TimeSpan.FromMilliseconds(AniTime(0.1))); var k3_1 = new EasingDoubleKeyFrame(s2, TimeSpan.FromMilliseconds(AniTime(0.2))); var k3_2 = new EasingDoubleKeyFrame(s1, TimeSpan.FromMilliseconds(AniTime(0.3))); var k3_3 = new EasingDoubleKeyFrame(s1, TimeSpan.FromMilliseconds(AniTime(0.5))); var k3_4 = new EasingDoubleKeyFrame(s1, TimeSpan.FromMilliseconds(AniTime(0.7))); var k3_5 = new EasingDoubleKeyFrame(s1, TimeSpan.FromMilliseconds(AniTime(0.9))); var k3_6 = new EasingDoubleKeyFrame(s1, TimeSpan.FromMilliseconds(AniTime(0.4))); var k3_7 = new EasingDoubleKeyFrame(s1, TimeSpan.FromMilliseconds(AniTime(0.6))); var k3_8 = new EasingDoubleKeyFrame(s1, TimeSpan.FromMilliseconds(AniTime(0.8))); var k3_9 = new EasingDoubleKeyFrame(scaleX, TimeSpan.FromMilliseconds(AnimateSpeed)); var k4 = new EasingDoubleKeyFrame(s4, TimeSpan.FromMilliseconds(AniTime(0.1))); var k4_1 = new EasingDoubleKeyFrame(s4, TimeSpan.FromMilliseconds(AniTime(0.2))); var k4_2 = new EasingDoubleKeyFrame(s3, TimeSpan.FromMilliseconds(AniTime(0.3))); var k4_3 = new EasingDoubleKeyFrame(s3, TimeSpan.FromMilliseconds(AniTime(0.5))); var k4_4 = new EasingDoubleKeyFrame(s3, TimeSpan.FromMilliseconds(AniTime(0.7))); var k4_5 = new EasingDoubleKeyFrame(s3, TimeSpan.FromMilliseconds(AniTime(0.9))); var k4_6 = new EasingDoubleKeyFrame(s3, TimeSpan.FromMilliseconds(AniTime(0.4))); var k4_7 = new EasingDoubleKeyFrame(s3, TimeSpan.FromMilliseconds(AniTime(0.6))); var k4_8 = new EasingDoubleKeyFrame(s3, TimeSpan.FromMilliseconds(AniTime(0.8))); var k4_9 = new EasingDoubleKeyFrame(scaleY, TimeSpan.FromMilliseconds(AnimateSpeed)); Storyboard.SetTargetName(dauScaleX, Win.GetName(translationScale)); Storyboard.SetTargetProperty(dauScaleX, new PropertyPath(ScaleTransform.ScaleXProperty)); Storyboard.SetTargetName(dauScaleY, Win.GetName(translationScale)); Storyboard.SetTargetProperty(dauScaleY, new PropertyPath(ScaleTransform.ScaleYProperty)); dauScaleX.KeyFrames.Add(k3); dauScaleX.KeyFrames.Add(k3_1); dauScaleX.KeyFrames.Add(k3_2); dauScaleX.KeyFrames.Add(k3_3); dauScaleX.KeyFrames.Add(k3_4); dauScaleX.KeyFrames.Add(k3_5); dauScaleX.KeyFrames.Add(k3_6); dauScaleX.KeyFrames.Add(k3_7); dauScaleX.KeyFrames.Add(k3_8); dauScaleX.KeyFrames.Add(k3_9); Story.Children.Add(dauScaleX); dauScaleY.KeyFrames.Add(k4); dauScaleY.KeyFrames.Add(k4_1); dauScaleY.KeyFrames.Add(k4_2); dauScaleY.KeyFrames.Add(k4_3); dauScaleY.KeyFrames.Add(k4_4); dauScaleY.KeyFrames.Add(k4_5); dauScaleY.KeyFrames.Add(k4_6); dauScaleY.KeyFrames.Add(k4_7); dauScaleY.KeyFrames.Add(k4_8); dauScaleY.KeyFrames.Add(k4_9); Story.Children.Add(dauScaleY); Story.Completed -= Story_Completed; Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); ScaleTransform translation = new ScaleTransform(0, 0); dauX = new DoubleAnimationUsingKeyFrames(); dauY = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new ScaleTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as ScaleTransform; if (translation != null) { break; } } if (translation != null) { var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); } } else { translation = new ScaleTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion Win.RegisterResource(Story); Story = (Storyboard)Story.CloneCurrentValue(); double danqianX = translation.ScaleX; double danqianY = translation.ScaleY; var k2 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(0)); var k3 = new EasingDoubleKeyFrame(1.1, TimeSpan.FromMilliseconds(300)); var k3_1 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(350)); //var k3_1 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(0.7))); Storyboard.SetTargetName(dauX, Win.GetName(translation)); Storyboard.SetTargetProperty(dauX, new PropertyPath(ScaleTransform.ScaleXProperty)); dauX.KeyFrames.Add(k2); dauX.KeyFrames.Add(k3); dauX.KeyFrames.Add(k3_1); Story.Children.Add(dauX); var k4 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(0)); var k5 = new EasingDoubleKeyFrame(1.1, TimeSpan.FromMilliseconds(300)); var k5_1 = new EasingDoubleKeyFrame(1.0, TimeSpan.FromMilliseconds(350)); if (EasingFunction != null) { k3.EasingFunction = EasingFunction; k5.EasingFunction = EasingFunction; } Storyboard.SetTargetName(dauY, Win.GetName(translation)); Storyboard.SetTargetProperty(dauY, new PropertyPath(ScaleTransform.ScaleYProperty)); dauY.KeyFrames.Add(k4); dauY.KeyFrames.Add(k5); dauY.KeyFrames.Add(k5_1); Story.Children.Add(dauY); if (OpacityNeed) { dauOpacty = new DoubleAnimationUsingKeyFrames(); var k6 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(0)); var k6_1 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(350)); if (EasingFunction != null) { k6_1.EasingFunction = EasingFunction; } dauOpacty.KeyFrames.Add(k6); dauOpacty.KeyFrames.Add(k6_1); Storyboard.SetTarget(dauOpacty, Element); dauOpacty.FillBehavior = FillBehavior.Stop; Storyboard.SetTargetProperty(dauOpacty, new PropertyPath(UIElement.OpacityProperty)); Story.Children.Add(dauOpacty); } Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); SkewTransform translation = new SkewTransform(0, 0); dauX = new DoubleAnimationUsingKeyFrames(); dauY = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new SkewTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as SkewTransform; if (translation != null) { break; } } if (translation != null) { var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); } } else { translation = new SkewTransform(0, 0); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion Win.RegisterResource(Story); double danqianX = translation.AngleX; double danqianY = translation.AngleY; var k2 = new EasingDoubleKeyFrame(danqianX - 12.5, TimeSpan.FromMilliseconds(AniTime(0.222))); var k2_0 = new EasingDoubleKeyFrame(danqianX + 6.25, TimeSpan.FromMilliseconds(AniTime(0.333))); var k2_1 = new EasingDoubleKeyFrame(danqianX - 3.125, TimeSpan.FromMilliseconds(AniTime(0.444))); var k2_2 = new EasingDoubleKeyFrame(danqianX + 1.5625, TimeSpan.FromMilliseconds(AniTime(0.555))); var k2_3 = new EasingDoubleKeyFrame(danqianX - 0.78125, TimeSpan.FromMilliseconds(AniTime(0.666))); var k2_4 = new EasingDoubleKeyFrame(danqianX + 0.390625, TimeSpan.FromMilliseconds(AniTime(0.777))); var k2_5 = new EasingDoubleKeyFrame(danqianX - 0.1953125, TimeSpan.FromMilliseconds(AniTime(0.888))); var k2_6 = new EasingDoubleKeyFrame(danqianX, TimeSpan.FromMilliseconds(AniTime(1))); var k3 = new EasingDoubleKeyFrame(danqianY - 12.5, TimeSpan.FromMilliseconds(AniTime(0.222))); var k3_0 = new EasingDoubleKeyFrame(danqianY + 6.25, TimeSpan.FromMilliseconds(AniTime(0.333))); var k3_1 = new EasingDoubleKeyFrame(danqianY - 3.125, TimeSpan.FromMilliseconds(AniTime(0.444))); var k3_2 = new EasingDoubleKeyFrame(danqianY + 1.5625, TimeSpan.FromMilliseconds(AniTime(0.555))); var k3_3 = new EasingDoubleKeyFrame(danqianY - 0.78125, TimeSpan.FromMilliseconds(AniTime(0.666))); var k3_4 = new EasingDoubleKeyFrame(danqianY + 0.390625, TimeSpan.FromMilliseconds(AniTime(0.777))); var k3_5 = new EasingDoubleKeyFrame(danqianY - 0.1953125, TimeSpan.FromMilliseconds(AniTime(0.888))); var k3_6 = new EasingDoubleKeyFrame(danqianY, TimeSpan.FromMilliseconds(AniTime(1))); Storyboard.SetTargetName(dauX, Win.GetName(translation)); Storyboard.SetTargetProperty(dauX, new PropertyPath(SkewTransform.AngleXProperty)); dauX.KeyFrames.Add(k2); dauX.KeyFrames.Add(k2_0); dauX.KeyFrames.Add(k2_1); dauX.KeyFrames.Add(k2_2); dauX.KeyFrames.Add(k2_3); dauX.KeyFrames.Add(k2_4); dauX.KeyFrames.Add(k2_5); dauX.KeyFrames.Add(k2_6); Story = (Storyboard)Story.CloneCurrentValue(); Story.Children.Add(dauX); Storyboard.SetTargetName(dauY, Win.GetName(translation)); Storyboard.SetTargetProperty(dauY, new PropertyPath(SkewTransform.AngleYProperty)); dauY.KeyFrames.Add(k3); dauY.KeyFrames.Add(k3_0); dauY.KeyFrames.Add(k3_1); dauY.KeyFrames.Add(k3_2); dauY.KeyFrames.Add(k3_3); dauY.KeyFrames.Add(k3_4); dauY.KeyFrames.Add(k3_5); dauY.KeyFrames.Add(k3_6); Story.Children.Add(dauY); Story.Completed -= Story_Completed; Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); dauX = new DoubleAnimationUsingKeyFrames(); dauY = new DoubleAnimationUsingKeyFrames(); ScaleTransform translation = new ScaleTransform(1, 1); TranslateTransform translationTranslate = new TranslateTransform(0, 0); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new ScaleTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Win.RegisterName(translationTranslate.GetHashCode().ToString(), translationTranslate); tg.Children.Add(translationTranslate); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as ScaleTransform; if (translation != null) { break; } } foreach (var item in tg.Children) { translationTranslate = item as TranslateTransform; if (translationTranslate != null) { break; } } if (translation != null) { var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); } } else { translation = new ScaleTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } if (translationTranslate != null) { var tex = translationTranslate.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translationTranslate.GetHashCode().ToString(), translationTranslate); } } else { translationTranslate = new TranslateTransform(0, 0); Win.RegisterName(translationTranslate.GetHashCode().ToString(), translationTranslate); tg.Children.Add(translationTranslate); Element.RenderTransform = tg; } } #endregion Win.RegisterResource(Story); Story = (Storyboard)Story.CloneCurrentValue(); double danqianX = translation.ScaleX; double danqianY = translation.ScaleY; var keyspline = new KeySpline(0.55, 0.055, 0.675, 0.19); var keyspline2 = new KeySpline(0.175, 0.885, 0.320, 1); var k3_0 = new SplineDoubleKeyFrame(); k3_0.KeySpline = keyspline; k3_0.Value = 0.1; k3_0.KeyTime = TimeSpan.FromMilliseconds(0); var k3_1 = new SplineDoubleKeyFrame(); k3_1.KeySpline = keyspline2; k3_1.Value = 0.475; k3_1.KeyTime = TimeSpan.FromMilliseconds(AniTime(0.6)); var k3_2 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(AniTime(1))); Storyboard.SetTargetName(dauX, Win.GetName(translation)); Storyboard.SetTargetProperty(dauX, new PropertyPath(ScaleTransform.ScaleXProperty)); dauX.KeyFrames.Add(k3_0); dauX.KeyFrames.Add(k3_1); dauX.KeyFrames.Add(k3_2); Story.Children.Add(dauX); var k4_0 = new SplineDoubleKeyFrame(); k4_0.KeySpline = keyspline; k4_0.Value = 0.1; k4_0.KeyTime = TimeSpan.FromMilliseconds(0); var k4_1 = new SplineDoubleKeyFrame(); k4_1.KeySpline = keyspline2; k4_1.Value = 0.475; k4_1.KeyTime = TimeSpan.FromMilliseconds(AniTime(0.6)); var k4_2 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(AniTime(1))); Storyboard.SetTargetName(dauY, Win.GetName(translation)); Storyboard.SetTargetProperty(dauY, new PropertyPath(ScaleTransform.ScaleYProperty)); dauY.KeyFrames.Add(k4_0); dauY.KeyFrames.Add(k4_1); dauY.KeyFrames.Add(k4_2); Story.Children.Add(dauY); dauTranslateY = new DoubleAnimationUsingKeyFrames(); var k5_0 = new SplineDoubleKeyFrame(); k5_0.KeySpline = keyspline; k5_0.Value = -1000; k5_0.KeyTime = TimeSpan.FromMilliseconds(0); var k5_1 = new SplineDoubleKeyFrame(); k5_1.KeySpline = keyspline2; k5_1.Value = 60; k5_1.KeyTime = TimeSpan.FromMilliseconds(AniTime(0.6)); var k5_2 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(1))); Storyboard.SetTargetName(dauTranslateY, Win.GetName(translationTranslate)); Storyboard.SetTargetProperty(dauTranslateY, new PropertyPath(TranslateTransform.YProperty)); dauTranslateY.KeyFrames.Add(k5_0); dauTranslateY.KeyFrames.Add(k5_1); dauTranslateY.KeyFrames.Add(k5_2); Story.Children.Add(dauTranslateY); dauOpacty = new DoubleAnimationUsingKeyFrames(); var k6 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(0))); var k6_1 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(AniTime(0.6))); dauOpacty.KeyFrames.Add(k6); dauOpacty.KeyFrames.Add(k6_1); Storyboard.SetTarget(dauOpacty, Element); dauOpacty.FillBehavior = FillBehavior.Stop; Storyboard.SetTargetProperty(dauOpacty, new PropertyPath(UIElement.OpacityProperty)); Story.Children.Add(dauOpacty); Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); RotateTransform translation = new RotateTransform(); TranslateTransform translationTranslate = new TranslateTransform(0, 0); dau = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new RotateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Win.RegisterName(translationTranslate); tg.Children.Add(translationTranslate); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as RotateTransform; if (translation != null) { break; } } foreach (var item in tg.Children) { translationTranslate = item as TranslateTransform; if (translationTranslate != null) { break; } } if (translation != null) { var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation); } } else { translation = new RotateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } if (translationTranslate != null) { var tex = translationTranslate.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translationTranslate); } } else { translationTranslate = new TranslateTransform(0, 0); Win.RegisterName(translationTranslate); tg.Children.Add(translationTranslate); Element.RenderTransform = tg; } } #endregion translation.CenterX = 0.5; translation.CenterY = 1; Story = (Storyboard)Story.Clone(); double angle = translation.Angle; var k2 = new EasingDoubleKeyFrame(angle - 5, TimeSpan.FromMilliseconds(AniTime(0.15))); var k2_1 = new EasingDoubleKeyFrame(angle + 3, TimeSpan.FromMilliseconds(AniTime(0.3))); var k2_2 = new EasingDoubleKeyFrame(angle - 3, TimeSpan.FromMilliseconds(AniTime(0.45))); var k2_3 = new EasingDoubleKeyFrame(angle + 2, TimeSpan.FromMilliseconds(AniTime(0.6))); var k2_4 = new EasingDoubleKeyFrame(angle - 1, TimeSpan.FromMilliseconds(AniTime(0.75))); var k2_9 = new EasingDoubleKeyFrame(angle, TimeSpan.FromMilliseconds(AnimateSpeed)); Storyboard.SetTargetName(dau, Win.GetName(translation)); Storyboard.SetTargetProperty(dau, new PropertyPath(RotateTransform.AngleProperty)); Win.RegisterResource(Story); dau.KeyFrames.Add(k2); dau.KeyFrames.Add(k2_1); dau.KeyFrames.Add(k2_2); dau.KeyFrames.Add(k2_3); dau.KeyFrames.Add(k2_4); dau.KeyFrames.Add(k2_9); Story.Children.Add(dau); dauTranslateX = new DoubleAnimationUsingKeyFrames(); double lateX = translationTranslate.X; double elementWidth = Element.RenderSize.Width; double s1 = lateX + (-0.25 * elementWidth); double s2 = lateX + (0.2 * elementWidth); double s3 = lateX + (-0.15 * elementWidth); double s4 = lateX + (0.1 * elementWidth); double s5 = lateX + (-0.05 * elementWidth); var k3 = new EasingDoubleKeyFrame(s1, TimeSpan.FromMilliseconds(AniTime(0.15))); var k3_1 = new EasingDoubleKeyFrame(s2, TimeSpan.FromMilliseconds(AniTime(0.3))); var k3_2 = new EasingDoubleKeyFrame(s3, TimeSpan.FromMilliseconds(AniTime(0.45))); var k3_3 = new EasingDoubleKeyFrame(s4, TimeSpan.FromMilliseconds(AniTime(0.6))); var k3_4 = new EasingDoubleKeyFrame(s5, TimeSpan.FromMilliseconds(AniTime(0.75))); var k3_9 = new EasingDoubleKeyFrame(lateX, TimeSpan.FromMilliseconds(AnimateSpeed)); Storyboard.SetTargetName(dauTranslateX, Win.GetName(translationTranslate)); Storyboard.SetTargetProperty(dauTranslateX, new PropertyPath(TranslateTransform.XProperty)); dauTranslateX.KeyFrames.Add(k3); dauTranslateX.KeyFrames.Add(k3_1); dauTranslateX.KeyFrames.Add(k3_2); dauTranslateX.KeyFrames.Add(k3_3); dauTranslateX.KeyFrames.Add(k3_4); dauTranslateX.KeyFrames.Add(k3_9); Story.Children.Add(dauTranslateX); Story.Completed -= Story_Completed; Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); RotateTransform translation = new RotateTransform(); dau = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new RotateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as RotateTransform; if (translation != null) { break; } } if (translation != null) { //当前Y值 var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation); } } else { translation = new RotateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion double angle = translation.Angle; //如果旋转角度和最终的是一致的就不执行下面代码 if (RotateAngleTo.HasValue && RotateAngleTo == angle) { return; } EasingDoubleKeyFrame k2 = null; if (RotateAngleAdd.HasValue) { k2 = new EasingDoubleKeyFrame(RotateAngleAdd.Value + angle, TimeSpan.FromMilliseconds(AniTime(1))); } else if (RotateAngleTo.HasValue) { k2 = new EasingDoubleKeyFrame(RotateAngleTo.Value, TimeSpan.FromMilliseconds(AniTime(1))); } if (!RotateAngleAdd.HasValue && !RotateAngleTo.HasValue) { k2 = new EasingDoubleKeyFrame(RotateAngleAdd.Value + 360, TimeSpan.FromMilliseconds(AniTime(1))); } if (EasingFunction != null) { k2.EasingFunction = EasingFunction; } Story = (Storyboard)Story.CloneCurrentValue(); Win.RegisterResource(Story); Storyboard.SetTargetName(dau, Win.GetName(translation)); Storyboard.SetTargetProperty(dau, new PropertyPath(RotateTransform.AngleProperty)); if (AniRepeatBehavior.HasValue) { Story.RepeatBehavior = AniRepeatBehavior.Value; } if (AniAutoReverse.HasValue) { Story.AutoReverse = AniAutoReverse.Value; } Story = (Storyboard)Story.CloneCurrentValue(); dau.KeyFrames.Add(k2); Story.Children.Add(dau); Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); RotateTransform translation = new RotateTransform(); dau = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new RotateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as RotateTransform; if (translation != null) { break; } } if (translation != null) { //当前Y值 var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation); } } else { translation = new RotateTransform(); Win.RegisterName(translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion double angle = translation.Angle; var k2 = new EasingDoubleKeyFrame(angle + 15, TimeSpan.FromMilliseconds(AniTime(0.2))); var k2_1 = new EasingDoubleKeyFrame(angle - 10, TimeSpan.FromMilliseconds(AniTime(0.4))); var k2_2 = new EasingDoubleKeyFrame(angle + 5, TimeSpan.FromMilliseconds(AniTime(0.6))); var k2_3 = new EasingDoubleKeyFrame(angle - 5, TimeSpan.FromMilliseconds(AniTime(0.8))); var k2_4 = new EasingDoubleKeyFrame(angle, TimeSpan.FromMilliseconds(AniTime(1))); Story = (Storyboard)Story.Clone(); Storyboard.SetTargetName(dau, Win.GetName(translation)); Storyboard.SetTargetProperty(dau, new PropertyPath(RotateTransform.AngleProperty)); Win.RegisterResource(Story); dau.KeyFrames.Add(k2); dau.KeyFrames.Add(k2_1); dau.KeyFrames.Add(k2_2); dau.KeyFrames.Add(k2_3); dau.KeyFrames.Add(k2_4); Story.Children.Add(dau); Story.Completed -= Story_Completed; Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); ScaleTransform translation = new ScaleTransform(1, 1); dauX = new DoubleAnimationUsingKeyFrames(); dauY = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new ScaleTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as ScaleTransform; if (translation != null) { break; } } if (translation != null) { var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); } } else { translation = new ScaleTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } Win.RegisterResource(Story); double danqianX = translation.ScaleX; double danqianY = translation.ScaleY; #endregion Story = (Storyboard)Story.Clone(); //var k1 = new EasingDoubleKeyFrame(danqianX, TimeSpan.FromMilliseconds(0)); var k2 = new EasingDoubleKeyFrame(danqianX + 0.3, TimeSpan.FromMilliseconds(AniTime(0.3))); var k3 = new EasingDoubleKeyFrame(danqianX, TimeSpan.FromMilliseconds(AniTime(1)), new ElasticEase { EasingMode = EasingMode.EaseOut, Oscillations = this.Oscillations }); Storyboard.SetTargetName(dauX, Win.GetName(translation)); Storyboard.SetTargetProperty(dauX, new PropertyPath(ScaleTransform.ScaleXProperty)); dauX.KeyFrames.Add(k2); dauX.KeyFrames.Add(k3); Story.Children.Add(dauX); var k0 = new EasingDoubleKeyFrame(danqianY - 0.2, TimeSpan.FromMilliseconds(0)); var k4 = new EasingDoubleKeyFrame(danqianY - 0.2, TimeSpan.FromMilliseconds(AniTime(0.4))); var k5 = new EasingDoubleKeyFrame(danqianY, TimeSpan.FromMilliseconds(AniTime(1)), new ElasticEase { EasingMode = EasingMode.EaseOut, Oscillations = this.Oscillations }); Storyboard.SetTargetName(dauY, Win.GetName(translation)); Storyboard.SetTargetProperty(dauY, new PropertyPath(ScaleTransform.ScaleYProperty)); dauY.KeyFrames.Add(k0); dauY.KeyFrames.Add(k4); dauY.KeyFrames.Add(k5); Story.Children.Add(dauY); Story.Completed -= Story_Completed; Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); ScaleTransform translation = new ScaleTransform(1, 1); dauX = new DoubleAnimationUsingKeyFrames(); dauY = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new ScaleTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as ScaleTransform; if (translation != null) { break; } } if (translation != null) { var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); } } else { translation = new ScaleTransform(1, 1); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion Win.RegisterResource(Story); double danqianX = translation.ScaleX; double danqianY = translation.ScaleY; Story = (Storyboard)Story.CloneCurrentValue(); //var k1 = new EasingDoubleKeyFrame(danqianY, TimeSpan.FromMilliseconds(0)); var k2 = new EasingDoubleKeyFrame(danqianX + ScaleXDiff, TimeSpan.FromMilliseconds(AniTime(0.6)), new ExponentialEase { EasingMode = EasingMode.EaseOut }); var k3 = new EasingDoubleKeyFrame(danqianX, TimeSpan.FromMilliseconds(AniTime(1))); Storyboard.SetTargetName(dauX, Win.GetName(translation)); Storyboard.SetTargetProperty(dauX, new PropertyPath(ScaleTransform.ScaleXProperty)); dauX.KeyFrames.Add(k2); dauX.KeyFrames.Add(k3); Story.Children.Add(dauX); var k4 = new EasingDoubleKeyFrame(danqianY + ScaleYDiff, TimeSpan.FromMilliseconds(AniTime(0.6)), new ExponentialEase { EasingMode = EasingMode.EaseOut }); var k5 = new EasingDoubleKeyFrame(danqianY, TimeSpan.FromMilliseconds(AniTime(1))); Storyboard.SetTargetName(dauY, Win.GetName(translation)); Storyboard.SetTargetProperty(dauY, new PropertyPath(ScaleTransform.ScaleYProperty)); dauY.KeyFrames.Add(k4); dauY.KeyFrames.Add(k5); Story.Children.Add(dauY); //<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="textBlock"> // <EasingDoubleKeyFrame KeyTime="0" Value="1"/> // <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1.14"> // <EasingDoubleKeyFrame.EasingFunction> // <ExponentialEase EasingMode="EaseOut"/> // </EasingDoubleKeyFrame.EasingFunction> // </EasingDoubleKeyFrame> // <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="1"/> //</DoubleAnimationUsingKeyFrames> //<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="textBlock"> // <EasingDoubleKeyFrame KeyTime="0" Value="1"/> // <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1.08"> // <EasingDoubleKeyFrame.EasingFunction> // <ExponentialEase EasingMode="EaseOut"/> // </EasingDoubleKeyFrame.EasingFunction> // </EasingDoubleKeyFrame> // <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="1"/> //</DoubleAnimationUsingKeyFrames> Story.Completed -= Story_Completed; Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); RotateTransform translation = new RotateTransform(); TranslateTransform translationTranslate = new TranslateTransform(0, 0); dau = new DoubleAnimationUsingKeyFrames(); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new RotateTransform(); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Win.RegisterName(translationTranslate.GetHashCode().ToString(), translationTranslate); tg.Children.Add(translationTranslate); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as RotateTransform; if (translation != null) { break; } } foreach (var item in tg.Children) { translationTranslate = item as TranslateTransform; if (translationTranslate != null) { break; } } if (translation != null) { var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); } } else { translation = new RotateTransform(); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } if (translationTranslate != null) { var tex = translationTranslate.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translationTranslate); } } else { translationTranslate = new TranslateTransform(0, 0); Win.RegisterName(translationTranslate); tg.Children.Add(translationTranslate); Element.RenderTransform = tg; } } #endregion Story = (Storyboard)Story.CloneCurrentValue(); var k2 = new EasingDoubleKeyFrame(80, TimeSpan.FromMilliseconds(AniTime(0.2))); var k2_2 = new EasingDoubleKeyFrame(40, TimeSpan.FromMilliseconds(AniTime(0.4))); var k2_1 = new EasingDoubleKeyFrame(75, TimeSpan.FromMilliseconds(AniTime(0.6))); var k2_3 = new EasingDoubleKeyFrame(60, TimeSpan.FromMilliseconds(AniTime(0.8))); var k2_4 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(1)), new CircleEase() { EasingMode = EasingMode.EaseOut }); Storyboard.SetTargetName(dau, Win.GetName(translation)); Storyboard.SetTargetProperty(dau, new PropertyPath(RotateTransform.AngleProperty)); dau.FillBehavior = FillBehavior.Stop; Win.RegisterResource(Story); dau.KeyFrames.Add(k2); dau.KeyFrames.Add(k2_1); dau.KeyFrames.Add(k2_2); dau.KeyFrames.Add(k2_3); dau.KeyFrames.Add(k2_4); Story.Children.Add(dau); dauTranslateY = new DoubleAnimationUsingKeyFrames(); var k3 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(0.8))); var k3_1 = new EasingDoubleKeyFrame(700, TimeSpan.FromMilliseconds(AniTime(1))); Storyboard.SetTargetName(dauTranslateY, Win.GetName(translationTranslate)); Storyboard.SetTargetProperty(dauTranslateY, new PropertyPath(TranslateTransform.YProperty)); dauTranslateY.KeyFrames.Add(k3); dauTranslateY.KeyFrames.Add(k3_1); Story.Children.Add(dauTranslateY); dauTranslateY.FillBehavior = FillBehavior.Stop; dauOpacty = new DoubleAnimationUsingKeyFrames(); var k4 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(AniTime(0.8))); var k4_0 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(1))); dauOpacty.KeyFrames.Add(k4); dauOpacty.KeyFrames.Add(k4_0); Storyboard.SetTarget(dauOpacty, Element); dauOpacty.FillBehavior = FillBehavior.Stop; Storyboard.SetTargetProperty(dauOpacty, new PropertyPath(UIElement.OpacityProperty)); Story.Children.Add(dauOpacty); //PointAnimationUsingKeyFrames porender = new PointAnimationUsingKeyFrames(); //var k5 = new EasingPointKeyFrame(new Point(0, 0), TimeSpan.FromMilliseconds(0)); //var k5_0 = new EasingPointKeyFrame(new Point(0, 0), TimeSpan.FromMilliseconds(AniTime(0.8))); ////var k5_1 = new EasingPointKeyFrame(new Point(0.4, 0.9), TimeSpan.FromMilliseconds(AniTime(0.8001))); //porender.KeyFrames.Add(k5); //porender.KeyFrames.Add(k5_0); ////porender.KeyFrames.Add(k5_1); //Storyboard.SetTarget(porender, Element); //dauOpacty.FillBehavior = FillBehavior.Stop; //Storyboard.SetTargetProperty(porender, new PropertyPath(UIElement.RenderTransformOriginProperty)); //story.Children.Add(porender); Story.Completed += Story_Completed; }
protected override void Init() { SetBaseView(); dau = new DoubleAnimationUsingKeyFrames(); TranslateTransform translation = new TranslateTransform(0, 0); #region 基本工作,确定类型和name //是否存在TranslateTransform //动画要的类型是否存在 //动画要的类型的name是否存在,不存在就注册,结束后取消注册,删除动画 var ex = Element.RenderTransform; if (ex == null || (ex as System.Windows.Media.MatrixTransform) != null) { var tg = new TransformGroup(); translation = new TranslateTransform(0, 0); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } else { var tg = ex as TransformGroup; foreach (var item in tg.Children) { translation = item as TranslateTransform; if (translation != null) { break; } } if (translation != null) { //当前Y值 var tex = translation.GetValue(FrameworkElement.NameProperty); if (tex != null && tex.ToString() != "") { } else { Win.RegisterName(translation.GetHashCode().ToString(), translation); } } else { translation = new TranslateTransform(0, 0); Win.RegisterName(translation.GetHashCode().ToString(), translation); tg.Children.Add(translation); Element.RenderTransform = tg; } } #endregion double danqianY = translation.Y; var k2 = new EasingDoubleKeyFrame((danqianY - UpHeight), TimeSpan.FromMilliseconds(AniTime(0.2)), new PowerEase { EasingMode = EasingMode.EaseOut }); var k3 = new EasingDoubleKeyFrame(danqianY, TimeSpan.FromMilliseconds(AniTime(1)), new BounceEase { EasingMode = EasingMode.EaseOut, Bounces = this.Bounces, Bounciness = this.Bounciness }); //dau = new DoubleAnimationUsingKeyFrames {KeyFrames=new DoubleKeyFrameCollection { k2,k3} }; dau.KeyFrames.Add(k2); dau.KeyFrames.Add(k3); Storyboard.SetTargetName(dau, Win.GetName(translation)); Storyboard.SetTargetProperty(dau, new PropertyPath(TranslateTransform.YProperty)); Story = (Storyboard)Story.CloneCurrentValue(); Story.Children.Add(dau); //Story.Animate = this; Win.RegisterResource(Story); Story.Completed -= Story_Completed; Story.Completed += Story_Completed; }