本例所有代码
Imports System
Imports System.Text
Public Class frmThunderClass frmThunder
Private _iStartMode As Integer '讯雷任务下载开始模式
Private ThunderEng As New THUNDERAGENTLib.Agent '创建讯雷调用对象
Private Sub frmThunder_Load()Sub frmThunder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnCancel_Click()Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Close()
End Sub
'开始下载任务
Private Sub btnStartDown_Click()Sub btnStartDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartDown.Click
Dim iOnlyFromOrigin, iOriginThreadCount As Integer
iOnlyFromOrigin = IIf(chkOnlyFromOrigin.Checked = True, 1, 0)
iOriginThreadCount = CInt(txtOriginThreadCounts.Text)
If chkDefault.Checked Then
iOriginThreadCount = -1
End If
ThunderEng.AddTask(txtURL.Text, txtSaveAsFileName.Text, txtSaveDir.Text, txtComment.Text, _
txtReferencePage.Text, _iStartMode, iOnlyFromOrigin, iOriginThreadCount)
ThunderEng.CommitTasks()
Timer1.Enabled = True
End Sub
Private Sub radMaual_Click()Sub radMaual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radMaual.Click, radImmediate.Click, radDefault.Click
Dim rad As RadioButton = CType(sender, RadioButton)
_iStartMode = CInt(rad.Tag)
End Sub
'当任务开始时定时查询任务下载信息
Private Sub Timer1_Tick()Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim sFileSize, sDownedSize, sStatus, sFileName, sPercent As String
Try
sStatus = ThunderEng.GetTaskInfo(txtURL.Text, "Status")
sFileSize = ThunderEng.GetTaskInfo(txtURL.Text, "FileSize")
sDownedSize = ThunderEng.GetTaskInfo(txtURL.Text, "CompletedSize")
sFileName = ThunderEng.GetTaskInfo(txtURL.Text, "FileName")
lblDownedSize.Text = String.Format(lblDownedSize.Tag, sDownedSize)
lblFileSize.Text = String.Format(lblFileSize.Tag, sFileSize)
lblTaskStatus.Text = String.Format(lblTaskStatus.Tag, sStatus)
lblFilename.Text = String.Format(lblFilename.Tag, sFileName)
sPercent = ThunderEng.GetTaskInfo(txtURL.Text, "Percent") '获取下载百分比
lblProgress.Text = String.Format(lblProgress.Tag, sPercent.Remove(3, Len(sPercent) - 3))
Catch ex As Exception
End Try
End Sub
Private Sub chkOnlyFromOrigin_CheckedChanged_1()Sub chkOnlyFromOrigin_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkOnlyFromOrigin.CheckedChanged
Panel1.Enabled = chkOnlyFromOrigin.Checked
End Sub
Private Sub GroupBox1_Enter()Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
End Class