-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathForm1.vb
More file actions
315 lines (300 loc) · 12.3 KB
/
Form1.vb
File metadata and controls
315 lines (300 loc) · 12.3 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
Imports System.IO
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()
cbEncoding.SelectedIndex = 1
cbEncodingFile.SelectedIndex = 1
'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 btnDecodeFile As System.Windows.Forms.Button
Friend WithEvents btnEncodeFile As System.Windows.Forms.Button
Friend WithEvents cbEncodingFile As System.Windows.Forms.ComboBox
Friend WithEvents edtDestinationFile As System.Windows.Forms.TextBox
Friend WithEvents edtSourceFile As System.Windows.Forms.TextBox
Friend WithEvents btnDecode As System.Windows.Forms.Button
Friend WithEvents btnEncode As System.Windows.Forms.Button
Friend WithEvents cbEncoding As System.Windows.Forms.ComboBox
Friend WithEvents edtDestination As System.Windows.Forms.TextBox
Friend WithEvents edtSource As System.Windows.Forms.TextBox
Friend WithEvents label8 As System.Windows.Forms.Label
Friend WithEvents label7 As System.Windows.Forms.Label
Friend WithEvents label6 As System.Windows.Forms.Label
Friend WithEvents panel1 As System.Windows.Forms.Panel
Friend WithEvents label5 As System.Windows.Forms.Label
Friend WithEvents label4 As System.Windows.Forms.Label
Friend WithEvents label3 As System.Windows.Forms.Label
Friend WithEvents label2 As System.Windows.Forms.Label
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents Encoder1 As CleverComponents.InetSuite.Encoder
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.btnDecodeFile = New System.Windows.Forms.Button()
Me.btnEncodeFile = New System.Windows.Forms.Button()
Me.cbEncodingFile = New System.Windows.Forms.ComboBox()
Me.edtDestinationFile = New System.Windows.Forms.TextBox()
Me.edtSourceFile = New System.Windows.Forms.TextBox()
Me.btnDecode = New System.Windows.Forms.Button()
Me.btnEncode = New System.Windows.Forms.Button()
Me.cbEncoding = New System.Windows.Forms.ComboBox()
Me.edtDestination = New System.Windows.Forms.TextBox()
Me.edtSource = New System.Windows.Forms.TextBox()
Me.label8 = New System.Windows.Forms.Label()
Me.label7 = New System.Windows.Forms.Label()
Me.label6 = New System.Windows.Forms.Label()
Me.panel1 = New System.Windows.Forms.Panel()
Me.label5 = New System.Windows.Forms.Label()
Me.label4 = New System.Windows.Forms.Label()
Me.label3 = New System.Windows.Forms.Label()
Me.label2 = New System.Windows.Forms.Label()
Me.label1 = New System.Windows.Forms.Label()
Me.Encoder1 = New CleverComponents.InetSuite.Encoder()
Me.SuspendLayout()
'
'btnDecodeFile
'
Me.btnDecodeFile.Location = New System.Drawing.Point(224, 328)
Me.btnDecodeFile.Name = "btnDecodeFile"
Me.btnDecodeFile.Size = New System.Drawing.Size(75, 23)
Me.btnDecodeFile.TabIndex = 37
Me.btnDecodeFile.Text = "Decode"
'
'btnEncodeFile
'
Me.btnEncodeFile.Location = New System.Drawing.Point(120, 328)
Me.btnEncodeFile.Name = "btnEncodeFile"
Me.btnEncodeFile.Size = New System.Drawing.Size(75, 23)
Me.btnEncodeFile.TabIndex = 36
Me.btnEncodeFile.Text = "Encode"
'
'cbEncodingFile
'
Me.cbEncodingFile.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cbEncodingFile.Items.AddRange(New Object() {"Quoted Printable", "Base 64", "UUE"})
Me.cbEncodingFile.Location = New System.Drawing.Point(120, 296)
Me.cbEncodingFile.Name = "cbEncodingFile"
Me.cbEncodingFile.Size = New System.Drawing.Size(152, 21)
Me.cbEncodingFile.TabIndex = 35
'
'edtDestinationFile
'
Me.edtDestinationFile.Location = New System.Drawing.Point(120, 264)
Me.edtDestinationFile.Name = "edtDestinationFile"
Me.edtDestinationFile.Size = New System.Drawing.Size(296, 20)
Me.edtDestinationFile.TabIndex = 34
Me.edtDestinationFile.Text = "image001_encoded.txt"
'
'edtSourceFile
'
Me.edtSourceFile.Location = New System.Drawing.Point(120, 240)
Me.edtSourceFile.Name = "edtSourceFile"
Me.edtSourceFile.Size = New System.Drawing.Size(296, 20)
Me.edtSourceFile.TabIndex = 33
Me.edtSourceFile.Text = "image001.jpg"
'
'btnDecode
'
Me.btnDecode.Location = New System.Drawing.Point(224, 192)
Me.btnDecode.Name = "btnDecode"
Me.btnDecode.Size = New System.Drawing.Size(75, 23)
Me.btnDecode.TabIndex = 32
Me.btnDecode.Text = "Decode"
'
'btnEncode
'
Me.btnEncode.Location = New System.Drawing.Point(120, 192)
Me.btnEncode.Name = "btnEncode"
Me.btnEncode.Size = New System.Drawing.Size(75, 23)
Me.btnEncode.TabIndex = 31
Me.btnEncode.Text = "Encode"
'
'cbEncoding
'
Me.cbEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cbEncoding.Items.AddRange(New Object() {"Quoted Printable", "Base 64", "UUE"})
Me.cbEncoding.Location = New System.Drawing.Point(120, 160)
Me.cbEncoding.Name = "cbEncoding"
Me.cbEncoding.Size = New System.Drawing.Size(152, 21)
Me.cbEncoding.TabIndex = 30
'
'edtDestination
'
Me.edtDestination.Location = New System.Drawing.Point(120, 128)
Me.edtDestination.Name = "edtDestination"
Me.edtDestination.ReadOnly = True
Me.edtDestination.Size = New System.Drawing.Size(296, 20)
Me.edtDestination.TabIndex = 29
'
'edtSource
'
Me.edtSource.Location = New System.Drawing.Point(120, 104)
Me.edtSource.Name = "edtSource"
Me.edtSource.Size = New System.Drawing.Size(296, 20)
Me.edtSource.TabIndex = 28
Me.edtSource.Text = "sample text to encode"
'
'label8
'
Me.label8.Location = New System.Drawing.Point(16, 296)
Me.label8.Name = "label8"
Me.label8.Size = New System.Drawing.Size(100, 16)
Me.label8.TabIndex = 27
Me.label8.Text = "Encoding Format"
'
'label7
'
Me.label7.Location = New System.Drawing.Point(16, 264)
Me.label7.Name = "label7"
Me.label7.Size = New System.Drawing.Size(100, 16)
Me.label7.TabIndex = 26
Me.label7.Text = "Destination File"
'
'label6
'
Me.label6.Location = New System.Drawing.Point(16, 240)
Me.label6.Name = "label6"
Me.label6.Size = New System.Drawing.Size(100, 16)
Me.label6.TabIndex = 25
Me.label6.Text = "Source File"
'
'panel1
'
Me.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.panel1.Location = New System.Drawing.Point(16, 224)
Me.panel1.Name = "panel1"
Me.panel1.Size = New System.Drawing.Size(400, 1)
Me.panel1.TabIndex = 24
'
'label5
'
Me.label5.Location = New System.Drawing.Point(16, 160)
Me.label5.Name = "label5"
Me.label5.Size = New System.Drawing.Size(100, 16)
Me.label5.TabIndex = 23
Me.label5.Text = "Encoding Format"
'
'label4
'
Me.label4.Location = New System.Drawing.Point(16, 128)
Me.label4.Name = "label4"
Me.label4.Size = New System.Drawing.Size(100, 16)
Me.label4.TabIndex = 22
Me.label4.Text = "Result String"
'
'label3
'
Me.label3.Location = New System.Drawing.Point(16, 104)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(100, 16)
Me.label3.TabIndex = 21
Me.label3.Text = "Source String"
'
'label2
'
Me.label2.Location = New System.Drawing.Point(16, 56)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(408, 32)
Me.label2.TabIndex = 20
Me.label2.Text = "Please select the source and destination files, the required encoding format and " &
"press the Encode or Decode buttons."
'
'label1
'
Me.label1.Location = New System.Drawing.Point(16, 16)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(408, 32)
Me.label1.TabIndex = 19
Me.label1.Text = "This demo demonstrates how to decode / encode a file using the base64, UUE or Quo" &
"tedPrintable encoding formats."
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(440, 366)
Me.Controls.Add(Me.btnDecodeFile)
Me.Controls.Add(Me.btnEncodeFile)
Me.Controls.Add(Me.cbEncodingFile)
Me.Controls.Add(Me.edtDestinationFile)
Me.Controls.Add(Me.edtSourceFile)
Me.Controls.Add(Me.btnDecode)
Me.Controls.Add(Me.btnEncode)
Me.Controls.Add(Me.cbEncoding)
Me.Controls.Add(Me.edtDestination)
Me.Controls.Add(Me.edtSource)
Me.Controls.Add(Me.label8)
Me.Controls.Add(Me.label7)
Me.Controls.Add(Me.label6)
Me.Controls.Add(Me.panel1)
Me.Controls.Add(Me.label5)
Me.Controls.Add(Me.label4)
Me.Controls.Add(Me.label3)
Me.Controls.Add(Me.label2)
Me.Controls.Add(Me.label1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub btnEncode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncode.Click
On Error GoTo Err
Encoder1.EncodeMethod = CType(cbEncoding.SelectedIndex + 1, EncodeMethod)
edtDestination.Text = Encoder1.Encode(edtSource.Text)
Return
Err:
MessageBox.Show(Err.Description)
End Sub
Private Sub btnDecode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecode.Click
On Error GoTo Err
Encoder1.EncodeMethod = CType(cbEncoding.SelectedIndex + 1, EncodeMethod)
edtDestination.Text = Encoder1.Decode(edtSource.Text)
Return
Err:
MessageBox.Show(Err.Description)
End Sub
Private Sub btnEncodeFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncodeFile.Click
On Error GoTo Err
Dim source As New FileStream(edtSourceFile.Text, FileMode.Open, FileAccess.Read)
Dim dest As New FileStream(edtDestinationFile.Text, FileMode.Create)
Encoder1.EncodeMethod = CType(cbEncodingFile.SelectedIndex + 1, EncodeMethod)
Encoder1.Encode(source, dest)
dest.Close()
source.Close()
MessageBox.Show("Done")
Return
Err:
MessageBox.Show(Err.Description)
End Sub
Private Sub btnDecodeFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecodeFile.Click
On Error GoTo Err
Dim source As New FileStream(edtSourceFile.Text, FileMode.Open, FileAccess.Read)
Dim dest As New FileStream(edtDestinationFile.Text, FileMode.Create)
Encoder1.EncodeMethod = CType(cbEncodingFile.SelectedIndex + 1, EncodeMethod)
Encoder1.Decode(source, dest)
dest.Close()
source.Close()
MessageBox.Show("Done")
Return
Err:
MessageBox.Show(Err.Description)
End Sub
End Class