SynchronizeProgress.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. FMinimizedByMe = false;
  24. }
  25. //---------------------------------------------------------------------------
  26. __fastcall TSynchronizeProgressForm::~TSynchronizeProgressForm()
  27. {
  28. if (IsIconic(Application->Handle) && FMinimizedByMe)
  29. {
  30. Application->Restore();
  31. }
  32. ReleaseAsModal(this, FShowAsModalStorage);
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TSynchronizeProgressForm::Start()
  36. {
  37. FStarted = true;
  38. FStartTime = Now();
  39. UpdateTimer->Enabled = true;
  40. StartTimeLabel->Caption = FStartTime.TimeString();
  41. ShowAsModal(this, FShowAsModalStorage);
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TSynchronizeProgressForm::Stop()
  45. {
  46. HideAsModal(this, FShowAsModalStorage);
  47. FStarted = false;
  48. UpdateTimer->Enabled = false;
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TSynchronizeProgressForm::SetData(const AnsiString LocalDirectory,
  52. const AnsiString RemoteDirectory, bool & Continue)
  53. {
  54. assert(FStarted);
  55. LocalDirectoryLabel->Caption = LocalDirectory;
  56. RemoteDirectoryLabel->Caption = RemoteDirectory;
  57. Continue = !FCanceled;
  58. UpdateControls();
  59. Application->ProcessMessages();
  60. }
  61. //---------------------------------------------------------------------------
  62. void __fastcall TSynchronizeProgressForm::UpdateControls()
  63. {
  64. if (FStarted)
  65. {
  66. FElapsed = Now() - FStartTime;
  67. }
  68. TimeElapsedLabel->Caption = FormatDateTime(Configuration->TimeFormat, FElapsed);
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TSynchronizeProgressForm::CancelButtonClick(TObject * /*Sender*/)
  72. {
  73. if (!FCanceled && (MessageDialog(LoadStr(CANCEL_OPERATION), qtConfirmation,
  74. qaOK | qaCancel, 0) == qaOK))
  75. {
  76. FCanceled = true;
  77. }
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TSynchronizeProgressForm::UpdateTimerTimer(TObject * /*Sender*/)
  81. {
  82. UpdateControls();
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TSynchronizeProgressForm::MinimizeButtonClick(
  86. TObject * /*Sender*/)
  87. {
  88. Application->Minimize();
  89. FMinimizedByMe = true;
  90. }
  91. //---------------------------------------------------------------------------