• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamephpguicwindows翻訳pythonomegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

将棋ウォーズ棋譜を検索条件を指定して一括でダウンロードする。


コミットメタ情報

リビジョン6 (tree)
日時2015-01-27 11:57:09
作者bellyoshi

ログメッセージ

キャンセル実装

変更サマリ

差分

--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/downloder.vb (revision 5)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/downloder.vb (revision 6)
@@ -13,6 +13,7 @@
1313 Public Property DownLoadsListsCount As Integer
1414 Public Property DownLoadIndex As Integer
1515 Public Property IsDownloading As Boolean = False
16+ Public Property IsComplete As Boolean = False
1617
1718 Private Sub New()
1819 End Sub
@@ -32,6 +33,7 @@
3233 ListPageReadReq()
3334 _backGroudWoker.ReportProgress(0, "ダウンロード開始")
3435 DownLoadsReq()
36+ IsComplete = True
3537 _backGroudWoker.ReportProgress(100, "ダウンロード終了")
3638 End Sub
3739 Private Sub LoginReq()
@@ -70,6 +72,9 @@
7072 DownLoadIndex = 0
7173 IsDownloading = True
7274 For Each link As aLink In downloadLists
75+ If backGroudWoker.CancellationPending Then
76+ Throw New CancelException
77+ End If
7378 _backGroudWoker.ReportProgress(DownLoadIndex / DownLoadsListsCount, String.Format("{0}", link.Text))
7479 DownLoadOneLink(wc, link, dirfullpath)
7580 DownLoadIndex += 1
--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/CancelException.vb (nonexistent)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/CancelException.vb (revision 6)
@@ -0,0 +1,4 @@
1+Public Class CancelException
2+ Inherits Exception
3+
4+End Class
--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmProgress.Designer.vb (revision 5)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmProgress.Designer.vb (revision 6)
@@ -26,11 +26,12 @@
2626 Me.pbProgress = New System.Windows.Forms.ProgressBar()
2727 Me.lblKifuFileName = New System.Windows.Forms.Label()
2828 Me.BackgroundWorker1 = New System.ComponentModel.BackgroundWorker()
29+ Me.btnOk = New System.Windows.Forms.Button()
2930 Me.SuspendLayout()
3031 '
3132 'btnCancel
3233 '
33- Me.btnCancel.Location = New System.Drawing.Point(253, 70)
34+ Me.btnCancel.Location = New System.Drawing.Point(172, 69)
3435 Me.btnCancel.Name = "btnCancel"
3536 Me.btnCancel.Size = New System.Drawing.Size(75, 23)
3637 Me.btnCancel.TabIndex = 0
@@ -55,12 +56,24 @@
5556 'BackgroundWorker1
5657 '
5758 Me.BackgroundWorker1.WorkerReportsProgress = True
59+ Me.BackgroundWorker1.WorkerSupportsCancellation = True
5860 '
61+ 'btnOk
62+ '
63+ Me.btnOk.Location = New System.Drawing.Point(253, 69)
64+ Me.btnOk.Name = "btnOk"
65+ Me.btnOk.Size = New System.Drawing.Size(75, 23)
66+ Me.btnOk.TabIndex = 3
67+ Me.btnOk.Text = "Ok"
68+ Me.btnOk.UseVisualStyleBackColor = True
69+ Me.btnOk.Visible = False
70+ '
5971 'frmProgress
6072 '
6173 Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
6274 Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
6375 Me.ClientSize = New System.Drawing.Size(340, 101)
76+ Me.Controls.Add(Me.btnOk)
6477 Me.Controls.Add(Me.lblKifuFileName)
6578 Me.Controls.Add(Me.pbProgress)
6679 Me.Controls.Add(Me.btnCancel)
@@ -73,4 +86,5 @@
7386 Friend WithEvents pbProgress As System.Windows.Forms.ProgressBar
7487 Friend WithEvents lblKifuFileName As System.Windows.Forms.Label
7588 Friend WithEvents BackgroundWorker1 As System.ComponentModel.BackgroundWorker
89+ Friend WithEvents btnOk As System.Windows.Forms.Button
7690 End Class
--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmProgress.vb (revision 5)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmProgress.vb (revision 6)
@@ -3,7 +3,11 @@
33 Friend Property downloder As downloder
44
55 Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
6- downloder.Start()
6+ Try
7+ downloder.Start()
8+ Catch ex As CancelException
9+ e.Cancel = True
10+ End Try
711 End Sub
812
913 Private Sub frmProgress_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
@@ -19,6 +23,18 @@
1923 pbProgress.Maximum = downloder.DownLoadsListsCount
2024 pbProgress.Value = downloder.DownLoadIndex
2125 End If
26+ If downloder.IsComplete Then
27+ btnOk.Visible = True
28+ btnCancel.Visible = False
29+ End If
2230 End Sub
2331
32+ Private Sub btnOk_Click(sender As System.Object, e As System.EventArgs) Handles btnOk.Click
33+ Me.Close()
34+ End Sub
35+
36+ Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
37+ BackgroundWorker1.CancelAsync()
38+ Me.Close()
39+ End Sub
2440 End Class
\ No newline at end of file