Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
1.7.1版本,具体请看更新日志
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs4s committed Nov 19, 2016
1 parent 47fa3ba commit 606c09c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion BaiduPanDownload/Forms/AddDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void AddDownloadButton()
this.button2.Text = "添加下载";
return;
}
if (info.size <= Program.config.NetSpeed)
if (info.size <= Program.config.NetSpeed && info.isdir!=1)
{
MessageBox.Show("文件太小,无法下载!");
this.button2.Enabled = true;
Expand Down
5 changes: 5 additions & 0 deletions BaiduPanDownload/Forms/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ private void Login_Load(object sender, EventArgs e)
private void button1_Click(object sender, EventArgs e)
{
Regex rg = new Regex("(?<=(" + "access_token=" + "))[.\\s\\S]*?(?=(" + "&" + "))", RegexOptions.Multiline | RegexOptions.Singleline);
if (webBrowser1.Url == null)
{
MessageBox.Show("尚未加载完成!");
return;
}
string token = rg.Match(webBrowser1.Url.ToString()).Value;
if (token == string.Empty)
{
Expand Down
6 changes: 3 additions & 3 deletions BaiduPanDownload/Forms/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions BaiduPanDownload/Forms/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ void Upgraded()
try
{
JObject job = JObject.Parse(WebTool.GetHtml("http://www.mrs4s.top/api/update.json"));
//版本7
if ((int)job["Build"] > 7)
//版本8
if ((int)job["Build"] > 8)
{
DialogResult dr = MessageBox.Show((string)job["Message"] + "\r\n\r\n是否更新?", "发现更新", MessageBoxButtons.OKCancel);
if (dr == DialogResult.OK)
Expand Down Expand Up @@ -379,13 +379,13 @@ private void UpdateDownLoadList_Timer_Tick(object sender, EventArgs e)
item.SubItems.Add(Task.DownloadPath);
item.SubItems.Add((getSizeMB((long)Task.Speed) < 1 ? (Task.Speed / 1024) + "K/s" : getSizeMB((long)Task.Speed) + "M/s"));
item.SubItems.Add(Task.Percentage + "%");
item.SubItems.Add(Task.Downloading?"下载中":"停止中");
item.SubItems.Add(Task.Downloading?"下载中":Task.Completed?"下载完成":"暂停中");
DownloadListView.Items.Add(item);
continue;
}
DownloadListView.Items[Task.ID].SubItems[3].Text = (getSizeMB((long)Task.Speed) < 1 ? (Task.Speed / 1024) + "K/s" : getSizeMB((long)Task.Speed) + "M/s");
DownloadListView.Items[Task.ID].SubItems[4].Text = Task.Percentage + "%";
DownloadListView.Items[Task.ID].SubItems[5].Text = Task.Downloading ? "下载中" : "停止中";
DownloadListView.Items[Task.ID].SubItems[5].Text = Task.Downloading ? "下载中" : Task.Completed ? "下载完成" : "暂停中";
}
DownloadListView.EndUpdate();
return;
Expand Down
7 changes: 4 additions & 3 deletions BaiduPanDownload/HttpTool/Download/DownloadThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public DownloadThread()

Thread WorkThread;
HttpWebRequest Request;

HttpWebResponse Response;
public void Start()
{
try
Expand All @@ -57,7 +57,7 @@ public void Start()
}
Request = WebRequest.Create(DownloadUrl) as HttpWebRequest;
Request.AddRange(Block.From,Block.To);
HttpWebResponse Response = Request.GetResponse() as HttpWebResponse;
Response = Request.GetResponse() as HttpWebResponse;
if (!File.Exists(Path))
{
Console.WriteLine("出现错误: 本地数据文件不存在");
Expand Down Expand Up @@ -106,8 +106,9 @@ public void Stop()
{
return;
}
WorkThread.Abort();
Request?.Abort();
Response?.Close();
WorkThread.Abort();
}
}
}
7 changes: 4 additions & 3 deletions BaiduPanDownload/HttpTool/Download/HttpDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,13 @@ public void StopAndSave()
{
if (Threads != null)
{
foreach(var Thread in Threads)
Downloading = false;
Stoped = true;
CompletedThread = 0;
foreach (var Thread in Threads)
{
Thread.Stop();
}
Stoped = true;
Downloading = false;
Info.Save(DownloadPath + ".dcj");
}
}
Expand Down
7 changes: 7 additions & 0 deletions BaiduPanDownload/Managers/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ public TaskManager()
public event onTaskReloadEvent ReloadEvnet;
#endregion

bool Flag = false;

private void TaskManagerTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (Flag)
{
return;
}
if (GetDwonloadingTaskNum() < Program.config.TaskNum)
{
var WaitTask = TaskList.Where(v=> (!v.Value.Completed && !v.Value.Downloading && !v.Value.Stoped));
Expand All @@ -66,6 +71,7 @@ public void CreateDownloadTask(string DownloadUrl,string DownloadPath)
{
return;
}
Flag = true;
var Task=new HttpDownload
{
ID=TaskList.Count,
Expand All @@ -76,6 +82,7 @@ public void CreateDownloadTask(string DownloadUrl,string DownloadPath)
Task.CreateDataFile();
Program.config.SetDownloadInfo(DownloadPath+".dcj",false);
TaskList.Add(TaskList.Count,Task);
Flag = false;
}

/// <summary>
Expand Down

0 comments on commit 606c09c

Please sign in to comment.