51
51
BottomPanel: TPanel;
53
53
CloseBIButton: TButton;
54
BlockHeadline: TLabel;
54
lblBlockHeadline: TLabel;
55
55
LogEntryList: TStringGrid;
56
56
TrackCurrentCheckBox: TCheckBox;
57
57
procedure BlockEditChange(Sender: TObject);
58
procedure FormHide(Sender: TObject);
59
procedure FormShow(Sender: TObject);
60
procedure lblBlockHeadlineDblClick(Sender: TObject);
58
61
procedure LogEntryListHeaderSized(Sender: TObject; IsColumn: Boolean; Index: Integer);
59
62
procedure CloseBIButtonClick(Sender: TObject);
60
63
procedure FormCreate(Sender: TObject);
61
64
procedure FormDestroy(Sender: TObject);
65
procedure TrackCurrentCheckBoxChange(Sender: TObject);
64
68
FParser : TLogParser;
112
// public method to set the block. Called from the Main GUI.
113
// this is not called when the BI is notified.
103
114
procedure TBlockForm.SetBlock(block : integer);
105
activeblock, numBlocks : Longint;
107
119
activeblock := FGridBlockStore.activeBlock();
108
numBlocks := FGridBlockStore.numBlocks;
109
FBlock := max(0, min(block, numBlocks));
110
// Disable Cur. Pos. tracking if requested block is not active block
111
// or is outside of zooming bounds
112
if (FBlock <> activeblock) or (activeblock < 0) or (activeBlock >= numBlocks) then
113
TrackCurrentCheckBox.Checked:=false;
120
numBlocks := FGridBlockStore.NumBlocks;
121
FBlock := max(0, min(block, numBlocks)); // sanitize to bounds
122
// Disable Cur. Pos. tracking if requested, sanitized block is not active block
123
if (FBlock <> activeblock) then TrackCurrentCheckBox.Checked:=false;
114
124
// update the Form, clear the user's list selection
121
131
the first item. *)
122
132
procedure TBlockForm.DoUpdate(clearSel : boolean);
124
imgStartBlock, imgEndBlock, logEntry, logLen, row : Longint;
125
bStart, bEnd, leStart, leEnd, overlap : Int64;
134
logEntry, logLen, row : Longint;
135
actblock, bStart, bEnd, leStart, leEnd, overlap : Int64;
126
136
rs : TRescueStatus; // only for counting sectors here
127
137
BlockEditChangeEvent : TNotifyEvent;
129
139
with FGridBlockStore do begin
130
140
// check if file is open
131
if not Assigned(DataSource) or not DataSource.hasFile() then begin
141
if not Assigned(Parser) or not Parser.hasFile() then begin
132
142
LogEntryList.RowCount:=1; // clear LogEntryList
133
143
Hide; // close BI window
137
// set the spinEdit bounds
147
FBlock := EnsureRange(block, 0, NumBlocks-1); // sanitize to bounds
148
// adjust FBlock if current pos tracking is enabled and activeblock is in bounds
149
actblock:=activeBlock();
150
if TrackCurrentCheckBox.Checked and (FBlock <> actblock) and
151
(activeblock >=0) and (activeBlock < NumBlocks) then begin
153
BlockEdit.Value:=FBlock; // calls doUpdate again and updates the MainForm
157
// set the spinEdit bounds, deactivate its event while doing so
138
158
BlockEditChangeEvent:=BlockEdit.OnChange;
139
159
BlockEdit.OnChange:=nil;
140
160
BlockEdit.Value:=FBlock;
141
BlockEdit.MaxValue:=numBlocks-1;
161
BlockEdit.MaxValue:=Min(NumBlocks-1, getBlockFromOffset(Parser.rescueStatus.devicesize-1));
142
162
BlockEdit.OnChange:=BlockEditChangeEvent;
144
// adjust FBlock if curent pos tracking is enabled
145
if TrackCurrentCheckBox.Checked then begin
146
FBlock := activeBlock();
147
BlockEdit.Value:=FBlock; // this also updates the MainForm
151
164
rs:=emptyRescueStatus;
152
165
bStart := getOffsetFromBlock(FBlock);
153
bEnd := min(DataSource.rescueStatus.deviceSize,
154
getOffsetFromBlock(block+1));
156
EditBlockInfo.Text:='Start: ' + SizeStr(bStart) +
157
' Size: ' + SizeStr(bEnd-bStart) + ' (' +
158
inttostr((bEnd-bStart) div devBSize) + ' sectors)';
160
with DataSource do begin
166
bEnd := max(bStart, min(Parser.rescueStatus.deviceSize, getOffsetFromBlock(block+1)));
168
EditBlockInfo.Text:='Start: ' + SFORMATS[lblBlockHeadline.Tag]^.SizeStr(bStart) +
169
' Size: ' + SFORMATS[lblBlockHeadline.Tag]^.SizeStr(bEnd-bStart) +
170
' (' + SF_SECT.SizeStr(bEnd-bStart) + 'ectors)';
161
173
logLen := Length(log);
162
174
// go through log and make list entries
174
186
// this log block is current rescue pos
175
187
if (rescueStatus.pos >= leStart) and (rescueStatus.pos < leEnd) then
176
188
LogEntryList.Cells[0, row]:='> '+LogEntryList.Cells[0, row];
177
LogEntryList.Cells[1, row]:=inttostr(log[logEntry].offset)+' B ('+SizeStr(log[logEntry].offset)+')';
178
LogEntryList.Cells[2, row]:=inttostr(log[logEntry].length)+' B ('+SizeStr(log[logEntry].length)+')';
189
LogEntryList.Cells[1, row]:=SF_HEX.SizeStr(log[logEntry].offset)+
190
' ('+SF_FLOAT.SizeStr(log[logEntry].offset)+')';
191
LogEntryList.Cells[2, row]:=SF_HEX.SizeStr(log[logEntry].length)+
192
' ('+SF_FLOAT.SizeStr(log[logEntry].length)+')';
179
193
overlap:=BlockOverlap(leStart, leEnd, bStart, bEnd);
180
194
case log[logEntry].status of
181
195
'?' : inc(rs.nontried, overlap);
188
202
LogEntryList.RowCount:=row+1;
189
203
if clearSel then LogEntryList.Row:=1;
191
EditNontriedSectors.Text:=inttostr(rs.nontried div FGridBlockStore.devBSize);
192
EditRescuedSectors.Text:=inttostr(rs.rescued div FGridBlockStore.devBSize);
193
EditNonTrimmedSectors.Text:=inttostr(rs.nontrimmed div FGridBlockStore.devBSize);
194
EditNonScrapedSectors.Text:=inttostr(rs.nonscraped div FGridBlockStore.devBSize);
195
EditBadSectors.Text:=inttostr(rs.bad div FGridBlockStore.devBSize);
205
EditNontriedSectors.Text:=SF_SECT.SizeStr(rs.nontried);
206
EditRescuedSectors.Text:=SF_SECT.SizeStr(rs.rescued);
207
EditNonTrimmedSectors.Text:=SF_SECT.SizeStr(rs.nontrimmed);
208
EditNonScrapedSectors.Text:=SF_SECT.SizeStr(rs.nonscraped);
209
EditBadSectors.Text:=SF_SECT.SizeStr(rs.bad);
196
210
end; // with FGridBlockStore
205
// The block number in the spind-edit has been changed
219
// The block number in the spin-edit has been changed
206
220
procedure TBlockForm.BlockEditChange(Sender: TObject);
208
if BlockEdit.Value <> FGridBlockStore.activeBlock then TrackCurrentCheckBox.Checked:=false;
209
222
MainForm.SelectBlock(BlockEdit.Value);
210
223
SetBlock(BlockEdit.Value);
226
// prevent when hiding the form, unset the mainform's selected block and
227
// prevent further trakcing of the active block
228
procedure TBlockForm.FormHide(Sender: TObject);
230
MainForm.SelectBlock(-1);
231
TrackCurrentCheckBox.Checked:=false;
234
procedure TBlockForm.FormShow(Sender: TObject);
236
self.Position:=poDesigned; // make the form appear at its prev pos when reopened
239
// switch the boundaries line size format
240
procedure TBlockForm.lblBlockHeadlineDblClick(Sender: TObject);
242
lblBlockHeadline.Tag := (lblBlockHeadline.Tag + 1) mod 3;
213
246
// prevent 'Status' column from becoming invisible
214
247
procedure TBlockForm.LogEntryListHeaderSized(Sender: TObject; IsColumn: Boolean;