Esempio n. 1
0
        void CurrentTransferQueue_QueueAdded(object sender, TransferQueue.QueueEventArgs e)
        {
            var tq = sender as TransferQueue;

            this.Invoke(new aaaSoft.Helpers.ThreadHelper.UnnamedDelegate(delegate
            {
                btnStartQueue.Enabled = tq.GetQueueItemCount() != 0 && tq.QueueState != TransferQueue.TransferQueueState.Running;

                Int32 itemIndex = lvQueue.Items.Count - CurrentTransferQueue.GetTransferQueueItemBackIndex(e.QueueItem);
                if (itemIndex > lvQueue.Items.Count || itemIndex < 0)
                {
                    return;
                }

                var item        = e.QueueItem;
                var newLvi      = lvQueue.Items.Insert(itemIndex, "");
                var ftpClient   = item.FtpClient;
                var ftpSiteData = (FtpSiteData)ftpClient.Tag;

                if (item.Type == TransferQueueItem.TransferQueueItemTypeEnum.Download)
                {
                    newLvi.Text = item.RemoteBaseFile.FullName;
                    newLvi.SubItems.Add(item.LocalPath);
                    if (item.RemoteBaseFile.IsFolder)
                    {
                        newLvi.SubItems.Add("<文件夹>");
                    }
                    else
                    {
                        newLvi.SubItems.Add(storageUnitStringConverting.GetString(item.RemoteBaseFile.Length, 2, false) + "B");
                    }

                    newLvi.SubItems.Add(String.Format("从 {0} 下载", ftpSiteData.DisplayName));
                    newLvi.Tag      = item;
                    newLvi.ImageKey = "Download";
                }
                else if (item.Type == TransferQueueItem.TransferQueueItemTypeEnum.Upload)
                {
                    newLvi.Text = item.LocalPath;
                    newLvi.SubItems.Add(item.RemotePath);
                    if (File.Exists(item.LocalPath))
                    {
                        var fileInfo = new FileInfo(item.LocalPath);
                        newLvi.SubItems.Add(storageUnitStringConverting.GetString(fileInfo.Length, 2, false) + "B");
                    }
                    else if (Directory.Exists(item.LocalPath))
                    {
                        var folderInfo = new DirectoryInfo(item.LocalPath);
                        newLvi.SubItems.Add("<文件夹>");
                    }
                    newLvi.SubItems.Add(String.Format("上传到 {0}", ftpSiteData.DisplayName));
                    newLvi.Tag      = item;
                    newLvi.ImageKey = "Upload";
                }
                else if (item.Type == TransferQueueItem.TransferQueueItemTypeEnum.Delete)
                {
                    newLvi.Text = item.RemoteBaseFile.Name;
                    newLvi.SubItems.Add(item.RemotePath);
                    if (item.RemoteBaseFile.IsFolder)
                    {
                        newLvi.SubItems.Add("<文件夹>");
                    }
                    else
                    {
                        newLvi.SubItems.Add(storageUnitStringConverting.GetString(item.RemoteBaseFile.Length, 2, false) + "B");
                    }
                    newLvi.SubItems.Add(String.Format("从 {0} 删除", ftpSiteData.DisplayName));
                    newLvi.Tag      = item;
                    newLvi.ImageKey = "Delete";
                }
            }));
        }