-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetupDialogForm.vb
More file actions
91 lines (81 loc) · 3.53 KB
/
SetupDialogForm.vb
File metadata and controls
91 lines (81 loc) · 3.53 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
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports ASCOM.Utilities
Imports ASCOM.RR4005i
Imports System.Net
<ComVisible(False)> _
Public Class SetupDialogForm
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click ' OK button event handler
' Persist new values of user settings to the ASCOM profile
Dim tb As TextBox, ipstring As String, is_valid As Boolean = True
Switch.traceState = chkTrace.Checked
Switch.NumUnits = ddNumUnits.SelectedItem
For i As Integer = 0 To Switch.NumUnits - 1
tb = Me.Controls("txtIP" & i.ToString)
ipstring = tb.Text
Dim ip As IPAddress
If Not IPAddress.TryParse(ipstring, ip) Then
is_valid = False
Exit For
Else
Switch.RRIP(i) = tb.Text
End If
Next
If is_valid Then
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
Else
MsgBox("IP Address Invalid")
End If
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click 'Cancel button event handler
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub ShowAscomWebPage(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.DoubleClick, PictureBox1.Click
' Click on ASCOM logo event handler
Try
System.Diagnostics.Process.Start("http://ascom-standards.org/")
Catch noBrowser As System.ComponentModel.Win32Exception
If noBrowser.ErrorCode = -2147467259 Then
MessageBox.Show(noBrowser.Message)
End If
Catch other As System.Exception
MessageBox.Show(other.Message)
End Try
End Sub
Private Sub SetupDialogForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load ' Form load event handler
' Retrieve current values of user settings from the ASCOM Profile
InitUI()
End Sub
Private Sub InitUI()
Dim tb As TextBox, lb As Label
chkTrace.Checked = Switch.traceState
ddNumUnits.SelectedItem = Switch.NumUnits.ToString
cbFetchNames.Checked = Switch.bFetchNames
' Enable the IP Address text boxes, based on the number of units.
For i As Integer = 0 To Switch.NumUnits - 1
tb = Me.Controls("txtIP" & i.ToString)
lb = Me.Controls("lblIP" & i.ToString)
tb.Visible = True
tb.Text = Switch.RRIP(i)
lb.Visible = True
Next
' Disable the remaining IP Address textboxes based on the number of units
For i As Integer = Switch.NumUnits To 4
tb = Me.Controls("txtIP" & i.ToString)
lb = Me.Controls("lblIP" & i.ToString)
tb.Visible = False
lb.Visible = False
Next
End Sub
Private Sub ddNumUnits_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddNumUnits.SelectedIndexChanged
' Refresh the UI with the correct number of units
Switch.NumUnits = CInt(ddNumUnits.SelectedItem)
InitUI()
End Sub
Private Sub cbFetchNames_CheckedChanged(sender As Object, e As EventArgs) Handles cbFetchNames.CheckedChanged
' The driver can fetch port names from the RIGRunner. Should we do this on connect?
Switch.bFetchNames = cbFetchNames.Checked
End Sub
End Class