// function setup to record the user clicking the login button, allowing them to join the server
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            // attempts to join the server
            int returnValue = Server.Login(UsernameTextBox.Text);

            // if the username is already in use display a message
            if (returnValue == 1)
            {
                MessageBox.Show("You are already logged in. Try again");
            }
            // login the user and enable all messagin features
            else if (returnValue == 0)
            {
                MessageBox.Show("You logged in!");
                WelcomeLabel.Content = "Welcome " + UsernameTextBox.Text + " !";
                //means you cant log in twice
                UsernameTextBox.IsEnabled    = false;
                LoginButton.IsEnabled        = false;
                TextDisplayTextBox.IsEnabled = true;
                MessageTextBox.IsEnabled     = true;
                SendButton.IsEnabled         = true;
                checkBox.IsEnabled           = true;
                UsersListBox.IsEnabled       = true;
                TextDisplayTextBox.Text      = "Want to send a private message? Select a user from 'Who's Online' and enter your message as normal below. If you want to send a group message again, select your own username. \n \n";
                // checks if there has been a previous conversation and the user has used the service before
                fileExists();

                //load online users list
                LoadUserList(Server.GetCurrentUsers());
            }
        }
예제 #2
0
        //New command...
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            //username must be entered in order for action LOGIN to be successful
            int returnValue = Server.Login(UserNameTextBox.Text);

            if (returnValue == 1)
            {
                //if I am logged in, do not let someone else login again...
                MessageBox.Show("You are already logged in. Log out first and try again");
            }

            //Otherwise connect the user successfully...
            else if (returnValue == 0)
            {
                //once username is entered, do not allow another client to login with same credentials.
                UserNameTextBox.IsEnabled = false;
                //disable login button.
                LoginButton.IsEnabled = false;
                //Once logged in, message view box will be set as non edit mode ***
                TextDisplayTextBox.IsEnabled = false;

                //load our users...
                LoadUserList(Server.GetCurrentUsers());
            }
        }
예제 #3
0
        void btn_Login_Click(object sender, RoutedEventArgs e)
        {
            if (tb_Name.Text != string.Empty)
            {
                int i = Server.Login(tb_Name.Text);

                if (i == 1)
                {
                    MessageBox.Show("You are already login !!!");
                }
                else if (i == 0)
                {
                    MessageBox.Show("Welcom !!!");
                    tb_Name.IsEnabled   = false;
                    btn_Login.IsEnabled = false;

                    LoadUserList(Server.GetCurrrentUserList());
                }
            }

            else
            {
                string username = "******" + RandomInt(5);

                int i = Server.Login(username);

                if (i == 1)
                {
                    MessageBox.Show("You are already login !!!");
                }
                else if (i == 0)
                {
                    MessageBox.Show("Welcom !!!");
                    tb_Name.IsEnabled   = false;
                    btn_Login.IsEnabled = false;

                    tb_Name.Text = username;

                    LoadUserList(Server.GetCurrrentUserList());
                }
            }
        }
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            int returnValue = _server.Login(textBoxUserName.Text, "123");

            if (returnValue == 1)
            {
                MessageBox.Show("Already logged in!!!");
            }
            else if (returnValue == 0)
            {
                textBoxUserName.IsEnabled = false;
                Login.IsEnabled           = false;
                LoadUsers();
            }
        }
예제 #5
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            int returnValue = Server.Login(UserNameTextBox.Text);

            if (returnValue == 1)
            {
                MessageBox.Show("You are already Logged in");
            }
            else if (returnValue == 0)
            {
                MessageBox.Show("You logged in!");
                WelcomeLabel.Content      = "Welcome : " + UserNameTextBox.Text + "!";
                UserNameTextBox.IsEnabled = false;
                LoginButton.IsEnabled     = false;
            }
        }
        private void bntLogin_Click(object sender, RoutedEventArgs e)
        {
            int returnValue = Server.Login(txtUserName.Text);

            if (returnValue == 1)
            {
                MessageBox.Show("You are already logged in with " + lblWelcome.Content.ToString().ToUpper() + " Try again");
            }
            else if (returnValue == 0)
            {
                MessageBox.Show("Hallo " + txtUserName.Text);
                txtUserName.IsEnabled = false;
                bntLogin.IsEnabled    = false;
                lblWelcome.Content    = "You: " + txtUserName.Text;
            }
        }
예제 #7
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            int returnValue = Server.Login(UserNameTextBox.Text);

            if (returnValue == 1)
            {
                MessageBox.Show("User already logged in.");
            }
            else if (returnValue == 0)
            {
                TextDisplayTextBox.Text  += ">>> You are now logged in! \n";
                UserNameTextBox.IsEnabled = false;
                LoginButton.IsEnabled     = false;

                AddUsersToList(Server.GetCurrentUsers());
            }
        }
예제 #8
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            int returnValue = Server.Login(UserNameTextBox.Text);

            if (returnValue == 1)
            {
                MessageBox.Show("You are already logged in ! Try again");
            }
            else if (returnValue == 0)
            {
                UserNameTextBox.IsEnabled = false;
                LoginButton.IsEnabled     = false;
                label.Content             = "Welcome " + UserNameTextBox.Text;

                LoadUserList(Server.GetCurrentUsers());
            }
        }
예제 #9
0
        public ChatWPFClient()
        {
            InitializeComponent();
            _channelFactory = new DuplexChannelFactory <IChattingService>(new ClientCallback(), "ChattingServiceEndPoint");
            Server          = _channelFactory.CreateChannel();

            int returnValue = Server.Login(loggedInUser.username);

            if (returnValue == 1)
            {
                MessageBox.Show("You are already logged in, check to see who is logged into system");
            }
            else if (returnValue == 0)
            {
                MessageBox.Show("You are now logged in! Welcome!");
                welcomeLabel.Text = "Welcome, " + loggedInUser.username;
            }
        }
예제 #10
0
        private void LogInButton_Click(object sender, RoutedEventArgs e)
        {
            int returnValue = Server.Login(userNameTextbox.Text);

            if (returnValue == 1)
            {
                MessageBox.Show("Already logged in", "Message", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
            else if (returnValue == 0)
            {
                MessageBox.Show("Logged in", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
                welcomeLabel.Content      = "welcome" + " " + userNameTextbox.Text + "!";
                userNameTextbox.IsEnabled = false;
                logInButton.IsEnabled     = false;

                LoadUserList(Server.GetCurrentUsers());
            }
        }
        public ChatWPFClient()
        {
            InitializeComponent();
            _channelFactory = new DuplexChannelFactory<IChattingService>(new ClientCallback(), "ChattingServiceEndPoint");
            Server = _channelFactory.CreateChannel();

            int returnValue = Server.Login(loggedInUser.username);
            if (returnValue == 1)
            {
                MessageBox.Show("You are already logged in, check to see who is logged into system");

            }
            else if (returnValue == 0)
            {
                MessageBox.Show("You are now logged in! Welcome!");
                welcomeLabel.Text = "Welcome, " + loggedInUser.username;

            }
        }
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            int returnValue = Server.Login(UserNameTextBox.Text);

            if (returnValue == 1)
            {
                MessageBox.Show("You are already logged in. Try again");
            }
            else if (returnValue == 0)
            {
                //Displays the name of the user who logged on
                MessageBox.Show("You successfully logged in!");
                WelcomeUserLbl.Content    = "Welcome " + UserNameTextBox.Text + "!";
                UserNameTextBox.IsEnabled = false;
                LoginButton.IsEnabled     = false;

                //loads users
                LoadUserList(Server.GetCurrentUsers());
            }
        }
예제 #13
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int returnValue = Server.Login(UserNameTextBox.Text);
                if (returnValue == 1)
                {
                    MessageBox.Show("You are alredy log");
                }
                else
                {
                    MessageBox.Show("You log");
                    WelcomLabel.Content       = "Welcom" + UserNameTextBox.Text;
                    UserNameTextBox.IsEnabled = false;
                    LoginButton.IsEnabled     = false;

                    LoadUserList(Server.GetCurrentUsers());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }