• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

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

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

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


コミットメタ情報

リビジョン17 (tree)
日時2015-02-01 16:51:46
作者bellyoshi

ログメッセージ

変更サマリ

差分

--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/InvalidException.vb (nonexistent)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/InvalidException.vb (revision 17)
@@ -0,0 +1,20 @@
1+Public Class InvalidException
2+ Inherits Exception
3+
4+ Public Property DisplayMessage As String
5+ Public Property Controls As Control()
6+
7+ Public Sub New(ByVal message As String)
8+ Me.New(message, New Control() {})
9+ End Sub
10+
11+ Public Sub New(ByVal message As String, ByVal control As Control)
12+ Me.New(message, New Control() {control})
13+ End Sub
14+
15+ Public Sub New(ByVal message As String, ByVal controls() As Control)
16+ Me.DisplayMessage = message
17+ Me.Controls = controls
18+ End Sub
19+
20+End Class
--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/FormValidateUtil.vb (nonexistent)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/FormValidateUtil.vb (revision 17)
@@ -0,0 +1,29 @@
1+Public Class FormValidateUtil
2+
3+ Public Shared Property ErrorColor As Color = Color.Red
4+ Public Shared Property NormalColor As Color = Color.White
5+
6+ Public Shared Sub FormClear(ByVal form As Form)
7+ For Each c As Control In form.Controls
8+ If c.BackColor = ErrorColor Then
9+ c.BackColor = NormalColor
10+ End If
11+ Next
12+ End Sub
13+
14+ Public Shared Sub MessageShow(ByVal inputError As InvalidException)
15+
16+ For Each c As Control In inputError.Controls
17+ If Not c.BackColor = ErrorColor Then
18+ NormalColor = c.BackColor
19+ End If
20+ c.BackColor = ErrorColor
21+ Next
22+ MessageBox.Show(inputError.DisplayMessage, "入力エラー", MessageBoxButtons.OK, MessageBoxIcon.Warning)
23+ If 1 <= inputError.Controls.Length Then
24+ inputError.Controls(0).Focus()
25+ End If
26+
27+ End Sub
28+
29+End Class
--- ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmCondtion.vb (revision 16)
+++ ShogiWarsKifuDownloader/ShogiWarsKifuDownloader/frmCondtion.vb (revision 17)
@@ -1,35 +1,30 @@
11 Public Class frmCondtion
22
3+ Private Sub FormValidate()
34
4- Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
5-
65 If chk10min.Checked AndAlso
7- txt10minSaveDirectory.Text = String.Empty Then
8- MessageBox.Show("保存先を選択してください。")
9- Exit Sub
6+ txt10minSaveDirectory.Text = String.Empty Then
7+ Throw New InvalidException("保存先を選択してください。", txt10minSaveDirectory)
108 End If
119
1210 If chk3min.Checked AndAlso
1311 txt3minSaveDirectory.Text = String.Empty Then
14- MessageBox.Show("保存先を選択してください。")
15- Exit Sub
12+ Throw New InvalidException("保存先を選択してください。", txt3minSaveDirectory)
1613 End If
1714
1815 If chk10sec.Checked AndAlso
1916 txt10secSaveDirectory.Text = String.Empty Then
20- MessageBox.Show("保存先を選択してください。")
21- Exit Sub
17+ Throw New InvalidException("保存先を選択してください。", txt10secSaveDirectory)
2218 End If
2319
2420 If chkAnimal.Checked AndAlso
2521 txtAnimalSaveDirectory.Text = String.Empty Then
26- MessageBox.Show("保存先を選択してください。")
27- Exit Sub
22+ Throw New InvalidException("保存先を選択してください。", txtAnimalSaveDirectory)
2823 End If
2924
3025 If txtName1.Text = String.Empty AndAlso
3126 txtName2.Text = String.Empty Then
32- MessageBox.Show("対局者をどちらか入力してください。")
27+ Throw New InvalidException("対局者をどちらか入力してください。", New Control() {txtName1, txtName2})
3328 End If
3429
3530 If Not chk10min.Checked AndAlso
@@ -36,9 +31,25 @@
3631 Not chk3min.Checked AndAlso
3732 Not chk10sec.Checked AndAlso
3833 Not chkAnimal.Checked Then
39- MessageBox.Show("対局モードを選択してください。")
34+ Throw New InvalidException("対局モードを選択してください。",
35+ New Control() {chk10min,
36+ chk3min,
37+ chk10sec,
38+ chkAnimal})
4039 End If
4140
41+ End Sub
42+
43+ Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
44+
45+ Try
46+ FormValidateUtil.FormClear(Me)
47+ FormValidate()
48+ Catch ex As InvalidException
49+ FormValidateUtil.MessageShow(ex)
50+ Exit Sub
51+ End Try
52+
4253 Dim frm As New frmProgress
4354 Dim downloder As New downloder(
4455 frm.BackgroundWorker1,