Exemple #1
0
 private void FileReceived()
 {
     if (receiveFileProg != null)
     {
         this.BeginInvoke(new Action(() => { this.receiveFileProg.Close(); this.receiveFileProg = null; }));
     }
 }
Exemple #2
0
 private void FileSent()
 {
     if (sendFileProg != null)
     {
         this.BeginInvoke(new Action(() => { this.sendFileProg.Close(); this.sendFileProg = null; }));
     }
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        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));
            }
        }