private void RequestSendFile( object sender, RequestSendFileEventArgs e) { TraFransfersFileStart traFransfersFileStart = e.TraFransfersFileStart; BeginInvoke(new MethodInvoker(delegate() { FileTransfersItem item = fileTansfersContainer.AddItem( traFransfersFileStart.MD5, "接收文件", traFransfersFileStart.FileName, traFransfersFileStart.Image, traFransfersFileStart.Length, FileTransfersItemStyle.ReadyReceive); item.BaseColor = _baseColor; item.BorderColor = _borderColor; item.ProgressBarBarColor = _progressBarBarColor; item.ProgressBarBorderColor = _progressBarBorderColor; item.ProgressBarTextColor = _progressBarTextColor; item.Tag = e; item.SaveButtonClick += new EventHandler(ItemSaveButtonClick); item.SaveToButtonClick += new EventHandler(ItemSaveToButtonClick); item.RefuseButtonClick += new EventHandler(ItemRefuseButtonClick); })); AppendLog(string.Format( "请求发送文件 {0}。", traFransfersFileStart.FileName), true); }
private void ItemSaveToButtonClick(object sender, EventArgs e) { FileTransfersItem item = sender as FileTransfersItem; RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs; // FolderBrowserDialog fbd = new FolderBrowserDialog(); // if (fbd.ShowDialog() == DialogResult.OK) ////{ rse.Path = "E:\\CMSRec\\" + rse.TraFransfersFileStart.FileName.Substring(0, rse.TraFransfersFileStart.FileName.LastIndexOf(".")); DirectoryInfo dir = new DirectoryInfo(rse.Path); dir.Create(); AppendLog(string.Format( "同意接收文件 {0}。", rse.TraFransfersFileStart.FileName), false); ControlTag tag = new ControlTag( rse.TraFransfersFileStart.MD5, rse.TraFransfersFileStart.FileName, rse.RemoteIP); item.Tag = tag; item.Style = FileTransfersItemStyle.Receive; item.CancelButtonClick += new EventHandler(ItemCancelButtonClick); item.Start(); udpReceiveFile.AcceptReceive(rse); // } }
private void ItemRefuseButtonClick(object sender, EventArgs e) { FileTransfersItem item = sender as FileTransfersItem; RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs; rse.Cancel = true; fileTansfersContainer.RemoveItem(item); item.Dispose(); AppendLog(string.Format( "拒绝接收文件 {0}。", rse.TraFransfersFileStart.FileName), false); udpReceiveFile.AcceptReceive(rse); }
private void ItemSaveButtonClick(object sender, EventArgs e) { FileTransfersItem item = sender as FileTransfersItem; RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs; rse.Path = Application.StartupPath; AppendLog(string.Format( "同意接收文件 {0}。", rse.TraFransfersFileStart.FileName), false); ControlTag tag = new ControlTag( rse.TraFransfersFileStart.MD5, rse.TraFransfersFileStart.FileName, rse.RemoteIP); item.Tag = tag; item.Style = FileTransfersItemStyle.Receive; item.CancelButtonClick += new EventHandler(ItemCancelButtonClick); item.Start(); udpReceiveFile.AcceptReceive(rse); }
private void ItemSaveToButtonClick(object sender, EventArgs e) { FileTransfersItem item = sender as FileTransfersItem; RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs; FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { rse.Path = fbd.SelectedPath; AppendLog(string.Format( "同意接收文件 {0}。", rse.TraFransfersFileStart.FileName), false); ControlTag tag = new ControlTag( rse.TraFransfersFileStart.MD5, rse.TraFransfersFileStart.FileName, rse.RemoteIP); item.Tag = tag; item.Style = FileTransfersItemStyle.Receive; item.CancelButtonClick += new EventHandler(ItemCancelButtonClick); item.Start(); udpReceiveFile.AcceptReceive(rse); } }