This commit is contained in:
meffi@lab313.ru
2014-05-07 00:42:00 +00:00
parent fb3863f3c6
commit c130db80a7
6 changed files with 56 additions and 51 deletions

View File

@@ -23,8 +23,8 @@
<UnitName Value="umain"/> <UnitName Value="umain"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="362"/> <TopLine Value="787"/>
<CursorPos X="48" Y="368"/> <CursorPos X="42" Y="802"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
@@ -48,10 +48,10 @@
<Filename Value="ucommon.pas"/> <Filename Value="ucommon.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucommon"/> <UnitName Value="ucommon"/>
<EditorIndex Value="2"/> <EditorIndex Value="3"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="17"/>
<CursorPos X="45" Y="10"/> <CursorPos X="20" Y="35"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit4> </Unit4>
@@ -59,7 +59,7 @@
<Filename Value="utim.pas"/> <Filename Value="utim.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="utim"/> <UnitName Value="utim"/>
<EditorIndex Value="9"/> <EditorIndex Value="10"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="185"/> <TopLine Value="185"/>
<CursorPos X="1" Y="204"/> <CursorPos X="1" Y="204"/>
@@ -70,7 +70,7 @@
<Filename Value="ucdimage.pas"/> <Filename Value="ucdimage.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucdimage"/> <UnitName Value="ucdimage"/>
<EditorIndex Value="1"/> <EditorIndex Value="2"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="112"/> <TopLine Value="112"/>
<CursorPos X="50" Y="117"/> <CursorPos X="50" Y="117"/>
@@ -81,7 +81,7 @@
<Filename Value="usettings.pas"/> <Filename Value="usettings.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="usettings"/> <UnitName Value="usettings"/>
<EditorIndex Value="8"/> <EditorIndex Value="9"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="41"/> <TopLine Value="41"/>
<CursorPos X="60" Y="56"/> <CursorPos X="60" Y="56"/>
@@ -92,10 +92,10 @@
<Filename Value="uscanresult.pas"/> <Filename Value="uscanresult.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uscanresult"/> <UnitName Value="uscanresult"/>
<EditorIndex Value="6"/> <EditorIndex Value="7"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="35"/>
<CursorPos X="10" Y="5"/> <CursorPos X="79" Y="80"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit8> </Unit8>
@@ -103,11 +103,10 @@
<Filename Value="uscanthread.pas"/> <Filename Value="uscanthread.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uscanthread"/> <UnitName Value="uscanthread"/>
<IsVisibleTab Value="True"/> <EditorIndex Value="8"/>
<EditorIndex Value="7"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="171"/> <TopLine Value="178"/>
<CursorPos X="79" Y="182"/> <CursorPos X="72" Y="197"/>
<UsageCount Value="816"/> <UsageCount Value="816"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit9> </Unit9>
@@ -115,7 +114,7 @@
<Filename Value="ucpucount.pas"/> <Filename Value="ucpucount.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="ucpucount"/> <UnitName Value="ucpucount"/>
<EditorIndex Value="3"/> <EditorIndex Value="4"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="19"/> <TopLine Value="19"/>
<CursorPos X="87" Y="34"/> <CursorPos X="87" Y="34"/>
@@ -126,7 +125,7 @@
<Filename Value="udrawtim.pas"/> <Filename Value="udrawtim.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="udrawtim"/> <UnitName Value="udrawtim"/>
<EditorIndex Value="4"/> <EditorIndex Value="5"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="15" Y="6"/> <CursorPos X="15" Y="6"/>
@@ -145,20 +144,23 @@
<Unit13> <Unit13>
<Filename Value="todos.inc"/> <Filename Value="todos.inc"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="48" Y="2"/> <CursorPos X="44" Y="3"/>
<UsageCount Value="802"/> <UsageCount Value="802"/>
<Loaded Value="True"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
<Filename Value="uexportimport.pas"/> <Filename Value="uexportimport.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="uexportimport"/> <UnitName Value="uexportimport"/>
<EditorIndex Value="5"/> <EditorIndex Value="6"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="7"/> <TopLine Value="7"/>
<CursorPos X="20" Y="16"/> <CursorPos X="20" Y="16"/>
<UsageCount Value="71"/> <UsageCount Value="72"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit14> </Unit14>
</Units> </Units>
@@ -187,7 +189,7 @@
<WatchScope Value="wpsLocal"/> <WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/> <WatchKind Value="wpkWrite"/>
<Source Value="umain.pas"/> <Source Value="umain.pas"/>
<Line Value="812"/> <Line Value="797"/>
</Item3> </Item3>
</BreakPoints> </BreakPoints>
<Watches Count="3"> <Watches Count="3">

View File

@@ -1,2 +1,3 @@
{ TODO : Zooming? } { TODO : Zooming? }
{ TODO : Add different PNG output for Export. } { TODO : Add file to filelist }
{ TODO : StartScan - remove refs to umain }

View File

@@ -584,8 +584,9 @@ object frmMain: TfrmMain
Align = alClient Align = alClient
Columns = < Columns = <
item item
AutoSize = True
Caption = '# / 0' Caption = '# / 0'
Width = 60 Width = 41
end end
item item
Alignment = taCenter Alignment = taCenter
@@ -603,7 +604,7 @@ object frmMain: TfrmMain
Alignment = taCenter Alignment = taCenter
AutoSize = True AutoSize = True
Caption = 'W x H' Caption = 'W x H'
Width = 91 Width = 128
end> end>
ColumnClick = False ColumnClick = False
GridLines = True GridLines = True

View File

@@ -179,7 +179,6 @@ type
{ public declarations } { public declarations }
ScanResults: TScanResultList; //List of finished scan results ScanResults: TScanResultList; //List of finished scan results
ScanThreads: TScanThreadList; //List of currently started scans ScanThreads: TScanThreadList; //List of currently started scans
function CheckForFileOpened(const FileName: string): boolean;
end; end;
var var
@@ -774,20 +773,6 @@ begin
Result^.HEAD^.bBPP := Integer(cbbBitMode.Tag); Result^.HEAD^.bBPP := Integer(cbbBitMode.Tag);
end; end;
function TfrmMain.CheckForFileOpened(const FileName: string): boolean;
var
I: Integer;
begin
Result := False;
for I := 1 to ScanResults.Count do
if ScanResults[I - 1].ScanFile = FileName then
begin
Result := True;
Exit;
end;
end;
procedure TfrmMain.ScanPath(const Path: string); procedure TfrmMain.ScanPath(const Path: string);
begin begin
if Path = '' then Exit; if Path = '' then Exit;
@@ -806,7 +791,7 @@ begin
LastDir := ExtractFilePath(FileName); LastDir := ExtractFilePath(FileName);
Settings.LastDir := LastDir; Settings.LastDir := LastDir;
if CheckForFileOpened(FileName) then if CheckForFileOpened(@ScanResults, FileName) then
begin begin
cbbFiles.ItemIndex := cbbFiles.Items.IndexOf(FileName); cbbFiles.ItemIndex := cbbFiles.Items.IndexOf(FileName);
actChangeFile.Execute; actChangeFile.Execute;
@@ -818,7 +803,7 @@ begin
if not Boolean(actStopScan.Tag) then if not Boolean(actStopScan.Tag) then
begin begin
ScanThreads.Add(TScanThread.Create(FileName, GetImageScan(FileName))); ScanThreads.Add(TScanThread.Create(FileName, GetImageScan(FileName), @ScanResults));
ScanThreads.Last.FreeOnTerminate := True; ScanThreads.Last.FreeOnTerminate := True;
ScanThreads.Last.Priority := tpNormal; ScanThreads.Last.Priority := tpNormal;
ScanThreads.Last.OnTerminate := @ScanFinished; ScanThreads.Last.OnTerminate := @ScanFinished;

View File

@@ -39,6 +39,9 @@ type
property ScanTim[index: Integer]: TTimInfo read fGetTim write fSetTim; property ScanTim[index: Integer]: TTimInfo read fGetTim write fSetTim;
end; end;
TScanResultList = specialize TFPGObjectList<TScanResult>; TScanResultList = specialize TFPGObjectList<TScanResult>;
PScanResultList = ^TScanResultList;
function CheckForFileOpened(ScanResults: PScanResultList; const FileName: string): boolean;
implementation implementation
@@ -77,4 +80,18 @@ begin
pTims[Index] := Value; pTims[Index] := Value;
end; end;
end. function CheckForFileOpened(ScanResults: PScanResultList; const FileName: string): boolean;
var
I: Integer;
begin
Result := False;
for I := 1 to ScanResults^.Count do
if ScanResults^[I - 1].ScanFile = FileName then
begin
Result := True;
Exit;
end;
end;
end.

View File

@@ -10,6 +10,7 @@ type
private private
{ Private declarations } { Private declarations }
pScanResult: TScanResult; pScanResult: TScanResult;
pResults: PScanResultList;
pFileSize: Integer; pFileSize: Integer;
pFilePos: Integer; pFilePos: Integer;
pStatusText: string; pStatusText: string;
@@ -27,7 +28,7 @@ type
protected protected
procedure Execute; override; procedure Execute; override;
public public
constructor Create(const FileToScan: string; ImageScan: boolean); constructor Create(const FileToScan: string; ImageScan: boolean; Results: PScanResultList);
//property Started: boolean read pStarted write pStarted; //property Started: boolean read pStarted write pStarted;
property StopScan: boolean read pStopScan write pStopScan; property StopScan: boolean read pStopScan write pStopScan;
end; end;
@@ -44,7 +45,7 @@ const
{ TScanThread } { TScanThread }
constructor TScanThread.Create(const FileToScan: string; ImageScan: boolean); constructor TScanThread.Create(const FileToScan: string; ImageScan: boolean; Results: PScanResultList);
begin begin
inherited Create(True); inherited Create(True);
FreeOnTerminate := True; FreeOnTerminate := True;
@@ -57,6 +58,7 @@ begin
pScanResult := TScanResult.Create; pScanResult := TScanResult.Create;
pScanResult.ScanFile := FileToScan; pScanResult.ScanFile := FileToScan;
pScanResult.IsImage := ImageScan; pScanResult.IsImage := ImageScan;
pResults := Results;
end; end;
procedure TScanThread.AddResult(TIM: PTIM); procedure TScanThread.AddResult(TIM: PTIM);
@@ -170,7 +172,7 @@ begin
pFilePos := 0; pFilePos := 0;
pStatusText := ''; pStatusText := '';
Synchronize(@FinishScan); FinishScan;
end; end;
procedure TScanThread.FinishScan; procedure TScanThread.FinishScan;
@@ -184,11 +186,8 @@ begin
Exit; Exit;
end; end;
if not frmMain.CheckForFileOpened(pScanResult.ScanFile) then if not CheckForFileOpened(pResults, pScanResult.ScanFile) then
begin pResults^.Add(pScanResult)
frmMain.ScanResults.Add(pScanResult);
frmMain.cbbFiles.Items.Add(pScanResult.ScanFile);
end
else else
pScanResult.Free; pScanResult.Free;
end; end;
@@ -230,4 +229,4 @@ begin
end; end;
end; end;
end. end.