-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmPartSelect.class
237 lines (193 loc) · 6.7 KB
/
frmPartSelect.class
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
' Gambas class file
' ### PARTITION SELECTION WINDOW ###
PRIVATE MaxDisks AS Long
PRIVATE MaxPartions AS Long
PRIVATE selectedDisk AS String
PUBLIC SUB Form_Open()
DIM arrTemp AS NEW String[]
DIM n AS Byte
DIM m AS Byte
'Center form on screen:
ME.Center
ME.Caption = "Partition Selection"
MaxDisks = Global.DiskInfo.Count
MaxPartions = Global.PartInfo.Count
Global.PARTinst.Clear
'Setup gridDisk:
gridDisk.Columns.Count = 4
'gridDisk.Rows.Count = MaxDisks
gridDisk.Rows.Count = 32
gridDisk.Columns[0].Width = 0.35 * gridDisk.ClientWidth
gridDisk.Columns[1].Width = 0.25 * gridDisk.ClientWidth
gridDisk.Columns[2].Width = 0.25 * gridDisk.ClientWidth
gridDisk.Columns[3].Width = 0.15 * gridDisk.ClientWidth
'Center gridDisk titles alignment:
FOR n = 0 TO gridDisk.Columns.Count - 1
gridDisk[0, n].Alignment = Align.Center
NEXT
'Setup gridDisk titles:
gridDisk[0, 0].Text = "Drive"
gridDisk[0, 1].Text = "Size"
gridDisk[0, 2].Text = "Unallocated"
gridDisk[0, 3].Text = "Sel."
'Set gridDisk cell alignment; left for text, right for numbers, fill in gridDisk data:
FOR m = 1 TO MaxDisks
gridDisk[m, 0].Alignment = Align.Left
gridDisk.Rows[m].Height = 20
gridDisk[m, 0].Text = Global.DiskInfo[m - 1].Device
gridDisk[m, 1].Alignment = Align.Right
gridDisk[m, 1].Text = Functions.AutoUnits(Global.DiskInfo[m - 1].Bytes)
'arrTemp = Split(Functions.AutoUnits(Global.DiskInfo[m - 1].Bytes), " ", "", TRUE)
'gridDisk[m, 1].Text = arrTemp[0]
gridDisk[m, 2].Alignment = Align.Right
gridDisk[m, 2].Text = Functions.AutoUnits(Global.DiskInfo[m - 1].UnallocatedBytes)
gridDisk[m, 3].Alignment = Align.Center
NEXT
'Setup gridPart:
gridPart.Columns.Count = 7
'gridPart.Rows.Count = MaxPartions
gridPart.Rows.Count = 256
gridPart.Columns[0].Width = 0.15 * gridPart.ClientWidth
gridPart.Columns[1].Width = 0.125 * gridPart.ClientWidth
gridPart.Columns[2].Width = 0.1 * gridPart.ClientWidth
gridPart.Columns[3].Width = 0.055 * gridPart.ClientWidth
gridPart.Columns[4].Width = 0.275 * gridPart.ClientWidth
gridPart.Columns[5].Width = 0.17 * gridPart.ClientWidth
gridPart.Columns[6].Width = 0.125 * gridPart.ClientWidth
'Center gridPart titles alignment:
FOR n = 0 TO gridPart.Columns.Count - 1
gridPart[0, n].Alignment = Align.Center
NEXT
'Setup gridPart titles:
gridPart[0, 0].Text = "Partition"
gridPart[0, 1].Text = "Size"
gridPart[0, 2].Text = "Free Space"
gridPart[0, 3].Text = "Boot"
gridPart[0, 4].Text = "FileSystem"
gridPart[0, 5].Text = "Mount"
gridPart[0, 6].Text = "Format with"
'Set gridPart cell alignment; left for text, right for numbers:
FOR m = 1 TO gridPart.Rows.Count - 1
gridPart.Rows[m].Height = 20
gridPart[m, 0].Alignment = Align.Left
gridPart[m, 1].Alignment = Align.Right
gridPart[m, 2].Alignment = Align.Right
gridPart[m, 3].Alignment = Align.Center
gridPart[m, 4].Alignment = Align.Left
gridPart[m, 5].Alignment = Align.Left
NEXT
END
PUBLIC SUB gridDisk_Click()
DIM arrTemp AS NEW String[]
DIM n AS Long, m AS Long, p AS Long
IF gridDisk.Row = 0 OR gridDisk[gridDisk.Row, 2].Text = "" THEN
ELSE
IF gridDisk[gridDisk.Row, 3].Text = "" THEN
gridDisk[gridDisk.Row, 3].Text = "+++"
ELSE
gridDisk[gridDisk.Row, 3].Text = ""
ENDIF
FOR m = 1 TO gridPart.Rows.Count - 1
FOR n = 0 TO gridPart.Columns.Count - 1
gridPart[m, n].text = ""
NEXT
NEXT
m = 0
FOR p = 1 TO MaxDisks
IF gridDisk[p, 3].Text = "+++" THEN
selectedDisk = gridDisk[p, 0].Text
FOR n = 1 TO MaxPartions
IF InStr(Global.PartInfo[n - 1].Device, selectedDisk) THEN
m = m + 1
gridPart[m, 0].Text = Global.PartInfo[n - 1].Device
gridPart[m, 1].Text = Functions.AutoUnits(Global.PartInfo[n - 1].Bytes)
gridPart[m, 2].Text = Functions.AutoUnits(Global.PartInfo[n - 1].FreeBytes)
gridPart[m, 3].Text = IIf(Global.PartInfo[n - 1].Bootable, "B", "")
IF Functions.getPartType(Global.PartInfo[n - 1].ID) = "Extended" THEN
gridPart[m, 4].Text = "----Extended----"
ELSE IF Functions.getPartType(Global.PartInfo[n - 1].ID) = "Linux swap" THEN
gridPart[m, 4].Text = "Linux - Swap"
ELSE
gridPart[m, 4].Text = Functions.getPartType(Global.PartInfo[n - 1].ID) & " - " & Global.PartInfo[n - 1].FileSystem
ENDIF
IF InStr(gridPart[m, 4].Text, "Linux swap") THEN
gridPart[m, 5].Text = "swap"
gridPart[m, 6].Text = "swap"
ELSE IF InStr(gridPart[m, 4].Text, "Linux") THEN
gridPart[m, 6].Text = "reiserfs"
Global.PartInfo[n - 1].FormatWithFS = "reiserfs"
ELSE
'gridPart[m, 5].Text = Mid$(gridPart[m, 0].Text, 6)
gridPart[m, 6].Text = "--------------------"
ENDIF
ENDIF
NEXT
ENDIF
NEXT
ENDIF
END
PUBLIC SUB btnOK_Click()
DIM vPI AS NEW cPartInstall
DIM n AS Long
DIM sTemp AS String
FOR n = 1 TO gridPart.Rows.Count - 1
IF InStr(LCase(gridPart[n, 4].Text), LCase("Linux")) THEN
vPI = NEW cPartInstall
vPI.Device = gridPart[n, 0].Text
vPI.Mountpoint = gridPart[n, 5].Text
vPI.FormatWithFS = gridPart[n, 6].Text
Global.PARTinst.Push(vPI)
ENDIF
NEXT
FOR n = 1 TO global.PARTinst.Count - 1
PRINT global.PARTinst[n].Device
PRINT global.PARTinst[n].Mountpoint
PRINT global.PARTinst[n].FormatWithFS
NEXT
ME.Close(TRUE)
END
PUBLIC SUB btnCancel_Click()
ME.Close()
END
PUBLIC SUB gridPart_Menu()
IF InStr(gridPart[gridPart.Row, 4].Text, "Linux") THEN
IF gridPart.Column = 5 THEN
mountpoints.Popup
ELSE IF gridPart.Column = 6 THEN
filesystem.Popup
ENDIF
ENDIF
END
PUBLIC SUB Gmountpoint_Click()
DIM n AS Long
FOR n = 0 TO Global.PartInfo.Max
IF Global.PartInfo[n].Device = gridPart[gridPart.Row, 0].Text THEN
gridPart[gridPart.Row, 5].Text = LAST.Tag
Global.PartInfo[n].Mountpoint = gridPart[gridPart.Row, 5].Text
BREAK
ENDIF
NEXT
END
PUBLIC SUB Gfilesystem_Click()
DIM n AS Long
FOR n = 0 TO Global.PartInfo.Max
IF Global.PartInfo[n].Device = gridPart[gridPart.Row, 0].Text THEN
gridPart[gridPart.Row, 6].Text = LAST.Tag
Global.PartInfo[n].FormatWithFS = gridPart[gridPart.Row, 6].Text
BREAK
ENDIF
NEXT
END
PUBLIC SUB gridPart_Click()
DIM retstr AS String
IF gridPart.Column = 5 THEN
IF gridPart[gridPart.Row, 4].Text <> "Linux" AND gridPart[gridPart.Row, 5].Text <> "swap" THEN
' Get mount label.
retstr = InputBox.Input("Set mountpoint:", "", gridPart[gridPart.Row, 5].Text)
IF retstr THEN
' TODO: validate retstr
gridPart[gridPart.Row, 5].Text = retstr
END IF
ENDIF
ENDIF
END