private void FileReceived() { if (receiveFileProg != null) { this.BeginInvoke(new Action(() => { this.receiveFileProg.Close(); this.receiveFileProg = null; })); } }
private void FileSent() { if (sendFileProg != null) { this.BeginInvoke(new Action(() => { this.sendFileProg.Close(); this.sendFileProg = null; })); } }
private void FileAccept(string remoteHostname, string filePath, IPAddress remoteIP) { //MessageBox.Show(String.Format("{0}[{2}] accept your file sending request:{1}", remoteHostname, filePath, remoteIP.ToString())); string filename = Path.GetFileName(filePath); this.sendFileProg = new FileTransWindow("Sending " + filename); isSendFileProgReady = false; sendFileProgthread = new Thread(new ThreadStart(sendFileProgEntry)); sendFileProgthread.Start(); while (!isSendFileProgReady) { ; } Messenger.SendFile(filePath, remoteIP); }
private void FileSendReq(string remoteHostname, string remotefilePath, IPAddress remoteIP) { string filepath = ""; string filename = Path.GetFileName(remotefilePath); try { if (MessageBox.Show(string.Format("User {0} wants to send file {1} to you.", remoteHostname, filename), "Notice", MessageBoxButtons.YesNo) == DialogResult.Yes) { FolderBrowserDialog savePathDialog = new FolderBrowserDialog(); savePathDialog.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); savePathDialog.InitializeLifetimeService(); DialogResult result = STAShowDialog(savePathDialog); if (result == DialogResult.OK) { filepath = savePathDialog.SelectedPath; this.receiveFileProg = new FileTransWindow("Receiving " + filename); isRecvFileProgReady = false; recvFileProgthread = new Thread(new ThreadStart(recvFileProgEntry)); recvFileProgthread.Start(); while (!isRecvFileProgReady) { ; } Messenger.RecFile(filepath + "\\", remotefilePath, remoteIP); } else { Messenger.SendFileNotice(UdpDatagramType.FRefuse, remotefilePath, remoteIP); } } else { Messenger.SendFileNotice(UdpDatagramType.FRefuse, remotefilePath, remoteIP); } } catch (Exception e) { MessageBox.Show(string.Format(e.Message)); } }