コード例 #1
0
 private void registerButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (passwordBox.Text != textBox2.Text)
         {
             MessageBox.Show("Passwords do not match!", "Password", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (ClientApp.GetServer().RegisterUser(nicknameBox.Text, textBox2.Text, passwordBox.Text))
         {
             Console.WriteLine(@"Registration worked");
             ActiveUser newUser = ClientApp.GetServer().LoginUser(nicknameBox.Text, passwordBox.Text, ClientApp.GetInstance().Address);
             if (newUser != null)
             {
                 ClientApp.SetLoggedUser(newUser);
                 Console.WriteLine(@"Login worked");
                 this.Hide();
                 ClientApp.SetMainWindow(new MainWindow(newUser));
                 ClientApp.GetMainWindow().ShowDialog();
             }
         }
         else
         {
             MessageBox.Show("8 characters minimum;" + Environment.NewLine + "Can not have white spaces, <, >, \' or \"", "Password Rules", MessageBoxButtons.OK);
         }
     }
     catch (Exception ex)
     {
         ClientApp.LaunchServerError(ex.Message);
     }
 }
コード例 #2
0
 private void loginButton_Click(object sender, EventArgs e)
 {
     try
     {
         ActiveUser newUser = ClientApp.GetServer().LoginUser(nicknameBox.Text, passwordBox.Text, ClientApp.GetInstance().Address);
         if (newUser != null)
         {
             ClientApp.SetLoggedUser(newUser);
             Console.WriteLine(@"Login worked");
             this.Hide();
             ClientApp.SetMainWindow(new MainWindow(newUser));
             ClientApp.GetMainWindow().ShowDialog();
         }
         else
         {
             MessageBox.Show("Login Failed: Be sure that you were registred with those credentials",
                             "Login Failed",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             nicknameBox.Text = "";
             passwordBox.Text = "";
         }
     }
     catch (Exception ex)
     {
         ClientApp.LaunchServerError(ex.Message);
     }
 }
コード例 #3
0
        public void Invite(ControlMessage m)
        {
            if (ClientApp.GetInstance().GetChats().ContainsKey(m.ID))
            {
                return;
            }

            Console.WriteLine(@"Invitation received from " + m.Sender + " to join " + m.ID);
            ClientApp.GetMainWindow().LaunchInviteWindow(m);
        }
コード例 #4
0
        public void AcceptChat(ActiveUser user, string chatName, RemoteChat chat, string number)
        {
            if (ClientApp.GetInstance().GetChats().ContainsKey(number))
            {
                return;
            }
            if (!ClientApp.GetInstance().GetPendingChats().Remove(number))
            {
                Console.WriteLine("Not found  element");
            }

            ClientApp.GetMainWindow().StartChatBox(user, chatName, chat, number);
        }
コード例 #5
0
        private void AcceptInvationButton_Click(object sender, System.EventArgs e)
        {
            string chatName;

            if (_chatName != _user.Username)
            {
                chatName = _chatName;
            }
            else
            {
                chatName = ClientApp.GetLoggedUser().Username;
            }

            Task.Factory.StartNew(() => { _iFriend.AcceptChat(ClientApp.GetLoggedUser(), chatName, _chat, _id); });


            ClientApp.GetMainWindow().StartChatBox(_user, _chatName, _chat, _id);
            this.Close();
        }
コード例 #6
0
 public void RejectChat(ActiveUser user, string chatName, string id)
 {
     ClientApp.GetInstance().GetPendingChats().Remove(id);
     ClientApp.GetMainWindow().RejectedChat(user, chatName);
 }