Пример #1
0
        protected void RoomBtnClicked(object sender, RoutedEventArgs e)
        {
            uint   id       = uint.Parse(((Button)sender).Name.Substring(1));
            string roomName = (string)((Button)sender).Content;

            JoinRoomResponse response = (JoinRoomResponse)Communicator.Communicate(new JoinRoomRequest(id));

            GetRoomStateResponse res = (GetRoomStateResponse)Communicator.Communicate(new GetRoomStateRequest());

            Room room = new Room(roomName, (uint)res.players.Split(',').Length, res.questionCount, res.answerTimeOut);

            if (response.status == 1)
            {
                WaitingRoomWindow wind = new WaitingRoomWindow(false, this.username, res.players.Split(','), room);
                wind.Show();
                this.Hide();
                this.Close();
            }
        }
Пример #2
0
        private void BtnCreateClick(object sender, RoutedEventArgs e)
        {
            if (IsNumericValue(TBPlayers.Text) && IsNumericValue(TBQuestions.Text) && IsNumericValue(TBTimePerQuestion.Text))
            {
                this.room = new Room(TBRoomName.Text, uint.Parse(TBPlayers.Text), uint.Parse(TBQuestions.Text), uint.Parse(TBTimePerQuestion.Text));

                CreateRoomResponse response = (CreateRoomResponse)Communicator.Communicate(
                    new CreateRoomRequest(this.room.roomName, this.room.numberOfPlayers, this.room.numberOfQuestions, this.room.TimeForQuestion));

                if (response.status == 1)
                {
                    WaitingRoomWindow wind = new WaitingRoomWindow(true, this.username, this.room);
                    wind.Show();
                    base.Hide();
                    base.Close();
                }
            }
            else
            {
                TBInvalid.Text = "One or more arguments are invalid";
            }
        }