Skip to content

Commit

Permalink
fixed error occurrence issue
Browse files Browse the repository at this point in the history
  • Loading branch information
박동준 committed Jun 27, 2020
1 parent d0e2602 commit 3018525
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
29 changes: 19 additions & 10 deletions NVidExtractor/Controls/ItemPanel.vb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Public Class ItemPanel
Public Selected As Boolean = False
Public DownBegan As Boolean = False '다운로드를 한번이라도 시작을 했는지
Public DownFinished As Boolean = False '다운로드를 완료한 상태인지
Public progMode As String = "" '현재 프로그램의 모드 (downloading, pause, finished, error)
Dim captionDownFinished As Boolean = False '자막 다운로드를 완료한 상태인지
Dim progMode As String = ""

Dim prevCBSelect() As Integer = {-1, -1} '비디오 info 리셋할때 콤보박스 선택을 보존하기 위해서

Expand Down Expand Up @@ -168,6 +168,7 @@ Public Class ItemPanel
ProgPanelOver.BackColor = MainPanel.BackColor
ProgLabel1.Text = ""
ProgLabel2.Text = ""
PauseResumeBT.Visible = False
End If
End Sub

Expand Down Expand Up @@ -320,14 +321,21 @@ Public Class ItemPanel
#Region "다운로드 작업"

Private Sub DownloadProgressChanged(ByVal sender As Object, ByVal e As FileDownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
progMode = "downloading"
SetProgBar(e.ProgressPercentage.ToString _
+ "% (" + FormatBytes(e.DownloadSpeedBytesPerSec) + "/s, " _
+ FormatBytes(e.BytesReceived) + "/" + FormatBytes(e.TotalBytesToReceive) _
+ ", " + DaysCalc(e.RemainingTimeSeconds) + " 남음)")
progPercent = e.ProgressPercentage

ProgPanelOver.Width = (e.ProgressPercentage / 100) * ProgPanel.Width
If e.ProgressPercentage >= 0 Then
progMode = "downloading"
SetProgBar(e.ProgressPercentage.ToString _
+ "% (" + FormatBytes(e.DownloadSpeedBytesPerSec) + "/s, " _
+ FormatBytes(e.BytesReceived) + "/" + FormatBytes(e.TotalBytesToReceive) _
+ ", " + DaysCalc(e.RemainingTimeSeconds) + " 남음)")
progPercent = e.ProgressPercentage

ProgPanelOver.Width = (e.ProgressPercentage / 100) * ProgPanel.Width
Else '다운로드 퍼센트값이 음수면 -> 비정상적인 다운로드
WC.CancelAsync()
progMode = "downloading"
forceReset(True)
SetProgBar("다운로드를 재시작하는 중...")
End If
End Sub

Public Sub StartDownload()
Expand Down Expand Up @@ -479,11 +487,13 @@ Public Class ItemPanel
End Sub

Public Sub PauseDown()
LogForm.addLog("다운로드 일시정지 (" + Name + ")")
Paused = True
WC.CancelAsync()
End Sub

Public Sub ResumeDown()
LogForm.addLog("다운로드 재개 (" + Name + ")")
Try
If Not WC.IsBusy Then '이미 바쁠때 (사용중일때) 가 아닐 때에만
WC.ResumeAsync()
Expand Down Expand Up @@ -651,7 +661,6 @@ Public Class ItemPanel
Catch ex As Exception

'MsgBox("오류 발생:" + vbCr + ex.Message, vbCritical)

LogForm.addLog("비디오인포 수집 중 오류 발생. (" + Me.Name + ")")
End Try

Expand Down
12 changes: 8 additions & 4 deletions NVidExtractor/Forms/Form1.vb
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,19 @@ Public Class Form1
ctrl.PauseDown()
Next

LogForm.addLog("다운로드 타이머 정지됨")
DownStartBT.Text = "다운로드 시작"
Else
downStarted = True

For Each ctrl As ItemPanel In ListPanel.Controls
If Not ctrl.WC.IsBusy And ctrl.Paused And ctrl.DownBegan Then
If Not ctrl.WC.IsBusy And ctrl.Paused And ctrl.DownBegan And Not ctrl.DownFinished Then
ctrl.ResumeDown()
End If
Next

DownCheckTimer.Start()

LogForm.addLog("다운로드 타이머 시작됨")
DownStartBT.Text = "일시 정지"
End If
End Sub
Expand Down Expand Up @@ -159,6 +160,7 @@ Public Class Form1
For Each ctrl As ItemPanel In ListPanel.Controls
'이미 시작하면 변경 못함
If ctrl.Selected And Not ctrl.WC.IsBusy And Not ctrl.DownBegan Then
LogForm.addLog("일괄 다운로드 설정적용 (" + ctrl.Name + ")")
ctrl.DownQuality = quality
ctrl.DownMode = downmode
ctrl.DownloadLoc = saveLocation
Expand Down Expand Up @@ -205,6 +207,7 @@ Public Class Form1
Next

For Each n As String In killlist
LogForm.addLog("완료 다운로드 삭제 (" + n + ")")
ListPanel.Controls.RemoveByKey(n)
Next
End If
Expand All @@ -225,6 +228,7 @@ Public Class Form1
Next

For Each n As String In killlist
LogForm.addLog("일괄 다운로드 삭제 (" + n + ")")
ListPanel.Controls.RemoveByKey(n)
Next
End If
Expand Down Expand Up @@ -267,8 +271,8 @@ Public Class Form1
Dim unfinished = 0

For Each ctrl As ItemPanel In ListPanel.Controls
'시작은 했는데 끝을 못본 놈이 있으면
If ctrl.WC.IsBusy Or (ctrl.DownBegan And Not ctrl.DownFinished) Then
'시작은 했는데 끝을 못본 놈이 있으면 (그리고 오류도 아님)
If ctrl.WC.IsBusy Or (ctrl.DownBegan And Not ctrl.DownFinished And Not ctrl.progMode = "error") Then
busycount += 1
End If

Expand Down
4 changes: 2 additions & 2 deletions NVidExtractor/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' 기본값으로 할 수 있습니다.
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.0.1.0")>
<Assembly: AssemblyFileVersion("1.0.1.0")>
<Assembly: AssemblyVersion("1.0.2.0")>
<Assembly: AssemblyFileVersion("1.0.2.0")>

0 comments on commit 3018525

Please sign in to comment.