Progress.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //----------------------------------------------------------------------------
  2. #ifndef ProgressH
  3. #define ProgressH
  4. //----------------------------------------------------------------------------
  5. #include "PathLabel.hpp"
  6. #include <System.Classes.hpp>
  7. #include <Vcl.ComCtrls.hpp>
  8. #include <Vcl.Controls.hpp>
  9. #include <Vcl.ExtCtrls.hpp>
  10. #include <Vcl.StdCtrls.hpp>
  11. //----------------------------------------------------------------------------
  12. #include <FileOperationProgress.h>
  13. #include <Vcl.Menus.hpp>
  14. #include "PngImageList.hpp"
  15. #include <Vcl.Imaging.pngimage.hpp>
  16. #include <Vcl.ImgList.hpp>
  17. //----------------------------------------------------------------------------
  18. #include <GUITools.h>
  19. #include "TB2Dock.hpp"
  20. #include "TB2Item.hpp"
  21. #include "TB2Toolbar.hpp"
  22. #include "TBX.hpp"
  23. #include "TB2ExtItems.hpp"
  24. #include "TBXExtItems.hpp"
  25. #include <list>
  26. //----------------------------------------------------------------------------
  27. class TProgressForm : public TForm
  28. {
  29. __published:
  30. TPanel *MainPanel;
  31. TLabel *PathLabel;
  32. TPathLabel *FileLabel;
  33. TLabel *TargetLabel;
  34. TPathLabel *TargetPathLabel;
  35. TProgressBar *TopProgress;
  36. TPanel *TransferPanel;
  37. TLabel *Label3;
  38. TLabel *TimeElapsedLabel;
  39. TLabel *StartTimeLabelLabel;
  40. TLabel *StartTimeLabel;
  41. TLabel *Label4;
  42. TLabel *BytesTransferedLabel;
  43. TLabel *Label12;
  44. TLabel *CPSLabel;
  45. TProgressBar *BottomProgress;
  46. TTimer *UpdateTimer;
  47. TLabel *TimeLeftLabelLabel;
  48. TLabel *TimeLeftLabel;
  49. TPaintBox *AnimationPaintBox;
  50. TPngImageList *ImageList;
  51. TPanel *ToolbarPanel;
  52. TTBXDock *Dock;
  53. TTBXToolbar *Toolbar;
  54. TTBXItem *CancelItem;
  55. TTBXItem *MinimizeItem;
  56. TTBXItem *MoveToQueueItem;
  57. TTBXSubmenuItem *CycleOnceDoneItem;
  58. TTBXItem *IdleOnceDoneItem;
  59. TTBXItem *DisconnectOnceDoneItem;
  60. TTBXItem *SuspendOnceDoneItem;
  61. TTBXItem *ShutDownOnceDoneItem;
  62. TTBXComboBoxItem *SpeedComboBoxItem;
  63. TPanel *ComponentsPanel;
  64. TPngImageList *ImageList120;
  65. TPngImageList *ImageList144;
  66. TPngImageList *ImageList192;
  67. void __fastcall UpdateTimerTimer(TObject *Sender);
  68. void __fastcall FormShow(TObject *Sender);
  69. void __fastcall FormHide(TObject *Sender);
  70. void __fastcall CancelItemClick(TObject *Sender);
  71. void __fastcall MinimizeItemClick(TObject *Sender);
  72. void __fastcall MoveToQueueItemClick(TObject *Sender);
  73. void __fastcall OnceDoneItemClick(TObject *Sender);
  74. void __fastcall CycleOnceDoneItemClick(TObject *Sender);
  75. void __fastcall SpeedComboBoxItemAcceptText(TObject *Sender, UnicodeString &NewText,
  76. bool &Accept);
  77. void __fastcall SpeedComboBoxItemItemClick(TObject *Sender);
  78. void __fastcall SpeedComboBoxItemAdjustImageIndex(TTBXComboBoxItem *Sender, const UnicodeString AText,
  79. int AIndex, int &ImageIndex);
  80. void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift);
  81. private:
  82. TCancelStatus FCancel;
  83. bool FMoveToQueue;
  84. TFileOperationProgressType FData;
  85. bool FDataGot;
  86. bool FDataReceived;
  87. TFileOperation FLastOperation;
  88. bool FLastTotalSizeSet;
  89. bool FMinimizedByMe;
  90. int FUpdateCounter;
  91. bool FAsciiTransferChanged;
  92. bool FResumeStatusChanged;
  93. void * FShowAsModalStorage;
  94. bool FDeleteToRecycleBin;
  95. bool FReadOnly;
  96. unsigned long FCPSLimit;
  97. TProgressBar * FOperationProgress;
  98. TProgressBar * FFileProgress;
  99. TDateTime FStarted;
  100. int FSinceLastUpdate;
  101. bool FModalBeginHooked;
  102. TNotifyEvent FPrevApplicationModalBegin;
  103. int FModalLevel;
  104. TFrameAnimation FFrameAnimation;
  105. typedef BiDiMap<TOnceDoneOperation, TTBCustomItem *> TOnceDoneItems;
  106. TOnceDoneItems FOnceDoneItems;
  107. void __fastcall SetOnceDoneOperation(TOnceDoneOperation value);
  108. TTBCustomItem * __fastcall CurrentOnceDoneItem();
  109. TOnceDoneOperation __fastcall GetOnceDoneOperation();
  110. void __fastcall SetOnceDoneItem(TTBCustomItem * Item);
  111. void __fastcall SetAllowMinimize(bool value);
  112. bool __fastcall GetAllowMinimize();
  113. void __fastcall SetReadOnly(bool value);
  114. void __fastcall GlobalMinimize(TObject * Sender);
  115. void __fastcall ApplicationModalBegin(TObject * Sender);
  116. UnicodeString __fastcall ItemSpeed(const UnicodeString & Text, TTBXComboBoxItem * Item);
  117. bool __fastcall ApplicationHook(TMessage & Message);
  118. protected:
  119. void __fastcall CancelOperation();
  120. void __fastcall UpdateControls();
  121. void __fastcall ResetOnceDoneOperation();
  122. bool __fastcall ReceiveData(bool Force, int ModalLevelOffset);
  123. void __fastcall Minimize(TObject * Sender);
  124. virtual void __fastcall Dispatch(void * Message);
  125. static bool __fastcall IsIndetermiateOperation(TFileOperation Operation);
  126. public:
  127. static UnicodeString __fastcall ProgressStr(TFileOperationProgressType * ProgressData);
  128. virtual __fastcall TProgressForm(TComponent * AOwner, bool AllowMoveToQueue);
  129. virtual __fastcall ~TProgressForm();
  130. void __fastcall SetProgressData(TFileOperationProgressType & AData);
  131. __property TCancelStatus Cancel = { read = FCancel };
  132. __property bool MoveToQueue = { read = FMoveToQueue };
  133. __property TOnceDoneOperation OnceDoneOperation = { read=GetOnceDoneOperation, write=SetOnceDoneOperation };
  134. __property bool AllowMinimize = { read=GetAllowMinimize, write=SetAllowMinimize };
  135. __property bool DeleteToRecycleBin = { read=FDeleteToRecycleBin, write=FDeleteToRecycleBin };
  136. __property bool ReadOnly = { read=FReadOnly, write=SetReadOnly };
  137. };
  138. //----------------------------------------------------------------------------
  139. #endif