forked from CleverComponents/Clever-Internet-Suite-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.vb
More file actions
342 lines (322 loc) · 13 KB
/
Form1.vb
File metadata and controls
342 lines (322 loc) · 13 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
Imports CleverComponents.InetSuite
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
cbProxyType.SelectedIndex = 0
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Http1 As CleverComponents.InetSuite.Http
Private WithEvents cbProxyType As System.Windows.Forms.ComboBox
Private WithEvents label9 As System.Windows.Forms.Label
Private WithEvents edtPassword As System.Windows.Forms.TextBox
Private WithEvents label8 As System.Windows.Forms.Label
Private WithEvents edtUser As System.Windows.Forms.TextBox
Private WithEvents label7 As System.Windows.Forms.Label
Private WithEvents edtProxyPassword As System.Windows.Forms.TextBox
Private WithEvents label6 As System.Windows.Forms.Label
Private WithEvents edtProxyPort As System.Windows.Forms.TextBox
Private WithEvents label5 As System.Windows.Forms.Label
Private WithEvents label4 As System.Windows.Forms.Label
Private WithEvents edtProxyUser As System.Windows.Forms.TextBox
Private WithEvents edtProxyServer As System.Windows.Forms.TextBox
Private WithEvents label3 As System.Windows.Forms.Label
Private WithEvents memResult As System.Windows.Forms.TextBox
Private WithEvents cbShowText As System.Windows.Forms.CheckBox
Private WithEvents button1 As System.Windows.Forms.Button
Private WithEvents edtUrl As System.Windows.Forms.TextBox
Private WithEvents label2 As System.Windows.Forms.Label
Private WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents HtmlParser1 As CleverComponents.InetSuite.HtmlParser
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Http1 = New CleverComponents.InetSuite.Http
Me.HtmlParser1 = New CleverComponents.InetSuite.HtmlParser
Me.cbProxyType = New System.Windows.Forms.ComboBox
Me.label9 = New System.Windows.Forms.Label
Me.edtPassword = New System.Windows.Forms.TextBox
Me.label8 = New System.Windows.Forms.Label
Me.edtUser = New System.Windows.Forms.TextBox
Me.label7 = New System.Windows.Forms.Label
Me.edtProxyPassword = New System.Windows.Forms.TextBox
Me.label6 = New System.Windows.Forms.Label
Me.edtProxyPort = New System.Windows.Forms.TextBox
Me.label5 = New System.Windows.Forms.Label
Me.label4 = New System.Windows.Forms.Label
Me.edtProxyUser = New System.Windows.Forms.TextBox
Me.edtProxyServer = New System.Windows.Forms.TextBox
Me.label3 = New System.Windows.Forms.Label
Me.memResult = New System.Windows.Forms.TextBox
Me.cbShowText = New System.Windows.Forms.CheckBox
Me.button1 = New System.Windows.Forms.Button
Me.edtUrl = New System.Windows.Forms.TextBox
Me.label2 = New System.Windows.Forms.Label
Me.label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Http1
'
Me.Http1.Port = 80
Me.Http1.TlsFlags = CType((CleverComponents.InetSuite.Sspi.TlsFlags.UseSSL2 Or CleverComponents.InetSuite.Sspi.TlsFlags.UseSSL3), CleverComponents.InetSuite.Sspi.TlsFlags)
'
'HtmlParser1
'
Me.HtmlParser1.ParseMethod = CleverComponents.InetSuite.ParseMethod.TextOnly
'
'cbProxyType
'
Me.cbProxyType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cbProxyType.FormattingEnabled = True
Me.cbProxyType.Items.AddRange(New Object() {"HTTP Proxy", "SOCKS4 Firewall", "SOCKS5 Firewall"})
Me.cbProxyType.Location = New System.Drawing.Point(88, 93)
Me.cbProxyType.Name = "cbProxyType"
Me.cbProxyType.Size = New System.Drawing.Size(176, 21)
Me.cbProxyType.TabIndex = 39
'
'label9
'
Me.label9.AutoSize = True
Me.label9.Location = New System.Drawing.Point(16, 96)
Me.label9.Name = "label9"
Me.label9.Size = New System.Drawing.Size(60, 13)
Me.label9.TabIndex = 38
Me.label9.Text = "Proxy Type"
'
'edtPassword
'
Me.edtPassword.Location = New System.Drawing.Point(248, 56)
Me.edtPassword.Name = "edtPassword"
Me.edtPassword.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
Me.edtPassword.Size = New System.Drawing.Size(112, 20)
Me.edtPassword.TabIndex = 25
'
'label8
'
Me.label8.Location = New System.Drawing.Point(184, 56)
Me.label8.Name = "label8"
Me.label8.Size = New System.Drawing.Size(64, 16)
Me.label8.TabIndex = 37
Me.label8.Text = "Password"
'
'edtUser
'
Me.edtUser.Location = New System.Drawing.Point(56, 56)
Me.edtUser.Name = "edtUser"
Me.edtUser.Size = New System.Drawing.Size(104, 20)
Me.edtUser.TabIndex = 24
'
'label7
'
Me.label7.Location = New System.Drawing.Point(16, 56)
Me.label7.Name = "label7"
Me.label7.Size = New System.Drawing.Size(48, 16)
Me.label7.TabIndex = 36
Me.label7.Text = "User"
'
'edtProxyPassword
'
Me.edtProxyPassword.Location = New System.Drawing.Point(288, 143)
Me.edtProxyPassword.Name = "edtProxyPassword"
Me.edtProxyPassword.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
Me.edtProxyPassword.Size = New System.Drawing.Size(136, 20)
Me.edtProxyPassword.TabIndex = 30
'
'label6
'
Me.label6.Location = New System.Drawing.Point(288, 119)
Me.label6.Name = "label6"
Me.label6.Size = New System.Drawing.Size(64, 16)
Me.label6.TabIndex = 35
Me.label6.Text = "Proxy Port"
'
'edtProxyPort
'
Me.edtProxyPort.Location = New System.Drawing.Point(368, 119)
Me.edtProxyPort.Name = "edtProxyPort"
Me.edtProxyPort.Size = New System.Drawing.Size(56, 20)
Me.edtProxyPort.TabIndex = 27
Me.edtProxyPort.Text = "8080"
'
'label5
'
Me.label5.Location = New System.Drawing.Point(200, 143)
Me.label5.Name = "label5"
Me.label5.Size = New System.Drawing.Size(88, 16)
Me.label5.TabIndex = 34
Me.label5.Text = "Proxy Password"
'
'label4
'
Me.label4.Location = New System.Drawing.Point(16, 143)
Me.label4.Name = "label4"
Me.label4.Size = New System.Drawing.Size(64, 16)
Me.label4.TabIndex = 33
Me.label4.Text = "Proxy User"
'
'edtProxyUser
'
Me.edtProxyUser.Location = New System.Drawing.Point(88, 143)
Me.edtProxyUser.Name = "edtProxyUser"
Me.edtProxyUser.Size = New System.Drawing.Size(100, 20)
Me.edtProxyUser.TabIndex = 28
'
'edtProxyServer
'
Me.edtProxyServer.Location = New System.Drawing.Point(88, 119)
Me.edtProxyServer.Name = "edtProxyServer"
Me.edtProxyServer.Size = New System.Drawing.Size(176, 20)
Me.edtProxyServer.TabIndex = 26
Me.edtProxyServer.Text = "proxyserver"
'
'label3
'
Me.label3.Location = New System.Drawing.Point(16, 119)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(72, 16)
Me.label3.TabIndex = 29
Me.label3.Text = "Poxy Server"
'
'memResult
'
Me.memResult.BackColor = System.Drawing.SystemColors.Window
Me.memResult.Dock = System.Windows.Forms.DockStyle.Bottom
Me.memResult.Location = New System.Drawing.Point(0, 214)
Me.memResult.Multiline = True
Me.memResult.Name = "memResult"
Me.memResult.ReadOnly = True
Me.memResult.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.memResult.Size = New System.Drawing.Size(448, 212)
Me.memResult.TabIndex = 32
'
'cbShowText
'
Me.cbShowText.Location = New System.Drawing.Point(56, 167)
Me.cbShowText.Name = "cbShowText"
Me.cbShowText.Size = New System.Drawing.Size(104, 24)
Me.cbShowText.TabIndex = 31
Me.cbShowText.Text = "Show text only"
'
'button1
'
Me.button1.Location = New System.Drawing.Point(368, 32)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(56, 23)
Me.button1.TabIndex = 23
Me.button1.Text = "GET"
'
'edtUrl
'
Me.edtUrl.Location = New System.Drawing.Point(56, 32)
Me.edtUrl.Name = "edtUrl"
Me.edtUrl.Size = New System.Drawing.Size(304, 20)
Me.edtUrl.TabIndex = 22
Me.edtUrl.Text = "http://www.microsoft.com"
'
'label2
'
Me.label2.Location = New System.Drawing.Point(16, 32)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(40, 16)
Me.label2.TabIndex = 21
Me.label2.Text = "URL"
'
'label1
'
Me.label1.Location = New System.Drawing.Point(16, 8)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(424, 24)
Me.label1.TabIndex = 20
Me.label1.Text = "Type in the URL and click the 'GET' button to retreive the page specified by URL." & _
""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(448, 426)
Me.Controls.Add(Me.cbProxyType)
Me.Controls.Add(Me.label9)
Me.Controls.Add(Me.edtPassword)
Me.Controls.Add(Me.label8)
Me.Controls.Add(Me.edtUser)
Me.Controls.Add(Me.label7)
Me.Controls.Add(Me.edtProxyPassword)
Me.Controls.Add(Me.label6)
Me.Controls.Add(Me.edtProxyPort)
Me.Controls.Add(Me.label5)
Me.Controls.Add(Me.label4)
Me.Controls.Add(Me.edtProxyUser)
Me.Controls.Add(Me.edtProxyServer)
Me.Controls.Add(Me.label3)
Me.Controls.Add(Me.memResult)
Me.Controls.Add(Me.cbShowText)
Me.Controls.Add(Me.button1)
Me.Controls.Add(Me.edtUrl)
Me.Controls.Add(Me.label2)
Me.Controls.Add(Me.label1)
Me.Name = "Form1"
Me.Text = "HTTP GET demo"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
memResult.Text = ""
Http1.UserName = edtUser.Text
Http1.Password = edtPassword.Text
Http1.FirewallSettings.Server = ""
Http1.ProxySettings.Server = ""
If cbProxyType.SelectedIndex = 0 Then
Http1.ProxySettings.Server = edtProxyServer.Text
Http1.ProxySettings.Port = Convert.ToInt32(edtProxyPort.Text)
Http1.ProxySettings.UserName = edtProxyUser.Text
Http1.ProxySettings.Password = edtProxyPassword.Text
Else
If cbProxyType.SelectedIndex = 1 Then
Http1.FirewallSettings.FirewallType = FirewallType.Socks4
Else
Http1.FirewallSettings.FirewallType = FirewallType.Socks5
End If
Http1.FirewallSettings.Server = edtProxyServer.Text
Http1.FirewallSettings.Port = Convert.ToInt32(edtProxyPort.Text)
Http1.FirewallSettings.UserName = edtProxyUser.Text
Http1.FirewallSettings.Password = edtProxyPassword.Text
End If
Try
If cbShowText.Checked Then
HtmlParser1.Parse(Http1.Get(edtUrl.Text))
Else
memResult.Text = Http1.Get(edtUrl.Text)
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub 'button1_Click
Private Sub HtmlParser1_ParseTag(ByVal sender As Object, ByVal e As CleverComponents.InetSuite.ParseTagEventArgs) Handles HtmlParser1.ParseTag
If e.Tag.Text.Trim() <> "" Then
memResult.Text += e.Tag.Text
End If
End Sub
Private Sub cbProxyType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbProxyType.SelectedIndexChanged
If cbProxyType.SelectedIndex = 0 Then
edtProxyPort.Text = "8080"
Else
edtProxyPort.Text = "1080"
End If
End Sub
End Class