コード例 #1
0
ファイル: PageBrowser.xaml.cs プロジェクト: xpA076/Socket
        private void ButtonDownload_Click(object sender, RoutedEventArgs e)
        {
            if (this.ListViewFile.SelectedIndex < 0)
            {
                return;
            }
            List <FileTask> fileTasks = new List <FileTask>();

            //var a = this.ListViewFile.SelectedItems;
            //var selected = fileClasses[this.ListViewFile.SelectedIndex];
            foreach (SocketFileInfo selected in this.ListViewFile.SelectedItems)
            {
                FileTask task = new FileTask
                {
                    Route       = SocketFactory.CurrentRoute.Copy(),
                    IsDirectory = selected.IsDirectory,
                    Type        = TransferType.Download,
                    RemotePath  = RemoteDirectory + selected.Name,
                    Length      = selected.Length,
                };
                if (task.IsDirectory)
                {
                    task.Length = FileTaskManager.GetDownloadDirectoryTaskLength(task);
                }
                fileTasks.Add(task);
            }

            DownloadConfirm(fileTasks);
        }
コード例 #2
0
ファイル: PageTransfer.xaml.cs プロジェクト: xpA076/Socket
        private void UpdateSpeed(object sender, EventArgs e)
        {
            FileTaskManager ftm     = sender as FileTaskManager;
            double          speed   = ftm.GetSpeed();
            int             seconds = (int)((ftm.TotalLength - ftm.TotalFinished) / speed);

            ProgressView.Speed         = Size2String(speed).PadLeft(18, ' ') + "/s";
            ProgressView.TimeRemaining = (seconds / 3600).ToString().PadLeft(10, ' ') +
                                         ": " + (seconds % 3600 / 60).ToString().PadLeft(2, '0') +
                                         ": " + (seconds % 60).ToString().PadLeft(2, '0');
        }
コード例 #3
0
        /// <summary>
        /// 向用户发送文件
        /// </summary>
        /// <param name="taskItem">文件列表</param>
        /// <param name="textMessage">附加的文本信息</param>
        /// <param name="isRtf">附加的文本信息是RTF格式</param>
        /// <param name="isHtml">附加的文本信息是HTML格式</param>
        /// <param name="remoteHost">远程主机</param>
        public void PerformSendFile(FileTaskItem[] taskItem, string textMessage, bool isRtf, bool isHtml, Host remoteHost)
        {
            FileTaskInfo task = new FileTaskInfo(FileTransferDirection.Send, 0ul, remoteHost);

            task.TaskList.AddRange(taskItem);

            task.PackageID = Commander.SendTextMessage(remoteHost, textMessage, isHtml, isRtf, false, false, false, false, taskItem.BuildTaskMessage());
            if (task.PackageID > 0)
            {
                FileTaskManager.AddSendTask(task);
            }
        }
コード例 #4
0
ファイル: PageTransfer.xaml.cs プロジェクト: xpA076/Socket
        private void UpdateProgress(object sender, EventArgs e)
        {
            FileTaskManager ftm = sender as FileTaskManager;
            long            cf  = ftm.CurrentFinished;
            long            cl  = ftm.CurrentLength;
            long            tf  = ftm.TotalFinished;
            long            tl  = ftm.TotalLength;

            if (showCurrentPercent)
            {
                if (cl == 0)
                {
                    ProgressView.CurrentProgress = "--";
                }
                else
                {
                    ProgressView.CurrentProgress = ((double)cf * 100 / cl).ToString("0.00").PadLeft(16, ' ') + " %";
                }
            }
            else
            {
                ProgressView.CurrentProgress = Size2String(cf).PadLeft(12, ' ') + "/" + Size2String(cl);
            }
            if (showTotalPercent)
            {
                if (tl == 0)
                {
                    ProgressView.TotalProgress = "--";
                }
                else
                {
                    ProgressView.TotalProgress = ((double)tf * 100 / tl).ToString("0.00").PadLeft(16, ' ') + " %";
                }
            }
            else
            {
                ProgressView.TotalProgress = Size2String(tf).PadLeft(12, ' ') + "/" + Size2String(tl);
            }
            if (tf == tl)
            {
                ProgressView.TimeRemaining = "        00: 00: 00";
            }
        }