private void SendBtn_Click(object sender, EventArgs e) { if (MessageTBox.Text.Length != 0) { currentClient.SendMessage(MessageTBox.Text); MessageTBox.Text = ""; } }
private void SendBtn_Click(object sender, EventArgs e) { if (selectedDialog != -1) { if (MessageTBox.Text.Length != 0) { ChatMessage chatMessage = new ChatMessage(DateTime.Now, currentClient.clientIp, currentClient.clientPort, MessageTBox.Text, currentClient.UserName, selectedDialogId); if (selectedDialogId != currentClient.MyId) { currentClient.SendMessage(chatMessage); } selectedClientDialog.MessageHistory.Add(chatMessage); RedrawOther(currentClient.UserName, MessageTBox.Text, DateTime.Now.ToString()); MessageTBox.Text = ""; } } }
private void SendBtn_Click(object sender, EventArgs e) { if (selectedDialog != -1) { if ((MessageTBox.Text.Length != 0) || (httpClient.LoadedFiles.Count != 0)) { ChatMessage chatMessage = new ChatMessage(DateTime.Now, currentClient.clientIp, currentClient.clientPort, MessageTBox.Text, currentClient.UserName, selectedDialogId); if (httpClient.LoadedFiles.Count != 0) { chatMessage.IsAnyFiles = true; var fileInMessageList = new List <FileInMessage>(); foreach (KeyValuePair <int, string> keyValuePair in httpClient.LoadedFiles) { chatMessage.FilesInMessageList.Add(new FileInMessage() { fileID = keyValuePair.Key, fileName = keyValuePair.Value }); } httpClient.LoadedFiles.Clear(); httpClient.sizeOfLoadedFiles = 0; LoadedFIlesCBox.SelectedIndex = -1; UpdateFilesList(); } if (selectedDialogId != currentClient.MyId) { currentClient.SendMessage(chatMessage); } selectedClientDialog.MessageHistory.Add(chatMessage); RedrawOther(chatMessage.SenderName, chatMessage.Content, chatMessage.DateTime); if (chatMessage.IsAnyFiles) { foreach (FileInMessage fileInMessage in chatMessage.FilesInMessageList) { RedrawFileInDialogPanel(chatMessage.SenderName + "отправил файл", fileInMessage.fileName, chatMessage.DateTime, fileInMessage.fileID); } } LoadedFIlesCBox.Text = ""; LoadedFIlesCBox.Items.Clear(); MessageTBox.Text = ""; } } }