Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Intercanvi(ref int primer, ref int segon, int a, int b)
- {
- int temp;
- DoEvents();
- temp = primer;
- primer = segon;
- segon = temp;
- rectangles[a].Fill = canvi;
- rectangles[b].Fill = canvi;
- DoAnimacio(a, b);
- Espera(Convert.ToInt32(iudPausa.Value));
- if (cmbPuntsBarres.SelectedIndex == 0)
- {
- double heightA = rectangles[a].Height;
- rectangles[a].Height = rectangles[b].Height;
- rectangles[b].Height = heightA;
- }
- else
- {
- double bottom = Canvas.GetBottom(rectangles[a]);
- Canvas.SetBottom(rectangles[a], Canvas.GetBottom(rectangles[b]));
- Canvas.SetBottom(rectangles[b], bottom);
- }
- ComprobarFigura(a, primer);
- ComprobarFigura(b, segon);
- }
- private void DoAnimacio(int a, int b)
- {
- DoubleAnimation animacio = new DoubleAnimation();
- //ElasticEase ease = new ElasticEase();
- //ease.EasingMode = EasingMode.EaseOut;
- //animacio.EasingFunction = ease;
- animacio.Duration = TimeSpan.FromMilliseconds((double)iudPausa.Value);
- PutEasing(ref animacio);
- switch (cmbTipusAnimacio.SelectedIndex)
- {
- case 0:
- if (cmbPuntsBarres.SelectedIndex == 0)
- {
- animacio.From = rectangles[a].Height;
- animacio.To = rectangles[b].Height;
- rectangles[a].BeginAnimation(Shape.HeightProperty, animacio);
- animacio.From = rectangles[b].Height;
- animacio.To = rectangles[a].Height;
- rectangles[b].BeginAnimation(Shape.HeightProperty, animacio);
- }
- else
- {
- animacio.From = Canvas.GetBottom(rectangles[a]);
- animacio.To = Canvas.GetBottom(rectangles[b]);
- rectangles[a].BeginAnimation(Canvas.BottomProperty, animacio);
- animacio.From = Canvas.GetBottom(rectangles[b]);
- animacio.To = Canvas.GetBottom(rectangles[a]);
- rectangles[b].BeginAnimation(Canvas.BottomProperty, animacio);
- }
- break;
- case 1:
- Canvas.SetZIndex(rectangles[a], 1);
- Canvas.SetZIndex(rectangles[b], 1);
- animacio.FillBehavior = FillBehavior.Stop;
- animacio.From = Canvas.GetLeft(rectangles[a]);
- animacio.To = Canvas.GetLeft(rectangles[b]);
- rectangles[a].BeginAnimation(Canvas.LeftProperty, animacio);
- animacio.From = Canvas.GetLeft(rectangles[b]);
- animacio.To = Canvas.GetLeft(rectangles[a]);
- rectangles[b].BeginAnimation(Canvas.LeftProperty, animacio);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement