Beispiel #1
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!Validator.ValidTextBoxes(this.Name.Text, this.Pass.Password))
         {
             MessageBox.Show("Enter your nickname and password");
         }
         else
         {
             User thisUser = new User(this.Name.Text, this.Pass.Password);
             ServerObject.SendMessage("11", thisUser.GetLogAndPass());
             string exMess = ServerObject.GetMessage();
             if (exMess == "false")
             {
                 Menu menu = new Menu(this.Name.Text);
                 menu.Show();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("логин и/или пароль неверны");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #2
0
        public Menu(string UserName)
        {
            try
            {
                InitializeComponent();
                this.UserName.Text = UserName;
                ServerObject.SendMessage("12", UserName);
                thisUser           = new User(ServerObject.GetMessage());
                this.UserInfo.Text = thisUser.Name + "  " + thisUser.SurName + "  aka  " + thisUser.NickName;
                this.Birthday.Text = thisUser.Birthday;
                this.Gender.Text   = thisUser.Gender;
                this.Country.Text  = thisUser.Country;
                this.City.Text     = thisUser.City;

                //all users
                ServerObject.SendMessage("16", "");
                this.DataGrid.ItemsSource = new UserList(ServerObject.GetMessage()).GetUsers();

                //all chats
                update = new Thread(this.UpdateChats);
                update.Start();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Beispiel #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!Validator.ValidTextBoxes(this.Name.Text, this.Surname.Text, this.NickName.Text,
                                          this.Pass.Password, this.Pass2.Password, this.Date.Text, this.Country.Text, this.City.Text) ||
                !Validator.ValidRadio((bool)this.Male.IsChecked, (bool)this.Female.IsChecked))
            {
                MessageBox.Show("Please, enter the information");
            }
            else if (!Validator.CheckPassword(this.Pass.Password, this.Pass2.Password))
            {
                MessageBox.Show("Please, enter equal passwords");
            }
            else
            {
                User user = new User(this.Name.Text, this.Surname.Text, this.NickName.Text,
                                     this.Male.IsChecked == true ? this.Male.Name : this.Female.Name,
                                     this.Date.Text, this.Country.Text, this.City.Text, this.Pass.Password);
                ServerObject.SendMessage("10", user.ToString());

                string exMess = ServerObject.GetMessage();
                if (exMess == "false")
                {
                    MainWindow mainWind = new MainWindow();
                    mainWind.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Такой никнейм уже существует");
                }
            }
        }
Beispiel #4
0
 private void Searching(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!Validator.ValidTextBoxes(this.SearchBy.Text, this.TextToSearch.Text))
         {
             MessageBox.Show("Data not input");
         }
         SearchObject sObj = new SearchObject(this.TextToSearch.Text, this.SearchBy.Text);
         ServerObject.SendMessage("14", sObj.ToString());
         this.DataGrid.ItemsSource = new UserList(ServerObject.GetMessage()).GetUsers();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #5
0
 private void UpdateChats()
 {
     try
     {
         while (true)
         {
             ServerObject.SendMessage("17", thisUser.NickName);
             this.Dispatcher.Invoke((Action)(() =>
             {
                 this.Chats.ItemsSource = new ChatList(ServerObject.GetMessage()).GetChats();
             }));
             Thread.Sleep(5000);
         }
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #6
0
 private void UpdateMsgs()
 {
     try
     {
         while (true)
         {
             ServerObject.SendMessage("19", thisChat.ToString());
             MessageList list = new MessageList(ServerObject.GetMessage());
             this.Dispatcher.Invoke((Action)(() =>
             {
             }));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }