Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. public void Intercanvi(ref int primer, ref int segon, int a, int b)
  2. {
  3. int temp;
  4. DoEvents();
  5. temp = primer;
  6. primer = segon;
  7. segon = temp;
  8. rectangles[a].Fill = canvi;
  9. rectangles[b].Fill = canvi;
  10. DoAnimacio(a, b);
  11. Espera(Convert.ToInt32(iudPausa.Value));
  12. if (cmbPuntsBarres.SelectedIndex == 0)
  13. {
  14. double heightA = rectangles[a].Height;
  15. rectangles[a].Height = rectangles[b].Height;
  16. rectangles[b].Height = heightA;
  17. }
  18. else
  19. {
  20. double bottom = Canvas.GetBottom(rectangles[a]);
  21. Canvas.SetBottom(rectangles[a], Canvas.GetBottom(rectangles[b]));
  22. Canvas.SetBottom(rectangles[b], bottom);
  23. }
  24. ComprobarFigura(a, primer);
  25. ComprobarFigura(b, segon);
  26. }
  27.  
  28. private void DoAnimacio(int a, int b)
  29. {
  30. DoubleAnimation animacio = new DoubleAnimation();
  31. //ElasticEase ease = new ElasticEase();
  32. //ease.EasingMode = EasingMode.EaseOut;
  33. //animacio.EasingFunction = ease;
  34. animacio.Duration = TimeSpan.FromMilliseconds((double)iudPausa.Value);
  35. PutEasing(ref animacio);
  36. switch (cmbTipusAnimacio.SelectedIndex)
  37. {
  38. case 0:
  39. if (cmbPuntsBarres.SelectedIndex == 0)
  40. {
  41. animacio.From = rectangles[a].Height;
  42. animacio.To = rectangles[b].Height;
  43. rectangles[a].BeginAnimation(Shape.HeightProperty, animacio);
  44.  
  45. animacio.From = rectangles[b].Height;
  46. animacio.To = rectangles[a].Height;
  47. rectangles[b].BeginAnimation(Shape.HeightProperty, animacio);
  48. }
  49. else
  50. {
  51. animacio.From = Canvas.GetBottom(rectangles[a]);
  52. animacio.To = Canvas.GetBottom(rectangles[b]);
  53. rectangles[a].BeginAnimation(Canvas.BottomProperty, animacio);
  54.  
  55. animacio.From = Canvas.GetBottom(rectangles[b]);
  56. animacio.To = Canvas.GetBottom(rectangles[a]);
  57. rectangles[b].BeginAnimation(Canvas.BottomProperty, animacio);
  58. }
  59. break;
  60. case 1:
  61. Canvas.SetZIndex(rectangles[a], 1);
  62. Canvas.SetZIndex(rectangles[b], 1);
  63. animacio.FillBehavior = FillBehavior.Stop;
  64. animacio.From = Canvas.GetLeft(rectangles[a]);
  65. animacio.To = Canvas.GetLeft(rectangles[b]);
  66. rectangles[a].BeginAnimation(Canvas.LeftProperty, animacio);
  67.  
  68. animacio.From = Canvas.GetLeft(rectangles[b]);
  69. animacio.To = Canvas.GetLeft(rectangles[a]);
  70. rectangles[b].BeginAnimation(Canvas.LeftProperty, animacio);
  71. break;
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement