Skip to content

Commit

Permalink
Improved progress display - added progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsmith committed Jul 25, 2015
1 parent b655ecb commit 044255e
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 58 deletions.
30 changes: 16 additions & 14 deletions uprogress.lfm
@@ -1,20 +1,21 @@
object frmProgress: TfrmProgress
Left = 879
Height = 240
Top = 267
Width = 320
Left = 647
Height = 207
Top = 272
Width = 402
Caption = 'YAFFI - Progress Window'
ClientHeight = 240
ClientWidth = 320
ClientHeight = 207
ClientWidth = 402
Position = poDesktopCenter
LCLVersion = '1.4.0.4'
object GroupBox1: TGroupBox
Left = 8
Height = 145
Height = 177
Top = 16
Width = 305
Width = 384
Caption = 'Progress'
ClientHeight = 127
ClientWidth = 301
ClientHeight = 159
ClientWidth = 380
TabOrder = 0
object Label7: TLabel
Left = 8
Expand All @@ -27,7 +28,7 @@ object frmProgress: TfrmProgress
object Label6: TLabel
Left = 8
Height = 13
Top = 96
Top = 128
Width = 12
Caption = '...'
ParentColor = False
Expand All @@ -51,20 +52,21 @@ object frmProgress: TfrmProgress
ParentColor = False
end
object lblTotalBytesSource: TLabel
Left = 144
Left = 136
Height = 13
Top = 48
Width = 12
Caption = '...'
ParentColor = False
end
object ProgressBar1: TProgressBar
Left = 99
Left = 8
Height = 20
Top = 83
Width = 100
Width = 360
BorderWidth = 1
TabOrder = 0
BarShowText = True
end
end
end
30 changes: 28 additions & 2 deletions uyaffi.pas
Expand Up @@ -1345,6 +1345,8 @@ function WindowsImageDiskDD(hDiskHandle : THandle; DiskSize : Int64; HashChoice
BytesWritten := 0;
TotalBytesRead := 0;
TotalBytesWritten := 0;
frmProgress.ProgressBar1.Position := 0;
frmProgress.lblTotalBytesSource.Caption:= IntToStr(DiskSize);

try
// Initialise the hash digests in accordance with the users chosen algorithm
Expand Down Expand Up @@ -1397,7 +1399,8 @@ function WindowsImageDiskDD(hDiskHandle : THandle; DiskSize : Int64; HashChoice
else inc(TotalBytesRead, BytesRead);

frmProgress.Show;
frmProgress.lblTotalBytesRead.Caption := IntToStr(TotalBytesRead);
frmProgress.lblTotalBytesRead.Caption:= IntToStr(TotalBytesRead);
frmProgress.ProgressBar1.Position := Trunc((TotalBytesRead/DiskSize)*100);

BytesWritten := fsImageName.Write(Buffer, BytesRead);
if BytesWritten = -1 then
Expand Down Expand Up @@ -1554,7 +1557,9 @@ function VerifyDDImage(fsImageName : TFileStream; ImageFileSize : Int64) : strin
strMD5Hash := '';
strSHA1Hash := '';
frmProgress.Show;
frmProgress.ProgressBar1.Position := 0;
frmProgress.Label7.Caption := ' Verifying DD image...please wait';
frmProgress.lblTotalBytesSource.Caption:= IntToStr(ImageFileSize);

// Initialise new hashing digests

Expand Down Expand Up @@ -1590,6 +1595,9 @@ function VerifyDDImage(fsImageName : TFileStream; ImageFileSize : Int64) : strin
begin
inc(TotalBytesRead, BytesRead);
MD5Update(MD5ctxImageVerification, Buffer, BytesRead);
frmProgress.Show;
frmProgress.lblTotalBytesRead.Caption:= IntToStr(TotalBytesRead);
frmProgress.ProgressBar1.Position := Trunc((TotalBytesRead/ImageFileSize)*100);
end;
until (TotalBytesRead = ImageFileSize) or (frmYaffi.Stop = true);

Expand Down Expand Up @@ -1619,6 +1627,9 @@ function VerifyDDImage(fsImageName : TFileStream; ImageFileSize : Int64) : strin
begin
inc(TotalBytesRead, BytesRead);
SHA1Update(SHA1ctxImageVerification, Buffer, BytesRead);
frmProgress.Show;
frmProgress.lblTotalBytesRead.Caption:= IntToStr(TotalBytesRead);
frmProgress.ProgressBar1.Position := Trunc((TotalBytesRead/ImageFileSize)*100);
end;
until (TotalBytesRead = ImageFileSize) or (frmYaffi.Stop = true);
SHA1Final(SHA1ctxImageVerification, SHA1ImageVerificationDigest);
Expand Down Expand Up @@ -1648,6 +1659,9 @@ function VerifyDDImage(fsImageName : TFileStream; ImageFileSize : Int64) : strin
inc(TotalBytesRead, BytesRead);
MD5Update(MD5ctxImageVerification, Buffer, BytesRead);
SHA1Update(SHA1ctxImageVerification, Buffer, BytesRead);
frmProgress.Show;
frmProgress.lblTotalBytesRead.Caption:= IntToStr(TotalBytesRead);
frmProgress.ProgressBar1.Position := Trunc((TotalBytesRead/ImageFileSize)*100);
end;
until (TotalBytesRead = ImageFileSize) or (frmYaffi.Stop = true);

Expand Down Expand Up @@ -1699,6 +1713,8 @@ function WindowsImageDiskE01(hDiskHandle : THandle; SegmentSize : Int64; DiskSiz
TotalBytesRead := 0;
TotalBytesWritten := 0;
CompressionChoice := -1;
frmProgress.ProgressBar1.Position := 0;
frmProgress.lblTotalBytesSource.Caption:= IntToStr(DiskSize);

// Create the libEWF instance and ensure the DLL is found
fLibEWF := TLibEWF.create;
Expand Down Expand Up @@ -1802,7 +1818,8 @@ function WindowsImageDiskE01(hDiskHandle : THandle; SegmentSize : Int64; DiskSiz
if BytesWritten > -1 then inc(TotalBytesWritten, BytesWritten);
end;
frmProgress.Show;
frmProgress.lblTotalBytesRead.Caption := IntToStr(TotalBytesRead);
frmProgress.lblTotalBytesRead.Caption:= IntToStr(TotalBytesRead);
frmProgress.ProgressBar1.Position := Trunc((TotalBytesRead/DiskSize)*100);
// Hash the bytes read and\or written using the algorithm required
// If the user sel;ected no hashing, break the loop immediately; faster
if HashChoice = 4 then
Expand Down Expand Up @@ -2001,6 +2018,9 @@ function VerifyE01Image(strImageName : widestring) : string;
begin
inc(TotalBytesRead, BytesRead);
MD5Update(MD5ctxImageVerification, Buffer, BytesRead);
frmProgress.Show;
frmProgress.lblTotalBytesRead.Caption:= IntToStr(TotalBytesRead);
frmProgress.ProgressBar1.Position := Trunc((TotalBytesRead/ImageFileSize)*100);
end;
Application.ProcessMessages;
until (TotalBytesRead = ImageFileSize) or (frmYaffi.Stop = true);
Expand Down Expand Up @@ -2030,6 +2050,9 @@ function VerifyE01Image(strImageName : widestring) : string;
begin
inc(TotalBytesRead, BytesRead);
SHA1Update(SHA1ctxImageVerification, Buffer, BytesRead);
frmProgress.Show;
frmProgress.lblTotalBytesRead.Caption:= IntToStr(TotalBytesRead);
frmProgress.ProgressBar1.Position := Trunc((TotalBytesRead/ImageFileSize)*100);
end;
Application.ProcessMessages;
until (TotalBytesRead = ImageFileSize) or (frmYaffi.Stop = true);
Expand Down Expand Up @@ -2060,6 +2083,9 @@ function VerifyE01Image(strImageName : widestring) : string;
inc(TotalBytesRead, BytesRead);
MD5Update(MD5ctxImageVerification, Buffer, BytesRead);
SHA1Update(SHA1ctxImageVerification, Buffer, BytesRead);
frmProgress.Show;
frmProgress.lblTotalBytesRead.Caption:= IntToStr(TotalBytesRead);
frmProgress.ProgressBar1.Position := Trunc((TotalBytesRead/ImageFileSize)*100);
end;
Application.ProcessMessages;
until (TotalBytesRead = ImageFileSize) or (frmYaffi.Stop = true);
Expand Down
1 change: 0 additions & 1 deletion yaffi.lpi
Expand Up @@ -86,7 +86,6 @@
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
<UseHeaptrc Value="True"/>
</Debugging>
<Options>
<Win32>
Expand Down
82 changes: 41 additions & 41 deletions yaffi.lps
Expand Up @@ -24,8 +24,8 @@
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<WindowIndex Value="1"/>
<TopLine Value="1174"/>
<CursorPos X="9" Y="1181"/>
<TopLine Value="2096"/>
<CursorPos X="43" Y="2117"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
Expand All @@ -37,7 +37,7 @@
<WindowIndex Value="1"/>
<TopLine Value="446"/>
<CursorPos Y="463"/>
<UsageCount Value="197"/>
<UsageCount Value="199"/>
</Unit2>
<Unit3>
<Filename Value="diskspecification.pas"/>
Expand All @@ -49,7 +49,7 @@
<EditorIndex Value="5"/>
<WindowIndex Value="1"/>
<CursorPos X="47" Y="22"/>
<UsageCount Value="57"/>
<UsageCount Value="59"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit3>
Expand All @@ -63,8 +63,8 @@
<EditorIndex Value="2"/>
<WindowIndex Value="1"/>
<TopLine Value="5"/>
<CursorPos X="40" Y="23"/>
<UsageCount Value="22"/>
<CursorPos X="32" Y="27"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit4>
Expand Down Expand Up @@ -168,138 +168,138 @@
<EditorIndex Value="3"/>
<WindowIndex Value="1"/>
<CursorPos X="41" Y="80"/>
<UsageCount Value="23"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="C:\lazarus\fpc\2.6.4\source\rtl\objpas\sysutils\intfh.inc"/>
<EditorIndex Value="4"/>
<WindowIndex Value="1"/>
<CursorPos X="22" Y="42"/>
<UsageCount Value="21"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit18>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="UYaffi.pas"/>
<Caret Line="680" Column="15" TopLine="652"/>
<Caret Line="1245" Column="21" TopLine="1217"/>
</Position1>
<Position2>
<Filename Value="UYaffi.pas"/>
<Caret Line="749" Column="23" TopLine="721"/>
<Caret Line="1246" Column="24" TopLine="1218"/>
</Position2>
<Position3>
<Filename Value="UYaffi.pas"/>
<Caret Line="750" Column="23" TopLine="722"/>
<Caret Line="1250" Column="42" TopLine="1222"/>
</Position3>
<Position4>
<Filename Value="UYaffi.pas"/>
<Caret Line="52" Column="87" TopLine="31"/>
<Caret Line="1257" Column="36" TopLine="1229"/>
</Position4>
<Position5>
<Filename Value="UYaffi.pas"/>
<Caret Line="1190" Column="41" TopLine="1173"/>
<Caret Line="1302" Column="20" TopLine="1274"/>
</Position5>
<Position6>
<Filename Value="UYaffi.pas"/>
<Caret Line="1206" Column="46" TopLine="1188"/>
<Caret Line="1310" Column="106" TopLine="1282"/>
</Position6>
<Position7>
<Filename Value="UYaffi.pas"/>
<Caret Line="1222" Column="33" TopLine="1204"/>
<Caret Line="1597" Column="11" TopLine="1576"/>
</Position7>
<Position8>
<Filename Value="UYaffi.pas"/>
<Caret Line="1242" Column="24" TopLine="1224"/>
<Caret Line="1405" Column="9" TopLine="1384"/>
</Position8>
<Position9>
<Filename Value="UYaffi.pas"/>
<Caret Line="1259" Column="31" TopLine="1241"/>
<Caret Line="68" Column="13" TopLine="50"/>
</Position9>
<Position10>
<Filename Value="UYaffi.pas"/>
<Caret Line="1399" Column="21" TopLine="1382"/>
<Caret Line="149" Column="18" TopLine="120"/>
</Position10>
<Position11>
<Filename Value="UYaffi.pas"/>
<Caret Line="1555" Column="15" TopLine="1539"/>
<Caret Line="159" Column="18" TopLine="130"/>
</Position11>
<Position12>
<Filename Value="UYaffi.pas"/>
<Caret Line="1802" Column="25" TopLine="1785"/>
<Caret Line="890" Column="20" TopLine="861"/>
</Position12>
<Position13>
<Filename Value="UYaffi.pas"/>
<Caret Line="1982" Column="21" TopLine="1965"/>
<Caret Line="922" Column="33" TopLine="894"/>
</Position13>
<Position14>
<Filename Value="UYaffi.pas"/>
<Caret Line="1190" Column="18" TopLine="1173"/>
<Caret Line="923" Column="35" TopLine="895"/>
</Position14>
<Position15>
<Filename Value="UYaffi.pas"/>
<Caret Line="1205" Column="24" TopLine="1177"/>
<Caret Line="925" Column="26" TopLine="897"/>
</Position15>
<Position16>
<Filename Value="UYaffi.pas"/>
<Caret Line="1221" Column="32" TopLine="1193"/>
<Caret Line="1114" Column="40" TopLine="1085"/>
</Position16>
<Position17>
<Filename Value="UYaffi.pas"/>
<Caret Line="1241" Column="23" TopLine="1213"/>
<Caret Line="1134" Column="20" TopLine="1106"/>
</Position17>
<Position18>
<Filename Value="UYaffi.pas"/>
<Caret Line="1258" Column="30" TopLine="1230"/>
<Caret Line="1209" Column="22" TopLine="1181"/>
</Position18>
<Position19>
<Filename Value="UYaffi.pas"/>
<Caret Line="1399" Column="9" TopLine="1371"/>
<Caret Line="1210" Column="25" TopLine="1182"/>
</Position19>
<Position20>
<Filename Value="UYaffi.pas"/>
<Caret Line="1400" Column="20" TopLine="1372"/>
<Caret Line="1213" Column="43" TopLine="1185"/>
</Position20>
<Position21>
<Filename Value="UYaffi.pas"/>
<Caret Line="1556" Column="20" TopLine="1527"/>
<Caret Line="1220" Column="38" TopLine="1192"/>
</Position21>
<Position22>
<Filename Value="UYaffi.pas"/>
<Caret Line="1557" Column="14" TopLine="1528"/>
<Caret Line="1245" Column="21" TopLine="1217"/>
</Position22>
<Position23>
<Filename Value="UYaffi.pas"/>
<Caret Line="1804" Column="30" TopLine="1776"/>
<Caret Line="1246" Column="24" TopLine="1218"/>
</Position23>
<Position24>
<Filename Value="UYaffi.pas"/>
<Caret Line="1805" Column="24" TopLine="1777"/>
<Caret Line="1250" Column="42" TopLine="1222"/>
</Position24>
<Position25>
<Filename Value="UYaffi.pas"/>
<Caret Line="1985" Column="26" TopLine="1957"/>
<Caret Line="1257" Column="36" TopLine="1229"/>
</Position25>
<Position26>
<Filename Value="uprogress.pas"/>
<Caret Line="4" Column="12"/>
<Filename Value="UYaffi.pas"/>
<Caret Line="1302" Column="20" TopLine="1274"/>
</Position26>
<Position27>
<Filename Value="uprogress.pas"/>
<Caret Line="22" Column="32" TopLine="6"/>
<Filename Value="UYaffi.pas"/>
<Caret Line="1310" Column="106" TopLine="1282"/>
</Position27>
<Position28>
<Filename Value="UYaffi.pas"/>
<Caret Line="1977" Column="43" TopLine="1958"/>
<Caret Line="2051" Column="23" TopLine="2017"/>
</Position28>
<Position29>
<Filename Value="UYaffi.pas"/>
<Caret Line="1190" Column="20" TopLine="1174"/>
<Caret Line="1561" Column="69" TopLine="1549"/>
</Position29>
<Position30>
<Filename Value="uprogress.pas"/>
<Caret Line="22" Column="32" TopLine="5"/>
<Filename Value="UYaffi.pas"/>
<Caret Line="1339" Column="25" TopLine="1338"/>
</Position30>
</JumpHistory>
</ProjectSession>
Expand Down

0 comments on commit 044255e

Please sign in to comment.