예제 #1
0
 public GamesEndEventArgs(RoutedEvent routedEvent, object source, GameResult result)
     : base(routedEvent, source)
 {
     this.result = result;
 }
예제 #2
0
        protected virtual void OnGamesEnd(GameResult gameResult)
        {
            if (gameResult.GameStatus == GameStatus.Draw)
            {
                RaiseEvent(new GamesEndEventArgs(GamesEndEvent, this, gameResult));
                return;
            }
            var set = new HashSet <VerticeControl>();

            IsEnabled = false;
            var fgColor = Colors.Black;

            if (gameResult.Edges != null)
            {
                foreach (EdgeControl f in gameResult.Edges)
                {
                    var v1 = f.VerticeA as VerticeControl;
                    var v2 = f.VerticeB as VerticeControl;
                    set.Add(v1);
                    set.Add(v2);
                    fgColor       = (f.Foreground as SolidColorBrush).Color;
                    f.Highlighted = true;
                    Panel.SetZIndex(f, 85);
                }
            }
            var boomAnima = new Storyboard();

            foreach (var v in set)
            {
                v.Visibility = Visibility.Hidden;
                var nv = new VerticeControl(v.ID[0]);
                nv.Size       = v.Size;
                nv.Foreground = new SolidColorBrush(fgColor);
                nv.Background = v.Background;
                nv.CanvasLeft = v.CanvasLeft;
                nv.CanvasTop  = v.CanvasTop;
                Panel.SetZIndex(nv, 100);
                nv.InputState = InputState.Dragged;
                nv.IsEnabled  = false;
                canvas.Children.Add(nv);

                var ell = new Ellipse();
                ell.Stroke = new SolidColorBrush(fgColor);
                ell.Width  = 2;
                ell.Height = 2;
                ell.RenderTransformOrigin = new Point(0.5, 0.5);
                ell.RenderTransform       = new ScaleTransform();
                Canvas.SetLeft(ell, -1 + v.CanvasLeft);
                Canvas.SetTop(ell, -1 + v.CanvasTop);
                canvas.Children.Add(ell);
                var sx = new DoubleAnimation(200, Anima.ShortDuration);
                var sy = new DoubleAnimation(200, Anima.ShortDuration);
                var op = new DoubleAnimation(0, Anima.ShortDuration);
                sx.FillBehavior = FillBehavior.Stop;
                sy.FillBehavior = FillBehavior.Stop;
                //op.FillBehavior = FillBehavior.Stop;
                Storyboard.SetTarget(sx, ell);
                Storyboard.SetTarget(sy, ell);
                Storyboard.SetTarget(op, ell);
                Storyboard.SetTargetProperty(sx, new PropertyPath("RenderTransform.ScaleX"));
                Storyboard.SetTargetProperty(sy, new PropertyPath("RenderTransform.ScaleY"));
                Storyboard.SetTargetProperty(op, new PropertyPath("Opacity"));
                boomAnima.Children.Add(sy);
                boomAnima.Children.Add(sx);
                boomAnima.Children.Add(op);
            }
            boomAnima.Completed += (o, e) => RaiseEvent(new GamesEndEventArgs(GamesEndEvent, this, gameResult));
            boomAnima.Begin();
        }