-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrmEditPlayers.vb
More file actions
190 lines (136 loc) · 5.64 KB
/
Copy pathfrmEditPlayers.vb
File metadata and controls
190 lines (136 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
Option Strict Off
Option Explicit On
Friend Class frmEditPlayers
Inherits Form
' -------------------------------------------------------------------------------
' Dart Scorekeeper
'
' Written by Matthew Monroe
' Started in July 1999
' Ported to .NET in 2011
'
' E-mail: monroem@gmail.com or alchemistmatt@yahoo.com
' Repository: https://github.com/alchemistmatt
'
' -------------------------------------------------------------------------------
'
' Licensed under the Apache License, Version 2.0; you may not use this file except
' in compliance with the License. You may obtain a copy of the License at
' http://www.apache.org/licenses/LICENSE-2.0
Private mPlayerCountSave As Short
Private mPlayersSave() As String
Private mPlayerListChangedLocal As Boolean
Public ReadOnly Property PlayerListChanged() As Boolean
Get
Return mPlayerListChangedLocal
End Get
End Property
Private Sub EditPlayer()
Try
If lstPlayers.SelectedIndex >= 0 Then
frmEditPlayerDialog.PlayerName = CStr(lstPlayers.SelectedItem)
frmEditPlayerDialog.ShowDialog()
If frmEditPlayerDialog.PlayerNameUpdated Then
' Update list
lstPlayers.SelectedItem = frmEditPlayerDialog.PlayerName
mPlayerListChangedLocal = True
End If
frmEditPlayerDialog.Close()
End If
Catch ex As Exception
HandleException("frmEditPlayers.EditPlayer", ex)
End Try
End Sub
Private Sub SaveChanges()
Dim x As Short
Try
' Save Changes
If mPlayerListChangedLocal Then
ReDim glbPlayers(MAX_PLAYER_COUNT)
For x = 0 To lstPlayers.Items.Count - 1
glbPlayers(x) = CStr(lstPlayers.Items(x))
Next x
glbPlayerCount = lstPlayers.Items.Count
frmOptions.WriteIniFile(False)
End If
Catch ex As Exception
HandleException("frmEditPlayers.SaveChanges", ex)
End Try
End Sub
Private Sub cmdAddPlayer_Click(eventSender As Object, eventArgs As EventArgs) Handles cmdAddPlayer.Click
Try
frmEditPlayerDialog.PlayerName = String.Empty
frmEditPlayerDialog.ShowDialog()
If frmEditPlayerDialog.PlayerNameUpdated Then
' Add to list
lstPlayers.Items.Add(frmEditPlayerDialog.PlayerName)
mPlayerListChangedLocal = True
End If
frmEditPlayerDialog.Close()
Catch ex As Exception
HandleException("frmEditPlayers.cmdAddPlayer_click", ex)
End Try
End Sub
Private Sub cmdCancel_Click(eventSender As Object, eventArgs As EventArgs) Handles cmdCancel.Click
Dim eResponse As DialogResult
Dim x As Short
Try
If mPlayerListChangedLocal Then
' Abort changes by copying data from save array
eResponse = MessageBox.Show("Are you sure you want to cancel any changes made?", "Cancel", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
If eResponse <> DialogResult.Yes Then
Exit Sub
End If
ReDim glbPlayers(MAX_PLAYER_COUNT)
For x = 0 To MAX_PLAYER_COUNT
glbPlayers(x) = mPlayersSave(x)
Next x
glbPlayerCount = mPlayerCountSave
End If
Me.Close()
Catch ex As Exception
HandleException("frmEditPlayers.cmdCancel_Click", ex)
End Try
End Sub
Private Sub cmdClose_Click(eventSender As Object, eventArgs As EventArgs) Handles cmdClose.Click
SaveChanges()
Me.Close()
End Sub
Private Sub cmdEdit_Click(eventSender As Object, eventArgs As EventArgs) Handles cmdEdit.Click
EditPlayer()
End Sub
Private Sub cmdRemove_Click(eventSender As Object, eventArgs As EventArgs) Handles cmdRemove.Click
Try
If lstPlayers.SelectedIndex >= 0 Then
lstPlayers.Items.RemoveAt(lstPlayers.SelectedIndex)
mPlayerListChangedLocal = True
End If
Application.DoEvents()
Catch ex As Exception
HandleException("frmEditPlayers.cmdRemove_click", ex)
End Try
End Sub
Private Sub frmEditPlayers_Load(eventSender As Object, eventArgs As EventArgs) Handles MyBase.Load
Dim x As Short
Try
' Position form in window
Me.Left = (Screen.PrimaryScreen.Bounds.Width - Me.Width) / 2
Me.Top = (Screen.PrimaryScreen.Bounds.Height - Me.Height) / 3
ReDim mPlayersSave(MAX_PLAYER_COUNT)
For x = 0 To glbPlayerCount
mPlayersSave(x) = glbPlayers(x)
Next x
mPlayerCountSave = glbPlayerCount
lstPlayers.Items.Clear()
For x = 0 To glbPlayerCount
lstPlayers.Items.Add(glbPlayers(x))
Next x
mPlayerListChangedLocal = False
Catch ex As Exception
HandleException("frmEditPlayers.Form_Load", ex)
End Try
End Sub
Private Sub lstPlayers_DoubleClick(eventSender As Object, eventArgs As EventArgs) Handles lstPlayers.DoubleClick
EditPlayer()
End Sub
End Class