void ft_fileTransmitted(object sender) { OurMsg.Controls.FileTransmit ft = sender as OurMsg.Controls.FileTransmit; if (ft.isSend) { MessagePanel1.addRemarkTextToRecord(" 文件“" + ft.P2PFileTransmit.TFileInfo.Name + "”已经传输结束!"); } else { MessagePanel1.addRemarkTextToRecord(" 文件“<file:\\\\" + ft.P2PFileTransmit.TFileInfo.fullName + ">”已经传输结束!"); } flowLayoutPanel1.Controls.Remove(ft); ft.Dispose(); ft = null; }
void ft_fileTransmitCancel(object sender) { OurMsg.Controls.FileTransmit ft = sender as OurMsg.Controls.FileTransmit; IMLibrary3.Protocol.P2PFileMsg pfile = new IMLibrary3.Protocol.P2PFileMsg(); //文件传输协商协议 pfile.type = IMLibrary3.Protocol.type.cancel; //标记取消文件传输 pfile.MD5 = ft.P2PFileTransmit.TFileInfo.MD5; if (SendMsgToUser != null)//触发消息发送事件 { SendMsgToUser(pfile, User); } MessagePanel1.addRemarkTextToRecord(" 您取消了文件“" + ft.P2PFileTransmit.TFileInfo.Name + "”的传输!"); flowLayoutPanel1.Controls.Remove(ft); ft.Dispose(); ft = null; }
/// <summary> /// 取消文件传输 /// </summary> /// <param name="pfile"></param> public void CancelFile(IMLibrary3.Protocol.P2PFileMsg pfile) { if (pfile.MD5 == "") { flowLayoutPanel1.Controls.Clear(); MessagePanel1.addRemarkTextToRecord(" 对方取消了所有文件的传输!"); return; } foreach (Control c in flowLayoutPanel1.Controls) { OurMsg.Controls.FileTransmit ft = c as OurMsg.Controls.FileTransmit; if (ft != null && (ft.P2PFileTransmit.TFileInfo.MD5 == pfile.MD5)) { ft.CancelTransmit(); MessagePanel1.addRemarkTextToRecord(" 对方取消了文件“" + ft.P2PFileTransmit.TFileInfo.Name + "”的传输!"); flowLayoutPanel1.Controls.Remove(ft); ft.Dispose(); ft = null; } } }