Beispiel #1
0
 private void FilelistView_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (FilelistView.SelectedIndices.Count <= 0)
     {
         return;
     }
     if (Fileinfo.ContainsKey(FilelistView.SelectedItems[0].Text))
     {
         DiskFileInfo info = Fileinfo[FilelistView.SelectedItems[0].Text];
         if (info.isdir == 1)
         {
             Path += "/" + FilelistView.SelectedItems[0].Text;
             new Thread(this.updateFileList).Start(HomePath + Path);
             return;
         }
         if (info.getSuffix() == "mp4" || info.getSuffix() == "mkv")
         {
             new Video
             {
                 info = info
             }.Show();
             return;
         }
         new AddDownload(this, info).ShowDialog();
     }
 }
Beispiel #2
0
 void updateFileList(object path)
 {
     try
     {
         Path_Lab.Text = "当前路径:" + path.ToString().Replace("apps", "我的应用数据");
         var jobj = JObject.Parse(WebTool.GetHtml($"https://pcs.baidu.com/rest/2.0/pcs/file?method=list&access_token={Program.config.Access_Token}&path=" + Uri.EscapeDataString($"{path.ToString()}")));
         FilelistView.BeginUpdate();
         FilelistView.Items.Clear();
         Fileinfo.Clear();
         foreach (JObject job in jobj["list"])
         {
             DiskFileInfo fileinfo = JsonConvert.DeserializeObject <DiskFileInfo>(job.ToString());
             FilelistView.Items.Add(fileinfo.getName());
             this.Fileinfo.Add(fileinfo.getName(), fileinfo);
             if (fileinfo.isdir == 1)
             {
                 setEndItemImageKey("Dir.png");
             }
             else
             {
                 setEndItemImageKey(getIconImage(fileinfo.getSuffix()));
             }
         }
         FilelistView.EndUpdate();
     }
     catch (Exception ex)
     {
         MessageBox.Show("更新文件列表时遇到意外的错误: " + ex.ToString());
     }
     Info_Lab.Text = "等待中...";
 }
Beispiel #3
0
 public void AddFile(DiskFileInfo info)
 {
     if (!CopyList.Contains(info))
     {
         CopyList.Add(info);
     }
 }
Beispiel #4
0
 public void AddDownloadFile(DiskFileInfo info, string DownloadPath, string FileName)
 {
     if (DownloadTaskInfo.ContainsKey(FileName))
     {
         MessageBox.Show("警告:任务已存在");
     }
     TaskManager.GetTastManager.CreateDownloadTask($"https://www.baidupcs.com/rest/2.0/pcs/stream?method=download&access_token={Program.config.Access_Token}&path={info.path}", DownloadPath, FileName, 8);
 }
Beispiel #5
0
        private void 添加到下载列表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!Fileinfo.ContainsKey(FilelistView.SelectedItems[0].Text))
            {
                MessageBox.Show("出现了未知错误! 请刷新重试");
                return;
            }
            DiskFileInfo info = Fileinfo[FilelistView.SelectedItems[0].Text];

            //string url = string.Format("https://www.baidupcs.com/rest/2.0/pcs/stream?method=download&access_token={0}&path={1}", Program.config.Access_Token, info.path);
            new AddDownload(this, info).ShowDialog();
        }
        public SuperDownload CreateSuperDownload(DiskFileInfo info, string DownloadPath, string FileName, int SubTaskNum)
        {
            int      id   = Tasks.Count;
            HttpTask task = new SuperDownload
            {
                ID         = id,
                Info       = info,
                FilePath   = DownloadPath,
                FileName   = FileName,
                SubTaskNum = SubTaskNum
            };

            Tasks.Add(id, task);
            return(task as SuperDownload);
        }
Beispiel #7
0
 public void AddDownloadFile(DiskFileInfo info, string DownloadPath, string FileName, bool SuperDownload)
 {
     if (DownloadTaskInfo.ContainsKey(FileName))
     {
         MessageBox.Show("警告:任务已存在");
     }
     if (SuperDownload)
     {
         TaskManager.GetTastManager.CreateSuperDownload(info, DownloadPath, FileName, Program.config.NetSpeed / 10);
     }
     else
     {
         TaskManager.GetTastManager.CreateDownloadTask($"https://www.baidupcs.com/rest/2.0/pcs/stream?method=download&access_token={Program.config.Access_Token}&path=" + Uri.EscapeDataString($"{info.path}"), DownloadPath, FileName, Program.config.ThreadNum);
     }
 }
Beispiel #8
0
 private void  除ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < FilelistView.SelectedIndices.Count; i++)
     {
         if (!Fileinfo.ContainsKey(FilelistView.SelectedItems[i].Text))
         {
             MessageBox.Show("出现了未知错误! 请刷新重试");
             return;
         }
         DiskFileInfo info = Fileinfo[FilelistView.SelectedItems[i].Text];
         if (WebTool.GetHtml(string.Format("https://pcs.baidu.com/rest/2.0/pcs/file?method=delete&access_token={0}&path={1}", Program.config.Access_Token, info.path)).Contains("ERROR"))
         {
             MessageBox.Show("删除失败");
             return;
         }
     }
     new Thread(updateFileList).Start(HomePath + Path);
 }
Beispiel #9
0
        private void 文件信息ToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            if (FilelistView.SelectedIndices.Count <= 0)
            {
                MessageBox.Show("你没有选中任何文件哦");
                return;
            }
            if (!Fileinfo.ContainsKey(FilelistView.SelectedItems[0].Text))
            {
                MessageBox.Show("出现了未知错误! 请刷新重试");
                return;
            }
            DiskFileInfo info = Fileinfo[FilelistView.SelectedItems[0].Text];

            MessageBox.Show(
                "文件名: " + info.getName() + Environment.NewLine +
                "文件大小: " + (getSizeGB(info.size) < 1 ? getSizeMB(info.size) + " MB" : getSizeGB(info.size) + " GB") + Environment.NewLine +
                "文件路径: " + info.path.Replace("apps", "我的应用数据") + Environment.NewLine +
                "是不是文件夹: " + (info.isdir == 1?"是":"不是")
                , "文件信息"
                );
        }
        private List <DiskFileInfo> ConvertToDiskFile(List <FileInfo> fileList)
        {
            List <DiskFileInfo> diskFileList = new List <DiskFileInfo>();
            DiskFileInfo        diskFileInfo;
            int terminaNumber = 1;
            int index         = uDiskDriver.IndexOf("_");

            if (index > 0)
            {
                //terminaNumber = uDiskDriver.Substring(index - 1, 1).ToInt();
            }
            foreach (FileInfo fileinfo in fileList)
            {
                diskFileInfo = new DiskFileInfo();
                diskFileInfo.TerminalNumber = terminaNumber;
                diskFileInfo.DownloadTime   = fileinfo.CreationTime;
                diskFileInfo.FileSize       = fileinfo.Length;
                diskFileInfo.FileName       = fileinfo;
                diskFileList.Add(diskFileInfo);
            }
            return(diskFileList);
        }
Beispiel #11
0
 public void AddDownloadFile(DiskFileInfo info, string DownloadPath, string FileName)
 {
     TaskManager.GetTastManager.CreateDownloadTask($"https://www.baidupcs.com/rest/2.0/pcs/stream?method=download&access_token={Program.config.Access_Token}&path=" + Uri.EscapeDataString(info.path), DownloadPath + "\\" + FileName);
 }