Beispiel #1
0
        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);
        }