-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUserSelector.vb
80 lines (75 loc) · 2.83 KB
/
UserSelector.vb
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
Imports System.ComponentModel
Public Class UserSelector
Private Distribution As String
Private SelectedUser As Integer
Private Sub UserSelector_Load(sender As Object, e As EventArgs) Handles Me.Load
LabelLoading.Visible = True
ComboBoxUser.Visible = False
ComboBoxUser.Items.Clear()
ButtonOK.Enabled = False
LoadPasswd(Distribution).ContinueWith(
Sub(t)
Invoke(Sub()
If Visible = False Then Exit Sub
Dim found = False
For Each item In t.Result
Dim i = ComboBoxUser.Items.Add(item)
If item.Uid = SelectedUser Then
ComboBoxUser.SelectedIndex = i
found = True
End If
Next
LabelLoading.Visible = False
ComboBoxUser.Visible = True
ButtonOK.Enabled = True
If Not found Then ComboBoxUser.Text = CStr(SelectedUser)
End Sub)
End Sub)
End Sub
Private Sub ButtonOK_Click(sender As Object, e As EventArgs) Handles ButtonOK.Click
Dim uid As Integer = 0, found = False
For Each item_ In ComboBoxUser.Items
Dim item = CType(item_, PasswdUserItem)
If item.Name = ComboBoxUser.Text Then
uid = item.Uid
found = True
Exit For
ElseIf IsNumeric(ComboBoxUser.Text) Then
Try
If item.Uid = CInt(ComboBoxUser.Text) Then
uid = item.Uid
ComboBoxUser.SelectedItem = item
found = True
Exit For
End If
Catch
End Try
End If
Next
If Not found Then
If Not IsNumeric(ComboBoxUser.Text) Then
Beep()
Exit Sub
End If
Try
uid = CInt(ComboBoxUser.Text)
Catch
Beep()
Exit Sub
End Try
End If
SelectedUser = uid
Close()
End Sub
Private Sub ButtonCancel_Click(sender As Object, e As EventArgs) Handles ButtonCancel.Click
Close()
End Sub
Public Shadows Function Show(Distribution As String, SelectedUser As Integer) As Integer?
Me.Distribution = Distribution
Me.SelectedUser = SelectedUser
If ShowDialog() = DialogResult.Cancel Then
Return Nothing
End If
Return Me.SelectedUser
End Function
End Class