-
Notifications
You must be signed in to change notification settings - Fork 4
/
FixedHostUI.vb
57 lines (48 loc) · 1.82 KB
/
FixedHostUI.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
Imports JHSoftware.SimpleDNS.Plugin
Public Class FixedHostUI
Public Overrides Sub LoadData(ByVal config As String)
If config Is Nothing Then Exit Sub 'new instance
Dim cfg = MyConfigHost.Load(config)
txtHost.Text = cfg.HostName.ToString
If cfg.CNAME Then radCNAME.Checked = True Else radTypes.Checked = True
chkMX.Checked = cfg.MX
chkNS.Checked = cfg.NS
chkPTR.Checked = cfg.PTR
ttl1.Value = cfg.TTL
End Sub
Public Overrides Function ValidateData() As Boolean
If txtHost.Text.Trim.Length = 0 Then
MessageBox.Show("Host name is required", "Fixed Host Name", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End If
Dim hn As JHSoftware.SimpleDNS.DomName
If Not JHSoftware.SimpleDNS.DomName.TryParse(txtHost.Text.Trim, hn) Then
MessageBox.Show("Invalid host name", "Fixed Host Name", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End If
If radTypes.Checked AndAlso _
Not chkMX.Checked AndAlso _
Not chkNS.Checked AndAlso _
Not chkPTR.Checked Then
MessageBox.Show("At least one record type must be selected", "Fixed Host Name", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End If
Return True
End Function
Public Overrides Function SaveData() As String
Dim rv As New MyConfigHost With {
.HostName = txtHost.Text.Trim,
.CNAME = radCNAME.Checked,
.MX = chkMX.Checked,
.NS = chkNS.Checked,
.PTR = chkPTR.Checked,
.TTL = ttl1.Value
}
Return rv.Save()
End Function
Private Sub radCNAME_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radCNAME.CheckedChanged, radTypes.CheckedChanged
chkMX.Enabled = radTypes.Checked
chkNS.Enabled = radTypes.Checked
chkPTR.Enabled = radTypes.Checked
End Sub
End Class