public void DeleteUser(AccountInformation accountInformation)
 {
     AccountInformation account = SearchAccount(accountInformation);
     if (account != null)
     {
         _accountsOnline[account].Disconnect(false);
         Program.SecureWriting(() =>
         {
             ConsoleColor colorTemp = Console.BackgroundColor;
             Console.BackgroundColor = ConsoleColor.DarkCyan;
             Console.Write("Пользователь");
             Console.BackgroundColor = colorTemp;
             Console.Write(" ");
             Console.BackgroundColor = ConsoleColor.Gray;
             ConsoleColor tmpForeg = Console.ForegroundColor;
             Console.ForegroundColor = ConsoleColor.Blue;
             Console.Write(accountInformation.FirstName);
             Console.BackgroundColor = colorTemp;
             Console.Write(" ");
             Console.BackgroundColor = ConsoleColor.Gray;
             Console.Write(accountInformation.LastName);
             Console.ForegroundColor = tmpForeg;
             Console.BackgroundColor = colorTemp;
             Console.Write(" ");
             Console.BackgroundColor = ConsoleColor.DarkCyan;
             Console.WriteLine("вышел из чата");
             Console.BackgroundColor = colorTemp;
         });
         _accountsOnline.Remove(account);
     }
 }
 public MainWindow(Socket connection_socket, AccountInformation information)
 {
     InitializeComponent();
     _getUsersOnline = () =>
     {
         Functions.SerializeAndSend(new GetUsersOnline(), connection_socket);
         Console.WriteLine("Отправлен запрос на получение списка пользователей");
     };
     new Thread(Listen_server).Start(connection_socket);
     _writeToComboBox = new ComboBox();
     _writeToComboBox.DropDownClosed += writeToComboBox_DropDownClosed;
     Grid.SetRow(_writeToComboBox, Grid.GetRow(writeToButton));
     _writeToComboBox.Margin = new Thickness(0, 5, 5, 5);
     _writeToComboBox.Items.Add("Написать всем");
     _writeToComboBox.Items.Add("Написать девушкам");
     _writeToComboBox.Items.Add("Написать парням");
     _writeToComboBox.Items.Add("Написать группе");
     _connectionSocket = connection_socket;
     AccountInformation = information;
     Title = AccountInformation + " — Чат";
     _getUsersOnline.BeginInvoke(null, null);
 }
        public void AddUser(AccountInformation accountInformation, Socket socket)
        {
            if (!_accountsOnline.ContainsKey(accountInformation))
            {

                foreach (Socket sockeT in _accountsOnline.Values)
                {
                    Functions.SerializeAndSend(
                        new MessageFromServer("Пользователь " + accountInformation.FirstName + " " +
                                              accountInformation.LastName + " зашёл в чат"), sockeT);
                }
                _accountsOnline.Add(accountInformation, socket);
                Program.SecureWriting(() =>
                {
                    ConsoleColor colorTemp = Console.BackgroundColor;
                    Console.BackgroundColor = ConsoleColor.Blue;
                    Console.Write("Пользователь");
                    Console.BackgroundColor = colorTemp;
                    Console.Write(" ");
                    Console.BackgroundColor = ConsoleColor.Gray;
                    ConsoleColor tmpForeg = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.Write(accountInformation.FirstName);
                    Console.BackgroundColor = colorTemp;
                    Console.Write(" ");
                    Console.BackgroundColor = ConsoleColor.Gray;
                    Console.Write(accountInformation.LastName);
                    Console.ForegroundColor = tmpForeg;
                    Console.BackgroundColor = colorTemp;
                    Console.Write(" ");
                    Console.BackgroundColor = ConsoleColor.Blue;
                    Console.WriteLine("зашёл в чат");
                    Console.BackgroundColor = colorTemp;
                });
            }
        }
        private void signInButton_Click(object sender, RoutedEventArgs e)
        {
            if (LoginTextBox.Text == "" || PasswordPasswordBox.Password == "") return;
            _loading = new Loading(this);
            _loading.Show();

            ConnectionSocket = Functions.ReturnNewSocket(ConnectionSocket);
            Functions.SerializeAndSend(new Authorization(LoginTextBox.Text, PasswordPasswordBox.Password), ConnectionSocket);

            object obj;
            {
                byte[] byteBuffer = new byte[1024];
                if (ConnectionSocket.Receive(byteBuffer) == 0)
                {
                    MessageBox.Show("Получено 0 байт");
                }
                obj = Functions.Deserialize(byteBuffer);
            }
            if (!(obj is AccountInformation)) return;
            AccountInformation accountInf = obj as AccountInformation;
            if(accountInf.IsNull)
            {
                MessageBox.Show("Ошибка в логине или пароле!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                _loading.Close();
                LoginTextBox.Focus();
            }
            else
            {
                _whetherToCreate = true;
                _ai = accountInf;
                Close();
            }
        }
Пример #5
0
 public Correspondence(AccountInformation interlocutor)
 {
     Interlocutor = interlocutor;
 }
Пример #6
0
 public UserDisconnect(AccountInformation thisAccountInforamtion)
 {
     ThisAccountInforamtion = thisAccountInforamtion;
 }
 AccountInformation SearchAccount(AccountInformation ai)
 {
     return AccountsOnline.Keys.FirstOrDefault(acInf => String.CompareOrdinal(acInf.Email, ai.Email) == 0);
 }
Пример #8
0
 public UserDisconnect(AccountInformation thisAccountInforamtion)
 {
     ThisAccountInforamtion = thisAccountInforamtion;
 }
Пример #9
0
 public Correspondence(AccountInformation interlocutor)
 {
     Interlocutor = interlocutor;
 }