Example #1
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);
            }
        }
Example #2
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);
     }
 }
Example #3
0
 private void ChangePass(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!Validator.ValidTextBoxes(this.OldPassword.Password, this.NewPass.Password, this.RepNewPass.Password))
         {
             MessageBox.Show("Passwords not input");
         }
         else if (!Validator.CheckPassword(this.NewPass.Password, this.RepNewPass.Password))
         {
             MessageBox.Show("New passwords non Equal");
         }
         else if (!Validator.CheckPassword(thisUser.Password, Crypt.CryptPassword(this.OldPassword.Password)))
         {
             MessageBox.Show("Old passwords non Equal");
         }
         else
         {
             try
             {
                 thisUser.ChangePass(this.NewPass.Password);
                 ServerObject.SendMessage("13", thisUser.ToString());
                 MessageBox.Show("Password is changed");
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #4
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("Такой никнейм уже существует");
                }
            }
        }
Example #5
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);
     }
 }
Example #6
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)
     {
     }
 }
Example #7
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);
     }
 }
Example #8
0
        private void SendMessage(object sender, RoutedEventArgs e)
        {
            if (!Validator.ValidateMessage(this.Message.Text))
            {
                Message msg = new Message(thisChat.ChatName, thisChat.thisUserName, this.Message.Text);
                ServerObject.SendMessage("18", msg.ToString());

                TextBlock tb = new TextBlock();
                tb.Style = this.FindResource("2") as Style;
                tb.Text  = this.Message.Text;
                Messages.Children.Add(tb);
                scroll.ScrollToBottom();
            }
            else
            {
                MessageBox.Show("Please, enter the message");
            }
            this.Message.Text = "Write message...";
        }
Example #9
0
 private void CreateChat(object sender, RoutedEventArgs e)
 {
     try
     {
         if (this.DataGrid.SelectedItems.Count > 4)
         {
             MessageBox.Show("нужно 4 и меньше");
         }
         else if (this.DataGrid.SelectedItems.Count == 0)
         {
             MessageBox.Show("Не выбраны польщователи");
         }
         else
         {
             UserList list = new UserList(this.DataGrid.SelectedItems.Cast <User>().ToList());
             ServerObject.SendMessage("15", thisUser.NickName + ";" + list.ToString());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }