public MainWindow holderWin; // to change the size of main window public GameModeSelectionPage() { // layout InitializeComponent(); Grid aGrid = ButtonGrid1(holder); addChildrenGrid(holder, aGrid, 1); StringGrid s = new StringGrid("G", SquareGenerator.squareSize * 1.5); s.noAnimation(); aCanvas.Children.Add(s); s.SetValue(Canvas.RightProperty, 0.0); s.SetValue(Canvas.TopProperty, (WindowSizeGenerator.screenHeight - s.getHeight()) / 2); s.SetValue(Canvas.ZIndexProperty, 2); Pic.PicGen pic = new Pic.CatGen(); Pic.PicGenGrid pg = new Pic.PicGenGrid(pic, SquareGenerator.picSquareSize / 1.2); aCanvas.Children.Add(pg); pg.SetValue(Canvas.ZIndexProperty, 0); Canvas.SetRight(pg, 2); Canvas.SetBottom(pg, 2); }
public NavigationPage() { InitializeComponent(); int colorNum = 6; Color[] colors = SquareGenerator.randomColor(colorNum); CustomizedButton2 exitButton = new CustomizedButton2("退 出", colors[0]); exitButton.button.Click += exitGame_Click; exitButton.SetValue(Grid.RowProperty, 3); CustomizedButton2 startGameButton = new CustomizedButton2("开始游戏", colors[1]); startGameButton.button.Click += gotoGameModeSel_Click; startGameButton.SetValue(Grid.RowProperty, 0); CustomizedButton2 achievementButton = new CustomizedButton2("成就系统", colors[2]); achievementButton.button.Click += gotoAchievement_Click; achievementButton.SetValue(Grid.RowProperty, 1); CustomizedButton2 settingsButton = new CustomizedButton2("设 置", colors[3]); settingsButton.button.Click += gotoSetting_Click; settingsButton.SetValue(Grid.RowProperty, 2); ButtonsGrid.Children.Add(startGameButton); ButtonsGrid.Children.Add(achievementButton); ButtonsGrid.Children.Add(settingsButton); ButtonsGrid.Children.Add(exitButton); StringGrid title = new StringGrid("Tetris", SquareGenerator.squareSize / 1.1); outerGrid.Children.Add(title); title.SetValue(Grid.RowProperty, 1); title.SetValue(Grid.ColumnProperty, 1); title.noAnimation(); Pic.Cat2Gen pic = new Pic.Cat2Gen(); Pic.PicGenGrid pg = new Pic.PicGenGrid(pic, SquareGenerator.picSquareSize / 1.2); aCanvas.Children.Add(pg); pg.SetValue(Canvas.ZIndexProperty, 0); Canvas.SetRight(pg, 2); Canvas.SetBottom(pg, 2); }
// the starting animation(ready go) protected void startAnimation() { int timeStart = 10; int timeStep = 1000; int timeDelay = timeStep + 100; welcomeString1 = new StringGrid("READY", SquareGenerator.squareSize / 1.8); Canvas.SetLeft(welcomeString1, (Styles.WindowSizeGenerator.screenWidth - welcomeString1.getWidth()) / 2); Canvas.SetTop(welcomeString1, (outerGrid.Height - welcomeString1.getHeight()) / 2); Canvas.SetZIndex(welcomeString1, 10); aCanvas.Children.Add(welcomeString1); welcomeString1.startAnimation(timeStep, timeStart); Console.WriteLine(outerGrid.Width); Console.WriteLine(welcomeString1.getWidth()); Console.WriteLine((holderWin.Width - welcomeString1.getWidth()) / 2); welcomeString2 = new StringGrid("GO", SquareGenerator.squareSize); Canvas.SetLeft(welcomeString2, (Styles.WindowSizeGenerator.screenWidth - welcomeString2.getWidth()) / 2); Canvas.SetTop(welcomeString2, (holderWin.Height - welcomeString2.getHeight()) / 2); Canvas.SetZIndex(welcomeString2, 10); aCanvas.Children.Add(welcomeString2); welcomeString2.startAnimation(timeStep, timeDelay + timeStart); welcomeString2.story.Completed += whatHappenWhenAnimationStop; welcomeString1.beginAnimation(); welcomeString2.beginAnimation(); gameOver = new StringGrid("Game Over", SquareGenerator.squareSize / 2.5); aCanvas.Children.Add(gameOver); Canvas.SetLeft(gameOver, (Styles.WindowSizeGenerator.screenWidth - gameOver.getWidth()) / 2); Canvas.SetTop(gameOver, (outerGrid.Height - gameOver.getHeight()) / 2); Canvas.SetZIndex(gameOver, 10); gameOver.startAnimation(1500, 0); }