/// <summary>
        /// Called when btnConfirm is clicked.
        /// </summary>
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            int roomID = this.MyConnection.CreateRoom(Convert.ToInt32(this.sldGameTime.Value));

            if (roomID <= 0)
            {
                MessageBox.Show("Une erreur s'est produite lors de la création du salon.");
            }
            else
            {
                bool hasJoined = this.MyConnection.JoinRoom(roomID);

                if (hasJoined)
                {
                    JoinedRoomWindow joinedRoomWindow = new JoinedRoomWindow(this.MyConnection, roomID);
                    joinedRoomWindow.Owner = this;
                    this.Hide();
                    joinedRoomWindow.Show();
                    this.MyConnection.RegisterObserver(joinedRoomWindow);
                }
                else
                {
                    MessageBox.Show("Impossible de rejoindre le salon.");
                }
            }
        }
Example #2
0
        /// <summary>
        /// Called when btnJoin is clicked.
        /// </summary>
        private void btnJoin_Click(object sender, RoutedEventArgs e)
        {
            if (lwRooms.SelectedIndex > -1)
            {
                int  roomID    = Convert.ToInt32((lwRooms.SelectedItems[0] as RoomItem).RoomID);
                bool hasJoined = this.MyConnection.JoinRoom(roomID);

                if (hasJoined)
                {
                    JoinedRoomWindow joinedRoomWindow = new JoinedRoomWindow(this.MyConnection, roomID);
                    joinedRoomWindow.Owner = this;
                    this.Hide();
                    joinedRoomWindow.Show();
                    this.MyConnection.RegisterObserver(joinedRoomWindow);
                }
                else
                {
                    MessageBox.Show("Impossible de rejoindre le salon.");
                }
            }
        }