예제 #1
0
        //sets up the tilegrid for use later on
        private void Init()
        {
            
            winFlag = 24;
            for (int row = 0; row < 4; row++)
            {
                for (int col = 0; col < 6; col++)
                {
                    Tile tile = new Tile();
                    tile.Rect = (Rectangle)FindName("r" + row + "" + col);
                    tile.Rect.Fill = new SolidColorBrush(Tile.FaceDownColor);
                    tileGrid[row, col] = tile;
                }
            }
            GoInstant();
            Randomize();            

        }
예제 #2
0
        private void Flip(Tile tile, Storyboard sb)
        {
            sb.Stop();
            animating = true;

            Storyboard.SetTargetName(sb, tile.Rect.Name);

            if (tile.Faceup)
            {
                //getting a color animation from a storyboard *could* be easier...
                sb.Children.OfType<ColorAnimation>().First().To = Tile.FaceDownColor;
            }
            else
            {
                sb.Children.OfType<ColorAnimation>().First().To = Tile.FaceUpColor;
            }
            //Override the stretch with an actual height to allow the storyboard to run
            tile.Rect.Height = tile.Rect.ActualHeight;
            tile.Rect.Width = tile.Rect.ActualWidth;
            sb.Begin();
        }