Exemple #1
0
        private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var mouseon = e.OriginalSource as FrameworkElement;

            this.element = mouseon as UIElement;
            if (this.CanElementMove(this.element))
            {
                this.CreatePositionBackup(this.element);
                if (this.eng.ValidatePlay(element))
                {
                    this.moveAnimY.From     = Canvas.GetTop(element);
                    this.moveAnimY.To       = Canvas.GetTop(this.played);
                    this.moveAnimY.Duration = new Duration(TimeSpan.FromMilliseconds(100));

                    this.moveAnimX.From     = Canvas.GetLeft(element);
                    this.moveAnimX.To       = Canvas.GetLeft(this.played);
                    this.moveAnimX.Duration = new Duration(TimeSpan.FromMilliseconds(100));

                    this.moveAnimX.FillBehavior = FillBehavior.Stop;
                    this.moveAnimY.FillBehavior = FillBehavior.Stop;

                    this.element.BeginAnimation(Canvas.TopProperty, this.moveAnimY);
                    this.element.BeginAnimation(Canvas.LeftProperty, this.moveAnimX);

                    Canvas.SetLeft(this.element, Canvas.GetLeft(this.played));
                    Canvas.SetTop(this.element, Canvas.GetTop(this.played));

                    if (next != null) //Cambiarra :(
                    {
                        Thread.Sleep(100);
                        this.next.Visibility = Visibility.Collapsed;
                    }
                    if (eng.GetCurrentPlayer().Hand.Count == 0)
                    {
                        MessageBox.Show("VOCÊ GANHOU!!");
                    }
                }
                else
                {
                    this.BackCardToHand(element);
                }
            }
        }