| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include <WinInterface.h>
- #include "SynchronizeProgress.h"
- #include <Common.h>
- #include <Configuration.h>
- #include <ScpMain.h>
- #include <TextsWin.h>
- #include <VCLCommon.h>
- #include <GUITools.h>
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "PathLabel"
- #pragma resource "*.dfm"
- //---------------------------------------------------------------------------
- __fastcall TSynchronizeProgressForm::TSynchronizeProgressForm(TComponent * Owner,
- bool AllowMinimize)
- : TForm(Owner)
- {
- FStarted = false;
- FCanceled = false;
- FElapsed = EncodeTime(0, 0, 0, 0);
- FShowAsModalStorage = NULL;
- FMinimizedByMe = false;
- if (!AllowMinimize)
- {
- CancelButton->Left = CancelButton->Left +
- (MinimizeButton->Left - CancelButton->Left) / 2;
- MinimizeButton->Visible = false;
- }
- }
- //---------------------------------------------------------------------------
- __fastcall TSynchronizeProgressForm::~TSynchronizeProgressForm()
- {
- if (IsIconic(Application->Handle) && FMinimizedByMe)
- {
- Application->Restore();
- }
- ReleaseAsModal(this, FShowAsModalStorage);
- }
- //---------------------------------------------------------------------------
- void __fastcall TSynchronizeProgressForm::Start()
- {
- FStarted = true;
- FStartTime = Now();
- UpdateTimer->Enabled = true;
- StartTimeLabel->Caption = FStartTime.TimeString();
- ShowAsModal(this, FShowAsModalStorage);
- }
- //---------------------------------------------------------------------------
- void __fastcall TSynchronizeProgressForm::Stop()
- {
- HideAsModal(this, FShowAsModalStorage);
- FStarted = false;
- UpdateTimer->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TSynchronizeProgressForm::SetData(const AnsiString LocalDirectory,
- const AnsiString RemoteDirectory, bool & Continue)
- {
- assert(FStarted);
- LocalDirectoryLabel->Caption = LocalDirectory;
- RemoteDirectoryLabel->Caption = RemoteDirectory;
- Continue = !FCanceled;
-
- UpdateControls();
- Application->ProcessMessages();
- }
- //---------------------------------------------------------------------------
- void __fastcall TSynchronizeProgressForm::UpdateControls()
- {
- if (FStarted)
- {
- FElapsed = Now() - FStartTime;
- }
- TimeElapsedLabel->Caption = FormatDateTimeSpan(Configuration->TimeFormat, FElapsed);
- }
- //---------------------------------------------------------------------------
- void __fastcall TSynchronizeProgressForm::CancelButtonClick(TObject * /*Sender*/)
- {
- if (!FCanceled && (MessageDialog(LoadStr(CANCEL_OPERATION), qtConfirmation,
- qaOK | qaCancel, HELP_NONE) == qaOK))
- {
- FCanceled = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TSynchronizeProgressForm::UpdateTimerTimer(TObject * /*Sender*/)
- {
- UpdateControls();
- }
- //---------------------------------------------------------------------------
- void __fastcall TSynchronizeProgressForm::MinimizeButtonClick(
- TObject * /*Sender*/)
- {
- Application->Minimize();
- FMinimizedByMe = true;
- }
- //---------------------------------------------------------------------------
|