Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void AnimateItemEnd(SwipeViewItem container, ItemAnimationType typeAnim)
- {
- Storyboard storyboard = new Storyboard();
- FrameworkElement item;
- FrameworkElement frameworkElement;
- Func<UIElement, bool> func = null;
- lock (this)
- {
- try
- {
- //IEnumerable<UIElement> uIElements = Container.Children.Reverse<UIElement>();
- //if (func == null)
- //{
- // func = new Func<UIElement, bool>(variable, (UIElement c) => c != this.currentDiapo);
- //}
- //foreach (UIElement list in uIElements.TakeWhile<UIElement>(func).ToList<UIElement>())
- //{
- // this.StackDiapos.Children.Remove(list);
- // if (!(list is TinderDiapo))
- // {
- // continue;
- // }
- // ((TinderDiapo)list).ClearResources();
- //}
- CompositeTransform renderTransform = (CompositeTransform)container.RenderTransform;
- Storyboard storyboard1 = new Storyboard();
- double num = 0;
- double translateY = 0;
- double rotation = 0;
- double duration = 340;
- IEasingFunction backEase = null;
- double num2 = 1;
- double num3 = 2;
- if (typeAnim == ItemAnimationType.BackToDesk)
- {
- duration = 500;
- container.BackToDesk();
- backEase = new BackEase()
- {
- Amplitude = 0.4
- };
- }
- else
- {
- backEase = new ExponentialEase();
- num = (double)((typeAnim == ItemAnimationType.LeftToRight || typeAnim == ItemAnimationType.ForceLeftToRight ? 540 : -540));
- num2 = 0;
- num3 = 1;
- storyboard1.Completed += new EventHandler((object senderr, EventArgs err) =>
- {
- try
- {
- Stack.Children.Remove(container);
- AddManipulationToFirstItem();
- }
- catch { }
- });
- if (typeAnim == ItemAnimationType.ForceLeftToRight || typeAnim == ItemAnimationType.ForceRightToLeft)
- {
- duration = 300;
- translateY = 100;
- container.RenderTransformOrigin = new Point(0.5, 0.5);
- container.Swiping(typeAnim == ItemAnimationType.ForceLeftToRight ? FlowDirection.RightToLeft : FlowDirection.LeftToRight, 1);
- rotation = (double)((typeAnim == ItemAnimationType.ForceLeftToRight ? 40 : -40));
- }
- else
- {
- rotation = renderTransform.Rotation * 1.3;
- translateY = renderTransform.TranslateY * 1.3;
- }
- }
- try
- {
- DoubleAnimation doubleAnimation3 = new DoubleAnimation()
- {
- To = new double?(translateY),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = backEase
- };
- DoubleAnimation doubleAnimation4 = doubleAnimation3;
- Storyboard.SetTargetProperty(doubleAnimation4, new PropertyPath(CompositeTransform.TranslateYProperty));
- Storyboard.SetTarget(doubleAnimation4, renderTransform);
- storyboard1.Children.Add(doubleAnimation4);
- DoubleAnimation doubleAnimation5 = new DoubleAnimation()
- {
- To = new double?(num),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = backEase
- };
- DoubleAnimation doubleAnimation6 = doubleAnimation5;
- Storyboard.SetTargetProperty(doubleAnimation6, new PropertyPath(CompositeTransform.TranslateXProperty));
- Storyboard.SetTarget(doubleAnimation6, renderTransform);
- storyboard1.Children.Add(doubleAnimation6);
- DoubleAnimation doubleAnimation7 = new DoubleAnimation()
- {
- To = new double?(rotation),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = new CircleEase()
- };
- DoubleAnimation doubleAnimation8 = doubleAnimation7;
- Storyboard.SetTargetProperty(doubleAnimation8, new PropertyPath(CompositeTransform.RotationProperty));
- Storyboard.SetTarget(doubleAnimation8, renderTransform);
- storyboard1.Children.Add(doubleAnimation8);
- }
- catch { }
- if (typeAnim != ItemAnimationType.LeftToRight && typeAnim != ItemAnimationType.RightToLeft)
- {
- int count = Stack.Children.Count;
- if (count - 2 >= 0)
- {
- item = (FrameworkElement)Stack.Children[count - 2];
- }
- else
- {
- item = null;
- }
- FrameworkElement frameworkElement1 = item;
- try
- {
- if (frameworkElement1 != null)
- {
- double num4 = 0.06 * num2;
- double num5 = num2 * 12 + 260.5 * num4;
- CompositeTransform compositeTransform = (CompositeTransform)frameworkElement1.RenderTransform;
- DoubleAnimation doubleAnimation9 = new DoubleAnimation()
- {
- To = new double?(-num5),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = new CircleEase()
- };
- DoubleAnimation doubleAnimation10 = doubleAnimation9;
- Storyboard.SetTargetProperty(doubleAnimation10, new PropertyPath(CompositeTransform.TranslateYProperty));
- Storyboard.SetTarget(doubleAnimation10, compositeTransform);
- storyboard.Children.Add(doubleAnimation10);
- DoubleAnimation doubleAnimation11 = new DoubleAnimation()
- {
- To = new double?(1 - num4),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = new CircleEase()
- };
- DoubleAnimation doubleAnimation12 = doubleAnimation11;
- Storyboard.SetTargetProperty(doubleAnimation12, new PropertyPath(CompositeTransform.ScaleXProperty));
- Storyboard.SetTarget(doubleAnimation12, compositeTransform);
- storyboard.Children.Add(doubleAnimation12);
- DoubleAnimation doubleAnimation13 = new DoubleAnimation()
- {
- To = new double?(1 - num4),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = new CircleEase()
- };
- doubleAnimation12 = doubleAnimation13;
- Storyboard.SetTargetProperty(doubleAnimation12, new PropertyPath(CompositeTransform.ScaleYProperty));
- Storyboard.SetTarget(doubleAnimation12, compositeTransform);
- storyboard.Children.Add(doubleAnimation12);
- }
- }
- catch { }
- try
- {
- if (count - 3 >= 0)
- {
- frameworkElement = (FrameworkElement)Stack.Children[count - 3];
- }
- else
- {
- frameworkElement = null;
- }
- FrameworkElement frameworkElement2 = frameworkElement;
- if (frameworkElement2 != null)
- {
- double num6 = 0.06 * num3;
- double num7 = num3 * 12 + 260.5 * num6;
- CompositeTransform renderTransform1 = (CompositeTransform)frameworkElement2.RenderTransform;
- DoubleAnimation doubleAnimation14 = new DoubleAnimation()
- {
- To = new double?(-num7),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = new CircleEase()
- };
- DoubleAnimation doubleAnimation15 = doubleAnimation14;
- Storyboard.SetTargetProperty(doubleAnimation15, new PropertyPath(CompositeTransform.TranslateYProperty));
- Storyboard.SetTarget(doubleAnimation15, renderTransform1);
- storyboard.Children.Add(doubleAnimation15);
- DoubleAnimation doubleAnimation16 = new DoubleAnimation()
- {
- To = new double?(1 - num6),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = new CircleEase()
- };
- DoubleAnimation doubleAnimation17 = doubleAnimation16;
- Storyboard.SetTargetProperty(doubleAnimation17, new PropertyPath(CompositeTransform.ScaleXProperty));
- Storyboard.SetTarget(doubleAnimation17, renderTransform1);
- storyboard.Children.Add(doubleAnimation17);
- DoubleAnimation doubleAnimation18 = new DoubleAnimation()
- {
- To = new double?(1 - num6),
- Duration = TimeSpan.FromMilliseconds(duration),
- EasingFunction = new CircleEase()
- };
- doubleAnimation17 = doubleAnimation18;
- Storyboard.SetTargetProperty(doubleAnimation17, new PropertyPath(CompositeTransform.ScaleYProperty));
- Storyboard.SetTarget(doubleAnimation17, renderTransform1);
- storyboard.Children.Add(doubleAnimation17);
- }
- }
- catch { }
- }
- storyboard1.Begin();
- if (storyboard != storyboard1)
- {
- try
- {
- storyboard.Begin();
- }
- catch { }
- }
- }
- catch { }
- //if (typeAnim != TypeAnimDiapo.BACKTODESK)
- //{
- // ((MainViewModel)base.DataContext).RemoveProposition((Person)currentDiapo.DataContext);
- //}
- if (typeAnim != ItemAnimationType.BackToDesk)
- {
- ItemsSource.Remove(container.DataContext);
- OnItemSwiped(container.DataContext, (typeAnim == ItemAnimationType.ForceLeftToRight || typeAnim == ItemAnimationType.LeftToRight)
- ? System.Windows.FlowDirection.LeftToRight
- : System.Windows.FlowDirection.RightToLeft);
- }
- //GC.Collect();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement