示例#1
0
        public UploadInfo(WinFileSystem win, ClientInfo controlledClient, string localPath, FileTransmissionInfo trans)
        {
            LocalPath = localPath;
            File      = trans.File;
            ID        = trans.ID;
            Dialog    = new ProgressDialog(win)
            {
                Message = "正在上传" + File.Name
            };
            Dialog.Value   = 0;
            Dialog.Minimum = 0;
            Dialog.Maximum = trans.File.Length;
            Dialog.Title   = "上传";
            Dialog.Cancle += (p1, p2) =>
            {
                Canceled = true;
                Dispose();

                Telnet.Instance.Send(new CommandBody(File_AskForCancelUpload, Global.CurrentClient.ID, controlledClient.ID, ID));
            };
            Dialog.Closed += (p1, p2) =>
            {
                if (Dialog.Canceled == false)
                {
                    win.RefreshFolder();
                }
            };

            Stream = System.IO.File.OpenRead(localPath);
        }
示例#2
0
        public DownloadingInfo(WinFileSystem win, ClientInfo controlledClient, string localPath, FileTransmissionInfo download)
        {
            LocalPath = localPath;
            File      = download.File;
            ID        = download.ID;
            Dialog    = new ProgressDialog(win)
            {
                Message = "正在下载" + File.Name
            };
            Dialog.Value   = 0;
            Dialog.Minimum = 0;
            Dialog.Maximum = 1;
            Dialog.Title   = "下载";
            Dialog.Cancle += (p1, p2) =>
            {
                Canceled = true;
                Dispose(true);

                Telnet.Instance.Send(new CommandBody(File_AskForCancelDownload, Global.CurrentClient.ID, controlledClient.ID, ID));
            };
            Dialog.Closed += (p1, p2) =>
            {
                if (Dialog.Canceled == false)
                {
                    win.RefreshFolder();
                }
            };

            Stream = System.IO.File.OpenWrite(localPath);
            Stream.SetLength(File.Length);
        }
示例#3
0
        public void StartNew(WinFileSystem win, ClientInfo client, FileFolderInfo selectedFile)
        {
            ControlledClient = client;
            string path = FileSystemDialog.GetSaveFile(null, true, false, selectedFile.Name);

            if (path != null)
            {
                FileTransmissionInfo trans = new FileTransmissionInfo()
                {
                    File = selectedFile
                };
                try
                {
                    download = new DownloadingInfo(win, client, path, trans);
                }
                catch (Exception ex)
                {
                    TaskDialog.ShowException(ex, "建立本地文件失败!");
                    return;
                }
                Telnet.Instance.FileSystemDownloadErrorReceived += FileSystemDownloadErrorReceived;
                Telnet.Instance.FileSystemDownloadPartReceived  += FileSystemDownloadPartReceived;

                Telnet.Instance.Send(new CommandBody(
                                         File_AskForDownloading, Global.CurrentClient.ID, client.ID, trans));

                download.Dialog.ShowDialog();
            }
        }
示例#4
0
        public void StartNew(WinFileSystem win, ClientInfo client, string remoteFolderPath)
        {
            this.win         = win;
            ControlledClient = client;
            string path = FileSystemDialog.GetOpenFile();

            if (path != null)
            {
                var trans = new FileTransmissionInfo
                {
                    File = new FileFolderInfo()
                    {
                        Path = Path.Combine(remoteFolderPath, Path.GetFileName(path)), Length = new FileInfo(path).Length
                    }
                };
                currentUpload = new UploadInfo(win, ControlledClient, path, trans);

                Telnet.Instance.Send(new CommandBody(File_AskForStartUpload, Global.CurrentClient.ID, ControlledClient.ID, trans));
            }

            Telnet.Instance.FileSystemPrepareForUploadingReceived += FileSystemPrepareForUploadingReceived;;
        }