Esempio n. 1
0
        // a label
        private SwitchLabel setSwitchLabel(int row, String[] contents, double opaque)
        {
            SwitchLabel l = new SwitchLabel(contents);

            l.SetValue(Grid.RowProperty, row);
            l.SetValue(Grid.ColumnProperty, 1);
            l.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            l.Opacity             = opaque;

            return(l);
        }
Esempio n. 2
0
 // a switching animation
 private void setClickSwitch(FrameworkElement from1, FrameworkElement to1,
                             FrameworkElement from2, FrameworkElement to2, SwitchLabel l, Grid holder)
 {
     l.p.Click += new RoutedEventHandler(
         delegate
     {
         if (l.getLabelIndex() == 0)
         {
             switchContent(from1, to1, holder, l.p);
             switchContent(from2, to2, holder, l.p);
         }
     });
     l.n.Click += new RoutedEventHandler(
         delegate
     {
         if (l.getLabelIndex() == 1)
         {
             switchContent(to1, from1, holder, l.n);
             switchContent(to2, from2, holder, l.p);
         }
     });
 }
Esempio 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);
        }