private void txtMessage_KeyDown(object sender, KeyEventArgs e) { if (e.Control) { switch (e.KeyCode) { case Keys.V: if (Clipboard.ContainsFileDropList()) { List <string> fileNames = new List <string>(); foreach (string filePath in Clipboard.GetFileDropList()) { if (File.Exists(filePath)) { fileNames.Add(filePath); } } foreach (string fileName in fileNames) { _network.SendFileAttachment("", fileName); } e.Handled = true; e.SuppressKeyPress = true; } break; case Keys.Back: string msgRight = txtMessage.Text.Substring(0, txtMessage.SelectionStart); string msgLeft = txtMessage.Text.Substring(txtMessage.SelectionStart); int i = msgRight.TrimEnd().LastIndexOfAny(new char[] { ' ', '\n' }); if (i > -1) { i++; txtMessage.Text = msgRight.Substring(0, i) + msgLeft; txtMessage.SelectionStart = i; } else { txtMessage.Text = msgLeft; txtMessage.SelectionStart = 0; } e.Handled = true; e.SuppressKeyPress = true; break; } } }
private void lstFiles_DragDrop(object sender, DragEventArgs e) { string[] fileNames = e.Data.GetData(DataFormats.FileDrop) as string[]; foreach (string fileName in fileNames) { _network.SendFileAttachment("", fileName); } }