//This function is executed when the login button is clicked
        private void BtnLogIn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!String.IsNullOrWhiteSpace(txtBoxUname.Text.Trim()) && !String.IsNullOrWhiteSpace(txtBoxPwd.Password.Trim()))
                {
                    string        uname    = txtBoxUname.Text;
                    string        password = txtBoxPwd.Password;
                    List <string> ulist    = ulist = Portal.GetUserList();;

                    int id = ulist.IndexOf(uname);

                    int x = Portal.LogInUser(id, uname, password);
                    FriendList = Portal.GetFriendList(UserId);

                    if (x == 0)
                    {
                        //Saving the user id if user successully logs in
                        UserId   = id;
                        UserName = Portal.GetUserNameById(UserId);

                        ServerList ServerWindow = new ServerList(UserId, Portal.GetServerList(), UserName, Portal, FriendList);
                        ServerWindow.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Incorrect username or password");
                    }
                }
                else
                {
                    MessageBox.Show("Please enter both password and user name ! ");
                }
            }
            catch (EndpointNotFoundException)
            {
                MessageBox.Show("Error : Cannot communicate with the portal");
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Error : Cannot communicate with the portal");
            }
            catch (CommunicationObjectFaultedException)
            {
                MessageBox.Show("Error : Cannot open the next window");
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Error : Invalid data memebers found");
            }
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Server_List = ((MMOGamePlay.ServerList)(target));

            #line 8 "..\..\ServerList.xaml"
                this.Server_List.Loaded += new System.Windows.RoutedEventHandler(this.Server_List_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.lblServerList = ((System.Windows.Controls.Label)(target));
                return;

            case 3:
                this.listServers = ((System.Windows.Controls.ListView)(target));
                return;

            case 6:
                this.lblUname = ((System.Windows.Controls.Label)(target));
                return;

            case 7:
                this.btnSeeFriends = ((System.Windows.Controls.Button)(target));

            #line 47 "..\..\ServerList.xaml"
                this.btnSeeFriends.Click += new System.Windows.RoutedEventHandler(this.btnSeeFriends_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }