コード例 #1
0
ファイル: portal.cs プロジェクト: hakonamatata/WCF-Risk-Game
        private void btnHostNewGame_Click(object sender, EventArgs e)
        {
            try
            {
                if (proxy == null)
                {
                    proxy = new GamePortal.GamePortalClient();
                }

                int amount = Convert.ToInt32(numericAmount.Value);
                bool result = proxy.createNewGame(tbName.Text, amount);

                if (result)
                {
                    updateAvaliableGames();
                }
                else
                {
                    MessageBox.Show("Creating a game was UNSUCCESFUL. Remember that game name need to be between 3 and 15 characters and amount of players between 2 and 4");
                }

            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
コード例 #2
0
ファイル: portal.cs プロジェクト: hakonamatata/WCF-Risk-Game
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            // get game id
            int index = lbAvaliableGames.SelectedIndex;

            // check if game exist
            try
            {
                if (proxy == null)
                {
                    proxy = new GamePortal.GamePortalClient();
                }

                bool result = proxy.gameIdExist(index);
                if (result == false)
                {
                    return;
                }

                gameName = proxy.getGameName(index);

                gameId = index;

                // start new form in a new thread so it can run after the
                // portal is closed
                Thread t = new Thread(new System.Threading.ThreadStart(ThreadRunningMainForm));
                t.Start();

                //mainScreen form = new mainScreen(index);
                //form.Show();

            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }
コード例 #3
0
ファイル: portal.cs プロジェクト: hakonamatata/WCF-Risk-Game
        private void updateAvaliableGames()
        {
            try
            {
                if (proxy == null)
                {
                    proxy = new GamePortal.GamePortalClient();
                }

                String[] avaliableGames = proxy.getAvaliableGames();

                if (avaliableGames == null)
                {
                    avaliableGames = new String[] { "no avaliable games" };
                }

                lbAvaliableGames.Items.Clear();
                foreach (string s in avaliableGames)
                {
                    lbAvaliableGames.Items.Add(s);
                }

            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }