Exemplo n.º 1
0
        // a label
        private CustomizedLabel whoAreYouLabel(int row, Color c, String content)
        {
            CustomizedLabel l = new CustomizedLabel(c, content);

            l.SetValue(Grid.RowProperty, row);

            return(l);
        }
Exemplo n.º 2
0
        // the single mode setting
        private Grid ButtonGridSingle(Grid holder)
        {
            Grid aGrid = new Grid();

            setGrid(2, 3, aGrid);

            int colorNum = 6;

            Color[] colors = SquareGenerator.randomColor(colorNum);

            CustomizedLabel whoAreYouPlayer1 = whoAreYouLabel(0, colors[0], "昵称:");

            TextBox aBox = setTextBox(0, 1, 0);

            CustomizedButton2 goButton =
                new CustomizedButton2("开始游戏", colors[1]);

            //goButton.Width = 100;
            goButton.button.Click += new RoutedEventHandler(
                delegate
            {
                PlayersName.setName(0, aBox.Text);
                nav = NavigationService.GetNavigationService(this);
                SingleModePage nextPage = new SingleModePage();
                nextPage.holderWin      = holderWin;
                nav.Navigate(nextPage);
            });
            goButton.SetValue(Grid.RowProperty, 1);

            CustomizedButton2 backButton =
                new CustomizedButton2("后  退", colors[2]);

            //backButton.Width = 100;
            backButton.button.Click += new RoutedEventHandler(
                delegate
            {
                Grid nextGrid = ButtonGrid1(holder);
                switchGrid(aGrid, nextGrid, holder, backButton.button);
            });
            backButton.SetValue(Grid.RowProperty, 3);

            aGrid.Children.Add(whoAreYouPlayer1);
            aGrid.Children.Add(aBox);
            aGrid.Children.Add(goButton);
            aGrid.Children.Add(backButton);

            return(aGrid);
        }
Exemplo n.º 3
0
        // the dual mode setting
        private Grid ButtonGridDual(Grid holder)
        {
            String[] contents1 = new string[2] {
                "  人  ", "电  脑"
            };
            String[] contents2 = new string[3] {
                "低难度", "中难度", "高难度"
            };

            Grid aGrid = new Grid();

            setGrid(2, 6, aGrid);

            int colorNum = 6;

            Color[] colors = SquareGenerator.randomColor(colorNum);

            CustomizedLabel player1 = whoAreYouLabel(0, colors[5], "玩家1:");

            SwitchLabel player1Sel = setSwitchLabel(0, contents1, 1);

            CustomizedLabel whoAreYouPlayer1 = whoAreYouLabel(1, colors[0], "昵称:");
            CustomizedLabel difficulty1      = whoAreYouLabel(1, colors[0], "难  度:");

            difficulty1.Opacity = 0;

            TextBox aBox1 = setTextBox(1, 1, 0);

            SwitchLabel dif1Sel = setSwitchLabel(1, contents2, 0);

            CustomizedLabel player2 = whoAreYouLabel(2, colors[3], "玩家2:");

            SwitchLabel player2Sel = setSwitchLabel(2, contents1, 1);

            CustomizedLabel whoAreYouPlayer2 = whoAreYouLabel(3, colors[4], "昵称:");
            CustomizedLabel difficulty2      = whoAreYouLabel(3, colors[4], "难  度:");

            difficulty2.Opacity = 0;

            TextBox     aBox2   = setTextBox(3, 1, 1);
            SwitchLabel dif2Sel = setSwitchLabel(3, contents2, 0);

            DualModePage.gameMode[] pModes = new DualModePage.gameMode[2];

            CustomizedButton2 goButton =
                new CustomizedButton2("开始游戏", colors[2]);

            // used to store the settings and go to dual game
            goButton.button.Click += new RoutedEventHandler(
                delegate
            {
                if (player1Sel.getLabelIndex() == 0)     // player1 is 人
                {
                    PlayersName.setName(0, aBox1.Text);
                    pModes[0] = new DualModePage.gameMode(0, 0);
                }
                else
                {
                    PlayersName.setName(0, "");
                    pModes[0] = new DualModePage.gameMode(1, dif1Sel.getLabelIndex());
                }
                if (player2Sel.getLabelIndex() == 0)     // player2 is 人
                {
                    PlayersName.setName(1, aBox2.Text);
                    pModes[1] = new DualModePage.gameMode(0, 0);
                }
                else
                {
                    PlayersName.setName(1, "");
                    pModes[1] = new DualModePage.gameMode(1, dif2Sel.getLabelIndex());
                }

                nav = NavigationService.GetNavigationService(this);
                DualModePage nextPage = new DualModePage(pModes);
                nextPage.holderWin    = holderWin;
                nav.Navigate(nextPage);
            });

            goButton.SetValue(Grid.RowProperty, 4);

            CustomizedButton2 backButton =
                new CustomizedButton2("后  退", colors[1]);

            backButton.button.Click += new RoutedEventHandler(
                delegate
            {
                Grid nextGrid = ButtonGrid1(holder);
                switchGrid(aGrid, nextGrid, holder, backButton.button);
            });
            backButton.SetValue(Grid.RowProperty, 6);

            aGrid.Children.Add(player1);
            aGrid.Children.Add(player2);
            aGrid.Children.Add(player1Sel);
            aGrid.Children.Add(whoAreYouPlayer1);
            aGrid.Children.Add(aBox1);
            aGrid.Children.Add(player2Sel);
            aGrid.Children.Add(whoAreYouPlayer2);
            aGrid.Children.Add(aBox2);
            aGrid.Children.Add(goButton);
            aGrid.Children.Add(backButton);

            setClickSwitch(whoAreYouPlayer1, difficulty1, aBox1, dif1Sel, player1Sel, aGrid);
            setClickSwitch(whoAreYouPlayer2, difficulty2, aBox2, dif2Sel, player2Sel, aGrid);

            return(aGrid);
        }