Ejemplo n.º 1
0
        //Generate game overview
        protected Grid generateGameOverview(GameState gs)
        {
            Grid game = new Grid();

            for (int i = 0; i < 3; i++)
            {
                ColumnDefinition gridCol1 = new ColumnDefinition();
                gridCol1.Width = new GridLength(listOfGamesPanel.Width / 3);
                game.ColumnDefinitions.Add(gridCol1);
            }
            //create the join button
            Button joinButton = new Button();

            joinButton.Content = "Join";
            joinButton.Height  = 20;
            joinButton.Width   = 50;
            joinButton.Style   = Application.Current.Resources["buttonTemplate"] as Style;
            joinButton.Tag     = gs;
            joinButton.Click  += (s, e) => {
                joinGame((GameState)((Button)s).Tag);
            };
            joinButton.SetValue(Grid.ColumnProperty, 0);

            //gnerate the overview of the board
            Border mygame = CheckerBoardWindow.generateCheckerBoardUI(70, gs, false);

            mygame.SetValue(Grid.ColumnProperty, 1);


            TextBlock player = new TextBlock();

            //Add the player's name who's currently in that game
            player.Text   = string.IsNullOrEmpty(gs.player1Name) ? gs.player2Name : gs.player1Name;
            player.Width  = 70;
            player.Height = 20;
            player.Style  = Application.Current.Resources["textBlockTemplate"] as Style;
            player.SetValue(Grid.ColumnProperty, 2);

            //Add all elements to the stack panel
            game.Children.Add(joinButton);
            game.Children.Add(mygame);
            game.Children.Add(player);

            return(game);
        }
Ejemplo n.º 2
0
        public CheckerBoardWindow()
        {
            InitializeComponent();
            Instance = this;

            //Set gradiant for the checker pieces
            SetGradient(redGradient, System.Windows.Media.Color.FromRgb(220, 141, 124), System.Windows.Media.Color.FromRgb(177, 8, 1), System.Windows.Media.Color.FromRgb(131, 22, 2));
            SetGradient(blackGradient, System.Windows.Media.Color.FromRgb(139, 141, 136), System.Windows.Media.Color.FromRgb(43, 43, 45), System.Windows.Media.Color.FromRgb(68, 67, 63));

            //name for local
            if (gc.testLocal)
            {
                gc.GetGameState().player2Name = "testLocalPlayer";
            }

            //Generate the game board
            refreshBoard(generateCheckerBoardUI(boardSize, gc.GetGameState(), false));

            //Set up the backend timer to run the game client
            recvTimer          = new System.Windows.Threading.DispatcherTimer();
            recvTimer.Tick    += new EventHandler(GetMove);
            recvTimer.Interval = TimeSpan.FromMilliseconds(166);
            recvTimer.Start();
        }