-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmMain.vb
313 lines (292 loc) · 15.8 KB
/
frmMain.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
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
Imports System.IO
Public Class frmMain
Dim fs As FileStream
Dim sr As StreamReader
Dim sw As StreamWriter
Private Sub Refresh_List()
Dim i As String
Dim typ, fn As String
ListView1.Items.Clear()
'stream writer
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("hcdisk cat -e > console.rd")
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.Hide, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
'stream reader
Try
fs = New FileStream("console.rd", FileMode.Open, FileAccess.Read)
sr = New StreamReader(fs, System.Text.Encoding.Default)
'read header
i = sr.ReadLine()
If i = "No files found." Then
i = sr.ReadLine()
i = sr.ReadLine()
Label1.Text = i
sr.Close()
fs.Close()
Exit Sub
End If
If i = "Read error: No media in drive." Then
i = sr.ReadLine()
i = sr.ReadLine()
i = sr.ReadLine()
i = sr.ReadLine()
Label1.Text = i
MessageBox.Show("Read error: No media in drive.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
sr.Close()
fs.Close()
Exit Sub
End If
If i = "Read error: No ID address mark was found on the floppy disk." Then
i = sr.ReadLine()
i = sr.ReadLine()
i = sr.ReadLine()
i = sr.ReadLine()
Label1.Text = i
MessageBox.Show("Read error: No ID address mark was found on the floppy disk. The disk may not be formatted for HC.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
sr.Close()
fs.Close()
Exit Sub
End If
i = sr.ReadLine
'get files
Do
i = sr.ReadLine
If i = "" Then 'daca a fost ultimul fisier...
i = sr.ReadLine()
Label1.Text = i
Exit Do
End If
'scoatere nume fisier
fn = Strings.Left(Strings.Right(i, Strings.Len(i) - Strings.InStr(i, ":")), Strings.InStr((Strings.Right(i, Strings.Len(i) - Strings.InStr(i, ":"))), " ") - 1)
ListView1.Items.Add(fn, 0)
'scoatere tip fisier
typ = Strings.Left(i, Strings.InStr(i, ":") - 1)
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(typ)
Loop Until sr.EndOfStream = True
sr.Close()
fs.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
End Sub
Private Sub LinkLabel10_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel10.LinkClicked
Refresh_List()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.SelectedIndex = 0
Text = Text & " v" & My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "List" Then ListView1.View = View.List
If ComboBox1.Text = "Small Icons" Then ListView1.View = View.SmallIcon
If ComboBox1.Text = "Large Icons" Then ListView1.View = View.LargeIcon
If ComboBox1.Text = "Tiles" Then ListView1.View = View.Tile
If ComboBox1.Text = "Details" Then
ListView1.View = View.Details
ListView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
End If
End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Dim msg As DialogResult
If ListView1.SelectedItems.Count = 0 Then Exit Sub
msg = MessageBox.Show("Are you sure you want to delete " & ListView1.SelectedItems.Item(0).Text & " ?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If msg = Windows.Forms.DialogResult.Yes Then
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("hcdisk del " & ListView1.SelectedItems.Item(0).Text)
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.Hide, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Refresh_List()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Shell(My.Application.Info.DirectoryPath & "\fdinstall.exe", AppWinStyle.NormalFocus, True, -1)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MessageBox.Show("HC Disk Explorer" & vbCrLf & "Made by: Mihai Alexandru Vasiliu" & vbCrLf & "Support: [email protected]" & vbCrLf & vbCrLf & "This program uses hcdisk and cpmimg by George Chirtoacă ([email protected])", "About", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub LinkLabel4_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel4.LinkClicked
Dim rsp As String
If ListView1.SelectedItems.Count = 0 Then Exit Sub
rsp = InputBox("Enter new name:", "Rename File", ListView1.SelectedItems.Item(0).Text)
If rsp <> "" Then
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("hcdisk ren " & ListView1.SelectedItems.Item(0).Text & " " & rsp)
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.Hide, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Refresh_List()
End If
End Sub
Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
Dim dlg As DialogResult
If ListView1.SelectedItems.Count = 0 Then Exit Sub
dlg = SaveFileDialog1.ShowDialog
If dlg <> Windows.Forms.DialogResult.Cancel Then
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("hcdisk get " & ListView1.SelectedItems.Item(0).Text)
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.Hide, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
'Refresh_List()
My.Computer.FileSystem.CopyFile(My.Application.Info.DirectoryPath & "\" & ListView1.SelectedItems.Item(0).Text, SaveFileDialog1.FileName, True)
My.Computer.FileSystem.DeleteFile(My.Application.Info.DirectoryPath & "\" & ListView1.SelectedItems.Item(0).Text, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
End Sub
Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
Dim dlg As DialogResult
Dim ft As String
If RadioButton3.Checked = True Then ft = "p"
If RadioButton3.Checked = True Then ft = "c"
If RadioButton3.Checked = True Then ft = "t"
dlg = OpenFileDialog1.ShowDialog
If dlg <> Windows.Forms.DialogResult.Cancel Then
My.Computer.FileSystem.CopyFile(OpenFileDialog1.FileName, My.Application.Info.DirectoryPath & "\" & OpenFileDialog1.SafeFileName, True)
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("hcdisk put " & OpenFileDialog1.SafeFileName & " -t" & ft)
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.Hide, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Refresh_List()
End If
End Sub
Private Sub LinkLabel5_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel5.LinkClicked
Dim msg As DialogResult
Dim ft As String
If CheckBox1.Checked = True Then ft = " -v"
If CheckBox1.Checked = False Then ft = ""
msg = MessageBox.Show("WARNING! Formatting the disk as HC will erase all the data on it and it will make the disk unusable on Windows/Disk Operating Systems. Are you sure you want to proceed? (It might take a while)", "Confirm Format", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)
If msg = Windows.Forms.DialogResult.Yes Then
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("@hcdisk fmt" & ft)
sw.WriteLine("@pause")
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.NormalFocus, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Refresh_List()
End If
End Sub
Private Sub LinkLabel8_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel8.LinkClicked
Dim dlg As DialogResult
dlg = SaveFileDialog1.ShowDialog
If dlg <> Windows.Forms.DialogResult.Cancel Then
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
If RadioButton2.Checked = True Then
sw.WriteLine("@hcdisk bak " & SaveFileDialog1.FileName & " -t40")
Else
sw.WriteLine("@hcdisk bak " & SaveFileDialog1.FileName)
End If
sw.WriteLine("@pause")
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.NormalFocus, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
'Refresh_List()
'My.Computer.FileSystem.CopyFile(My.Application.Info.DirectoryPath & "\" & ListView1.SelectedItems.Item(0).Text, SaveFileDialog1.FileName, True)
'My.Computer.FileSystem.DeleteFile(My.Application.Info.DirectoryPath & "\" & ListView1.SelectedItems.Item(0).Text, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
End Sub
Private Sub LinkLabel6_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel6.LinkClicked
Dim dlg As DialogResult
dlg = SaveFileDialog1.ShowDialog
If dlg <> Windows.Forms.DialogResult.Cancel Then
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("@hcdisk exp -t" & SaveFileDialog1.FileName)
sw.WriteLine("@pause")
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.NormalFocus, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
'Refresh_List()
'My.Computer.FileSystem.CopyFile(My.Application.Info.DirectoryPath & "\" & ListView1.SelectedItems.Item(0).Text, SaveFileDialog1.FileName, True)
'My.Computer.FileSystem.DeleteFile(My.Application.Info.DirectoryPath & "\" & ListView1.SelectedItems.Item(0).Text, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
End Sub
Private Sub LinkLabel7_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel7.LinkClicked
Dim dlg As DialogResult
dlg = OpenFileDialog1.ShowDialog
If dlg <> Windows.Forms.DialogResult.Cancel Then
My.Computer.FileSystem.CopyFile(OpenFileDialog1.FileName, My.Application.Info.DirectoryPath & "\" & OpenFileDialog1.SafeFileName, True)
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("@hcdisk imp -t" & OpenFileDialog1.SafeFileName)
sw.WriteLine("@pause")
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.NormalFocus, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Refresh_List()
End If
End Sub
Private Sub LinkLabel9_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel9.LinkClicked
Dim dlg As DialogResult
Dim ft As String
If CheckBox1.Checked = True Then ft = " -v"
If CheckBox1.Checked = False Then ft = ""
dlg = OpenFileDialog1.ShowDialog
If dlg <> Windows.Forms.DialogResult.Cancel Then
My.Computer.FileSystem.CopyFile(OpenFileDialog1.FileName, My.Application.Info.DirectoryPath & "\" & OpenFileDialog1.SafeFileName, True)
Try
fs = New FileStream("console.bat", FileMode.Create, FileAccess.Write)
sw = New StreamWriter(fs, System.Text.Encoding.Default)
sw.WriteLine("@hcdisk rst " & OpenFileDialog1.SafeFileName & ft)
sw.WriteLine("@pause")
sw.Close()
fs.Close()
Shell("console.bat", AppWinStyle.NormalFocus, True, -1)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
Refresh_List()
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
frmCPM.ShowDialog()
End Sub
End Class