/[AnywhereTS-MSSQL]/trunk/VBDLL/wizardSupport.vb
ViewVC logotype

Contents of /trunk/VBDLL/wizardSupport.vb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations) (download)
Wed Jul 11 14:19:13 2012 UTC (8 years, 1 month ago) by william
File size: 8881 byte(s)
imported from https://anywherets.svn.sourceforge.net/svnroot/anywherets/trunk/
Revision: 1
Author: beartown
Date: 3:10:40 AM, Monday, June 21, 2010
Message:
First upload. Still todo in order to get a fully working product: Replace Thinstation images with vanilla Thinstation, modify ImageDesigntimeConfig.cs, ImageRuntimeConfig.cs in order to support the Thinstation image
1 Imports System.IO
2 Imports System.CodeDom.Compiler
3 ' -------------------------------------
4 ' Support routines for the wizard form
5 ' -------------------------------------
6
7 Public Module wizardSupport
8 Public Enum PXEBootTask 'Types of media
9 PXE_Boot_Floppy
10 PXE_Boot_CD
11 End Enum
12 Public PXEBootType As PXEBootTask ' Startup mode for wizard, as defined in WizardTask
13 Dim response As MsgBoxResult
14 Dim msg As String
15 Dim title As String
16 Dim style As MsgBoxStyle
17
18 Public Sub PXEBoot()
19 If PXEBootType = PXEBootTask.PXE_Boot_Floppy Then 'create a PXE Floppy
20 Dim response As MsgBoxResult
21 msg = "Creates a floppy that can be used on computers that do not have support for PXE boot in BIOS. Please insert a blank floppy disk in drive A:" ' Define message.
22 style = MsgBoxStyle.OkCancel
23 title = "Create a PXE boot floppy" ' Define title.
24 response = MsgBox(msg, style, title)
25 If response = MsgBoxResult.Ok Then ' User chose OK.
26 Shell(Globals.strAppdir + "\diskwrite\DiskWrite.exe " + Globals.strAppdir + "\data\netboot.img", AppWinStyle.NormalFocus, False)
27 End If
28 ElseIf PXEBootType = PXEBootTask.PXE_Boot_CD Then 'Create a PXE boot CD
29 Dim isoName As String
30 msg = "Creates a CD-image that can be used to create a PXE BOOT-CD for computers that do not have support for PXE boot in BIOS." ' Define message.
31 style = MsgBoxStyle.OkCancel
32 title = "Create a PXE boot CD" ' Define title.
33 response = MsgBox(msg, style, title)
34 If response = MsgBoxResult.Ok Then ' User chose OK.
35 Dim objDialog As New SaveFileDialog
36 isoName = "Netboot"
37 objDialog.Filter = "CD-R ISO images (*.iso)|*.iso"
38 objDialog.DefaultExt = "iso"
39 objDialog.FileName = isoName
40 If objDialog.ShowDialog() = DialogResult.OK Then
41 isoName = objDialog.FileName
42 End If
43 File.Copy(Globals.strAppdir + "\data\netboot.iso", isoName, True)
44 End If
45 End If
46 End Sub
47
48 ' Does a look-up in the file strFile on the line numbered by intIndex (zero based), then skips the first parameter on the line,
49 ' and interprets all the following parameters on the row as files to be copied from strSourcePath to strDestPath
50 Sub CopyFiles(ByVal strDriver As String, ByVal strFile As String, ByVal strSourcePath As String, ByVal strDestPath As String, ByVal objTempRoot As TempFileCollection)
51 Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFile)
52 MyReader.TextFieldType = FileIO.FieldType.Delimited
53 MyReader.SetDelimiters(";")
54 Dim intRow As Integer
55 Dim currentRow As String()
56 ReDim currentRow(1) 'Initialise so that we can run the loop below first time.
57 'Read rows until we found the row
58 While Not MyReader.EndOfData AndAlso currentRow(1) <> strDriver
59 Try
60 currentRow = MyReader.ReadFields()
61 Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
62 MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.")
63 End Try
64 intRow = intRow + 1
65 End While
66 ' We have found the right row
67 Dim i As Integer
68 For i = 2 To currentRow.GetUpperBound(0)
69 File.Copy(strSourcePath & "\" & currentRow(i), strDestPath + "\" + currentRow(i), True)
70 Try
71 objTempRoot.AddFile(strDestPath + "\" + currentRow(i), False)
72 Catch
73 End Try
74 Next
75 End Using
76 End Sub
77
78 ' Copies all files specified in strFile from strSourcePath to strDestPath.
79 ' The first paramter on each line is skipped the following parameters on the line is iterpreted as file names
80 Sub CopyAllFiles(ByVal strFile As String, ByVal strSourcePath As String, ByVal strDestPath As String, ByVal objTempRoot As TempFileCollection)
81 Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFile)
82 MyReader.TextFieldType = FileIO.FieldType.Delimited
83 MyReader.SetDelimiters(";")
84 Dim intRow As Integer
85 Dim currentRow As String()
86 While Not MyReader.EndOfData
87 Try
88 currentRow = MyReader.ReadFields()
89 Dim i As Integer
90 For i = 2 To currentRow.GetUpperBound(0)
91 If Not File.Exists(strDestPath + "\" + currentRow(i)) Then
92 File.Copy(strSourcePath & "\" & currentRow(i), strDestPath + "\" + currentRow(i), True)
93 Try
94 objTempRoot.AddFile(strDestPath + "\" + currentRow(i), False)
95 Catch
96 End Try
97 End If
98 Next
99 Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
100 MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.")
101 End Try
102 intRow = intRow + 1
103 End While
104 End Using
105 End Sub
106 ' Does a look-up in the file strFile on the line numbered by intIndex (zero based), and returns the name of the first file specified on that line.
107 Function LookupFile(ByVal intIndex As Integer, ByVal strFile As String) As String
108 Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFile)
109 MyReader.TextFieldType = FileIO.FieldType.Delimited
110 MyReader.SetDelimiters(";")
111 Dim intRow As Integer
112 Dim currentRow As String()
113 While Not MyReader.EndOfData AndAlso intRow < intIndex
114 Try
115 currentRow = MyReader.ReadFields()
116 Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
117 MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.")
118 End Try
119 intRow = intRow + 1
120 End While
121 Try
122 currentRow = MyReader.ReadFields()
123 Return currentRow(1)
124 Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
125 MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.")
126 Return ""
127 End Try
128 End Using
129 End Function
130 Public Sub AnywhereTSHomepage()
131 '****************************************************
132 '* Denna metod opens the AnywhereTS homepage *
133 '****************************************************
134 On Error GoTo useie
135 'Try letting system select browser
136 System.Diagnostics.Process.Start("http://anywhereTS.com")
137 On Error GoTo -1
138 Return
139 useie: On Error GoTo -1
140 'Failed, use IE
141 System.Diagnostics.Process.Start("IExplore.exe", "http://anywhereTS.com")
142 End Sub
143 Public Function IsValidIPAddress(ByVal strIPAddress As String) As Boolean
144 On Error GoTo Handler
145 Dim varAddress As Object, n As Long, lCount As Long
146 varAddress = Split(strIPAddress, ".", , vbTextCompare)
147 '//
148 If IsArray(varAddress) Then
149 For n = LBound(varAddress) To UBound(varAddress)
150 lCount = lCount + 1
151 varAddress(n) = CByte(varAddress(n))
152 Next
153 '//
154 IsValidIPAddress = (lCount = 4)
155 End If
156 '//
157 Handler:
158 End Function
159 Public Sub LoadComboBoxFromFile(ByRef cboList As ComboBox, ByVal strFile As String)
160 cboList.Items.Clear()
161 Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFile)
162 MyReader.TextFieldType = FileIO.FieldType.Delimited
163 MyReader.SetDelimiters(";")
164 Dim currentRow As String()
165 While Not MyReader.EndOfData
166 Try
167 currentRow = MyReader.ReadFields()
168 cboList.Items.Add(currentRow(0))
169 Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
170 MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.")
171 End Try
172 End While
173 End Using
174 cboList.SelectedIndex = 0
175 End Sub
176
177 End Module

  ViewVC Help
Powered by ViewVC 1.1.22