Exemplo n.º 1
0
        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(ItemCancelButtonClick2);
            item.Start();

            udpReceiveFile.AcceptReceive(rse);
        }
Exemplo n.º 2
0
        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(ItemCancelButtonClick2);
                item.Start();

                udpReceiveFile.AcceptReceive(rse);
            }
        }
Exemplo n.º 3
0
        private void ItemSaveToButtonClick(object sender, EventArgs e)
        {
            FileTransfersItem item = sender as FileTransfersItem;
            RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs;
            if (item.Style == FileTransfersItemStyle.ReadyReceive)
            {
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    rse.Path = fbd.SelectedPath + "\\";
                    this.AppendSystemRtf(string.Format("同意接收文件 {0}。", rse.TraFransfersFileStart.FileName));
                    ControlTag tag = new ControlTag(
                         rse.TraFransfersFileStart.MD5,
                         rse.TraFransfersFileStart.FileName,
                         rse.RemoteIP);
                    item.Tag = tag;
                    item.Style = FileTransfersItemStyle.Cancel;
                    item.CancelButtonClick += new EventHandler(ItemCancelButtonClick2);
                    item.Start();
                    udpReceiveFile.AcceptReceive(rse);
                }
            }
            else
            {
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    rse.Path = fbd.SelectedPath + "\\";
                    this.AppendSystemRtf(string.Format("同意接收文件 {0}。", rse.ftpClient.fileTransfersItem.FileName));
                    ControlTag tag = new ControlTag(
                        rse.ftpClient.fileTransfersItem.Name,
                        rse.ftpClient.fileTransfersItem.FileName,
                        null);
                    tag.ftpClient = rse.ftpClient;
                    item.Tag = tag;
                    item.Style = FileTransfersItemStyle.Cancel;
                    DownloadFile downloadFile = new DownloadFile(this, rse.ftpClient);
                    downloadFile.receivePath = fbd.SelectedPath + "\\";
                    Thread pushThread = new Thread(downloadFile.GetFile);
                    pushThread.Start(rse.ftpClient.fileTransfersItem.Name);

                    CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                    fmsg.Type = MessageType.chat;
                    fmsg.To = TO_Jid;
                    fmsg.SetTag("m_type", 9);
                    fmsg.SetTag("FileName", rse.ftpClient.fileTransfersItem.FileName);
                    fmsg.From = XmppConn.MyJID;
                    fmsg.Body = "离线文件" + rse.ftpClient.fileTransfersItem.FileName + "开始接收。";
                    XmppConn.Send(fmsg);
                }
            }
        }