Exemplo n.º 1
0
        /// <summary>
        /// This Mth is calling the logic for registering a new user in DB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Register_Click(object sender, System.EventArgs e)
        {
            try
            {
                bool isUserExist = false;
                _communicationManager = new CommunicationManager();                                                       //Creates a new instance of client communication manager (client logic)
                string userToRegister        = txt_UserRegistration.Text;                                                 //Set the user from the textbox to be the new user to register
                string nickNameToRegister    = txt_NickNameRegistration.Text;                                             //Set the nickname from the textbox to be the new nickname to register
                bool   isRegistrationSuccess = _communicationManager.RegisterNewUser(userToRegister, nickNameToRegister); //Call the CM logic to register the new user.

                if (isRegistrationSuccess)
                {
                    // isRegistrationSuccess = true; //todo - check if this var is needed
                    MessageBox.Show(@"Registration succeded");//If the registration succeded, pop up a success message
                }
                else
                {
                    isRegistrationSuccess = false;
                    MessageBox.Show(@"Registration did not succeded");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            //Check if user exist in DB.
            //IF exist, connect, else
        }
Exemplo n.º 2
0
 /// <summary>
 /// Client Chat constructor
 /// </summary>
 public ClientChatWindow()
 {
     InitializeComponent();
     _communicationManager = new CommunicationManager();
     //Creates an instance of this class with contains the _client logics to communicate with the server
     _communicationManager.Set(this);
     txtBoxNickName.Text = Environment.UserName; //Set the NickName to be the Windows logged in userName
 }