/// <summary> /// Подгрузка новых сообщений /// </summary> /// <param name="binaryReader"> Данные, полученные из сервера </param> private void NewMessages(BinaryReader binaryReader) { CountNewMessages = binaryReader.ReadInt32(); _typeOfSource = CountNewMessages == 0 ? 0 : 1; DeletePastMessages(); AddMessages(TypeOfLoadMessage.NewMessages); if (_isGoToBottom && CountNewMessages == 0) { _chatView.Scroll(); _isGoToBottom = false; } if (_haveNewMessage) { Messages.Add(new Message() { Id = Messages.Count > 0 ? Messages[Messages.Count - 1].Id + 1 : 1, SenderName = Name, DateSend = DateTime.Now.ToString(), SendMessage = Message, IsItMe = true }); _serverWorker.SendMessage(Message); AddNewMessageInContainerAndUpdateDateSend(); Message = ""; _chatView.Scroll(); _haveNewMessage = false; } _topID = Messages[0].Id; IsFocus = true; }