示例#1
0
        private void BtnCreateClick(object sender, RoutedEventArgs e)
        {
            if (ValidateBoardSize())
            {
                int vSize = int.Parse(txt_vSize.Text);
                int hSize = int.Parse(txt_hSize.Text);

                var bs = new BoardSize { Width = vSize, Height = hSize };
                _api.PostGame(bs);
                lb_games.ItemsSource = GetGames();
                btn_create.Content = "created";
                var mainWindow = new MainWindow { GameId = lb_games.Items.Count, PlayerId = 1 };

                mainWindow.Show();
            }
            else
            {
                btn_create.Content = "not created";
            }
        }
示例#2
0
 private void BtnJoinClick(object sender, RoutedEventArgs e)
 {
     try
     {
         _api.PostPlayer(lb_games.SelectedIndex + 1);
         var mainWindow = new MainWindow { GameId = lb_games.SelectedIndex + 1, PlayerId = 2 };
         mainWindow.Show();
     }
     catch (Exception)
     {
         btn_join.Content = "Error";
     }
 }