SynchronizeProgress.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "SynchronizeProgress.h"
  5. #include <Common.h>
  6. #include <Configuration.h>
  7. #include <ScpMain.h>
  8. #include <TextsWin.h>
  9. #include <WinInterface.h>
  10. #include <VCLCommon.h>
  11. //---------------------------------------------------------------------------
  12. #pragma package(smart_init)
  13. #pragma link "PathLabel"
  14. #pragma resource "*.dfm"
  15. //---------------------------------------------------------------------------
  16. __fastcall TSynchronizeProgressForm::TSynchronizeProgressForm(TComponent* Owner)
  17. : TForm(Owner)
  18. {
  19. FStarted = false;
  20. FCanceled = false;
  21. FElapsed = EncodeTime(0, 0, 0, 0);
  22. FShowAsModalStorage = NULL;
  23. }
  24. //---------------------------------------------------------------------------
  25. __fastcall TSynchronizeProgressForm::~TSynchronizeProgressForm()
  26. {
  27. ReleaseAsModal(this, FShowAsModalStorage);
  28. }
  29. //---------------------------------------------------------------------------
  30. void __fastcall TSynchronizeProgressForm::Start()
  31. {
  32. FStarted = true;
  33. FStartTime = Now();
  34. UpdateTimer->Enabled = true;
  35. StartTimeLabel->Caption = FStartTime.TimeString();
  36. ShowAsModal(this, FShowAsModalStorage);
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall TSynchronizeProgressForm::Stop()
  40. {
  41. HideAsModal(this, FShowAsModalStorage);
  42. FStarted = false;
  43. UpdateTimer->Enabled = false;
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TSynchronizeProgressForm::SetData(const AnsiString LocalDirectory,
  47. const AnsiString RemoteDirectory, bool & Continue)
  48. {
  49. assert(FStarted);
  50. LocalDirectoryLabel->Caption = LocalDirectory;
  51. RemoteDirectoryLabel->Caption = RemoteDirectory;
  52. Continue = !FCanceled;
  53. UpdateControls();
  54. Application->ProcessMessages();
  55. }
  56. //---------------------------------------------------------------------------
  57. void __fastcall TSynchronizeProgressForm::UpdateControls()
  58. {
  59. if (FStarted)
  60. {
  61. FElapsed = Now() - FStartTime;
  62. }
  63. TimeElapsedLabel->Caption = FormatDateTime(Configuration->TimeFormat, FElapsed);
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TSynchronizeProgressForm::CancelButtonClick(TObject * /*Sender*/)
  67. {
  68. if (!FCanceled && (MessageDialog(LoadStr(CANCEL_OPERATION), qtConfirmation,
  69. qaOK | qaCancel, 0) == qaOK))
  70. {
  71. FCanceled = true;
  72. }
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TSynchronizeProgressForm::UpdateTimerTimer(TObject * /*Sender*/)
  76. {
  77. UpdateControls();
  78. }
  79. //---------------------------------------------------------------------------