ImageEn, unit imageenview |
|
TImageEnView.OnProgress
Declaration
property OnProgress: TIEProgressEvent;
Description
The OnProgress event is called when image processing or input/output operations are executed. If you use it to update a progress bar then you can reset it in the
OnFinishWork event.
You can use
ProgressTask to determine what action is underway.
Alternatively, check the class of the Sender:
◼TImageEnIO: I/O task, e.g. loading/saving images (ietLoading, ietSaving, ietOtherIO, ietAcquisition)
◼TImageEnProc: Image processing task, e.g. rotating the image (ietProcessing, ietAnalysis, ietResampling, ietRotating)
◼TImageEnView (Uncommon): General processing task, e.g.
merging all layers or
searching a PDF document (ietLayers, ietSearching)
Example code:
if Sender is TImageEnView then
MainForm.Caption := format( 'Layer Task Progress: %d%%', [ per ])
else
if Sender is TImageEnIO then
MainForm.Caption := format( 'IO Task Progress: %d%%', [ per ])
else
if Sender is TImageEnProc then
MainForm.Caption := format( 'Processing Task Progress: %d%%', [ per ]);
Note: To ensure your UI is responsive during processing, you can call Application.ProcessMessages() in the OnProgress event.
// Showing separate progress display for I/O operations and processing operations
procedure TMainForm.ImageEnView1Progress(Sender: TObject; per: Integer);
begin
// I/O PROGRESS
if Sender is TImageEnIO then
begin
IOProgressBar.Position := per;
IOProgressBar.Visible := True;
end
else
// IMAGE PROCESSING PROGRESS
if Sender is TImageEnProc then
begin
ProcProgressBar.Position := per;
ProcProgressBar.Visible := True;
end;
end;
// Hide the progress bar
procedure TMainForm.ImageEnView1FinishWork(Sender: TObject);
begin
// I/O PROGRESS
if Sender is TImageEnIO then
IOProgressBar.Visible := False
else
// IMAGE PROCESSING PROGRESS
if Sender is TImageEnProc then
ProcProgressBar.Visible := False;
end;
// Showing detailed progress display
procedure TMainForm.ImageEnView1Progress(Sender: TObject; per: Integer);
begin
case ImageEnView1.ProgressTask of
ietLoading : Caption := format( 'Loading - %d%%', [per] );
ietSaving : Caption := format( 'Saving - %d%%', [per] );
ietOtherIO : Caption := format( 'Writing - %d%%', [per] );
ietAcquisition : Caption := format( 'Acquiring - %d%%', [per] );
ietProcessing : Caption := format( 'Processing - %d%%', [per] );
ietAnalysis : Caption := format( 'Analyzing - %d%%', [per] );
ietResampling : Caption := format( 'Resizing - %d%%', [per] );
ietRotating : Caption := format( 'Rotating - %d%%', [per] );
ietLayers : Caption := format( 'Merging - %d%%', [per] );
ietSearching : Caption := format( 'Searching - %d%%', [per] );
else Caption := format( 'Processing - %d%%', [per] ); // Should not occur
end;
end;