Advertisement
FrayxRulez

Untitled

Sep 2nd, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.16 KB | None | 0 0
  1. private void AnimateItemEnd(SwipeViewItem container, ItemAnimationType typeAnim)
  2. {
  3. Storyboard storyboard = new Storyboard();
  4. FrameworkElement item;
  5. FrameworkElement frameworkElement;
  6. Func<UIElement, bool> func = null;
  7. lock (this)
  8. {
  9. try
  10. {
  11. //IEnumerable<UIElement> uIElements = Container.Children.Reverse<UIElement>();
  12. //if (func == null)
  13. //{
  14. // func = new Func<UIElement, bool>(variable, (UIElement c) => c != this.currentDiapo);
  15. //}
  16. //foreach (UIElement list in uIElements.TakeWhile<UIElement>(func).ToList<UIElement>())
  17. //{
  18. // this.StackDiapos.Children.Remove(list);
  19. // if (!(list is TinderDiapo))
  20. // {
  21. // continue;
  22. // }
  23. // ((TinderDiapo)list).ClearResources();
  24. //}
  25. CompositeTransform renderTransform = (CompositeTransform)container.RenderTransform;
  26. Storyboard storyboard1 = new Storyboard();
  27.  
  28. double num = 0;
  29. double translateY = 0;
  30. double rotation = 0;
  31. double duration = 340;
  32. IEasingFunction backEase = null;
  33. double num2 = 1;
  34. double num3 = 2;
  35. if (typeAnim == ItemAnimationType.BackToDesk)
  36. {
  37. duration = 500;
  38. container.BackToDesk();
  39. backEase = new BackEase()
  40. {
  41. Amplitude = 0.4
  42. };
  43. }
  44. else
  45. {
  46. backEase = new ExponentialEase();
  47. num = (double)((typeAnim == ItemAnimationType.LeftToRight || typeAnim == ItemAnimationType.ForceLeftToRight ? 540 : -540));
  48. num2 = 0;
  49. num3 = 1;
  50. storyboard1.Completed += new EventHandler((object senderr, EventArgs err) =>
  51. {
  52. try
  53. {
  54. Stack.Children.Remove(container);
  55. AddManipulationToFirstItem();
  56. }
  57. catch { }
  58. });
  59. if (typeAnim == ItemAnimationType.ForceLeftToRight || typeAnim == ItemAnimationType.ForceRightToLeft)
  60. {
  61. duration = 300;
  62. translateY = 100;
  63. container.RenderTransformOrigin = new Point(0.5, 0.5);
  64. container.Swiping(typeAnim == ItemAnimationType.ForceLeftToRight ? FlowDirection.RightToLeft : FlowDirection.LeftToRight, 1);
  65. rotation = (double)((typeAnim == ItemAnimationType.ForceLeftToRight ? 40 : -40));
  66. }
  67. else
  68. {
  69. rotation = renderTransform.Rotation * 1.3;
  70. translateY = renderTransform.TranslateY * 1.3;
  71. }
  72. }
  73. try
  74. {
  75. DoubleAnimation doubleAnimation3 = new DoubleAnimation()
  76. {
  77. To = new double?(translateY),
  78. Duration = TimeSpan.FromMilliseconds(duration),
  79. EasingFunction = backEase
  80. };
  81. DoubleAnimation doubleAnimation4 = doubleAnimation3;
  82. Storyboard.SetTargetProperty(doubleAnimation4, new PropertyPath(CompositeTransform.TranslateYProperty));
  83. Storyboard.SetTarget(doubleAnimation4, renderTransform);
  84. storyboard1.Children.Add(doubleAnimation4);
  85. DoubleAnimation doubleAnimation5 = new DoubleAnimation()
  86. {
  87. To = new double?(num),
  88. Duration = TimeSpan.FromMilliseconds(duration),
  89. EasingFunction = backEase
  90. };
  91. DoubleAnimation doubleAnimation6 = doubleAnimation5;
  92. Storyboard.SetTargetProperty(doubleAnimation6, new PropertyPath(CompositeTransform.TranslateXProperty));
  93. Storyboard.SetTarget(doubleAnimation6, renderTransform);
  94. storyboard1.Children.Add(doubleAnimation6);
  95. DoubleAnimation doubleAnimation7 = new DoubleAnimation()
  96. {
  97. To = new double?(rotation),
  98. Duration = TimeSpan.FromMilliseconds(duration),
  99. EasingFunction = new CircleEase()
  100. };
  101. DoubleAnimation doubleAnimation8 = doubleAnimation7;
  102. Storyboard.SetTargetProperty(doubleAnimation8, new PropertyPath(CompositeTransform.RotationProperty));
  103. Storyboard.SetTarget(doubleAnimation8, renderTransform);
  104. storyboard1.Children.Add(doubleAnimation8);
  105. }
  106. catch { }
  107. if (typeAnim != ItemAnimationType.LeftToRight && typeAnim != ItemAnimationType.RightToLeft)
  108. {
  109. int count = Stack.Children.Count;
  110. if (count - 2 >= 0)
  111. {
  112. item = (FrameworkElement)Stack.Children[count - 2];
  113. }
  114. else
  115. {
  116. item = null;
  117. }
  118. FrameworkElement frameworkElement1 = item;
  119. try
  120. {
  121. if (frameworkElement1 != null)
  122. {
  123. double num4 = 0.06 * num2;
  124. double num5 = num2 * 12 + 260.5 * num4;
  125. CompositeTransform compositeTransform = (CompositeTransform)frameworkElement1.RenderTransform;
  126. DoubleAnimation doubleAnimation9 = new DoubleAnimation()
  127. {
  128. To = new double?(-num5),
  129. Duration = TimeSpan.FromMilliseconds(duration),
  130. EasingFunction = new CircleEase()
  131. };
  132. DoubleAnimation doubleAnimation10 = doubleAnimation9;
  133. Storyboard.SetTargetProperty(doubleAnimation10, new PropertyPath(CompositeTransform.TranslateYProperty));
  134. Storyboard.SetTarget(doubleAnimation10, compositeTransform);
  135. storyboard.Children.Add(doubleAnimation10);
  136. DoubleAnimation doubleAnimation11 = new DoubleAnimation()
  137. {
  138. To = new double?(1 - num4),
  139. Duration = TimeSpan.FromMilliseconds(duration),
  140. EasingFunction = new CircleEase()
  141. };
  142. DoubleAnimation doubleAnimation12 = doubleAnimation11;
  143. Storyboard.SetTargetProperty(doubleAnimation12, new PropertyPath(CompositeTransform.ScaleXProperty));
  144. Storyboard.SetTarget(doubleAnimation12, compositeTransform);
  145. storyboard.Children.Add(doubleAnimation12);
  146. DoubleAnimation doubleAnimation13 = new DoubleAnimation()
  147. {
  148. To = new double?(1 - num4),
  149. Duration = TimeSpan.FromMilliseconds(duration),
  150. EasingFunction = new CircleEase()
  151. };
  152. doubleAnimation12 = doubleAnimation13;
  153. Storyboard.SetTargetProperty(doubleAnimation12, new PropertyPath(CompositeTransform.ScaleYProperty));
  154. Storyboard.SetTarget(doubleAnimation12, compositeTransform);
  155. storyboard.Children.Add(doubleAnimation12);
  156. }
  157. }
  158. catch { }
  159. try
  160. {
  161. if (count - 3 >= 0)
  162. {
  163. frameworkElement = (FrameworkElement)Stack.Children[count - 3];
  164. }
  165. else
  166. {
  167. frameworkElement = null;
  168. }
  169. FrameworkElement frameworkElement2 = frameworkElement;
  170. if (frameworkElement2 != null)
  171. {
  172. double num6 = 0.06 * num3;
  173. double num7 = num3 * 12 + 260.5 * num6;
  174. CompositeTransform renderTransform1 = (CompositeTransform)frameworkElement2.RenderTransform;
  175. DoubleAnimation doubleAnimation14 = new DoubleAnimation()
  176. {
  177. To = new double?(-num7),
  178. Duration = TimeSpan.FromMilliseconds(duration),
  179. EasingFunction = new CircleEase()
  180. };
  181. DoubleAnimation doubleAnimation15 = doubleAnimation14;
  182. Storyboard.SetTargetProperty(doubleAnimation15, new PropertyPath(CompositeTransform.TranslateYProperty));
  183. Storyboard.SetTarget(doubleAnimation15, renderTransform1);
  184. storyboard.Children.Add(doubleAnimation15);
  185. DoubleAnimation doubleAnimation16 = new DoubleAnimation()
  186. {
  187. To = new double?(1 - num6),
  188. Duration = TimeSpan.FromMilliseconds(duration),
  189. EasingFunction = new CircleEase()
  190. };
  191. DoubleAnimation doubleAnimation17 = doubleAnimation16;
  192. Storyboard.SetTargetProperty(doubleAnimation17, new PropertyPath(CompositeTransform.ScaleXProperty));
  193. Storyboard.SetTarget(doubleAnimation17, renderTransform1);
  194. storyboard.Children.Add(doubleAnimation17);
  195. DoubleAnimation doubleAnimation18 = new DoubleAnimation()
  196. {
  197. To = new double?(1 - num6),
  198. Duration = TimeSpan.FromMilliseconds(duration),
  199. EasingFunction = new CircleEase()
  200. };
  201. doubleAnimation17 = doubleAnimation18;
  202. Storyboard.SetTargetProperty(doubleAnimation17, new PropertyPath(CompositeTransform.ScaleYProperty));
  203. Storyboard.SetTarget(doubleAnimation17, renderTransform1);
  204. storyboard.Children.Add(doubleAnimation17);
  205. }
  206. }
  207. catch { }
  208. }
  209. storyboard1.Begin();
  210. if (storyboard != storyboard1)
  211. {
  212. try
  213. {
  214. storyboard.Begin();
  215. }
  216. catch { }
  217. }
  218. }
  219. catch { }
  220. //if (typeAnim != TypeAnimDiapo.BACKTODESK)
  221. //{
  222. // ((MainViewModel)base.DataContext).RemoveProposition((Person)currentDiapo.DataContext);
  223. //}
  224.  
  225. if (typeAnim != ItemAnimationType.BackToDesk)
  226. {
  227. ItemsSource.Remove(container.DataContext);
  228. OnItemSwiped(container.DataContext, (typeAnim == ItemAnimationType.ForceLeftToRight || typeAnim == ItemAnimationType.LeftToRight)
  229. ? System.Windows.FlowDirection.LeftToRight
  230. : System.Windows.FlowDirection.RightToLeft);
  231. }
  232.  
  233. //GC.Collect();
  234. }
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement