FrmCctvCamViewerF.cpp 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "FrmInitializeF.h"
  5. #include "DMDbF.h"
  6. #pragma hdrstop
  7. #include "CDSMonitoringObjF.h"
  8. #include "FrmCctvCamViewerF.h"
  9. #include "FrmCameraFullScreenF.h"
  10. #include "FrmCameraPlayerF.h"
  11. #include "FrmCameraScreenF.h"
  12. #include "FrmCameraScreenManagerF.h"
  13. //---------------------------------------------------------------------------
  14. #pragma package(smart_init)
  15. #pragma link "cxButtons"
  16. #pragma link "cxContainer"
  17. #pragma link "cxControls"
  18. #pragma link "cxEdit"
  19. #pragma link "cxGraphics"
  20. #pragma link "cxLookAndFeelPainters"
  21. #pragma link "cxLookAndFeels"
  22. #pragma link "cxProgressBar"
  23. #pragma link "dxSkinBlack"
  24. #pragma link "dxSkinBlue"
  25. #pragma link "dxSkinsCore"
  26. #pragma link "dxSkinsForm"
  27. #pragma link "cxLabel"
  28. #pragma link "cxDropDownEdit"
  29. #pragma link "cxMaskEdit"
  30. #pragma link "cxTextEdit"
  31. #pragma resource "*.dfm"
  32. TFrmCctvCamViewer *FrmCctvCamViewer = NULL;
  33. //---------------------------------------------------------------------------
  34. __fastcall TFrmCctvCamViewer::TFrmCctvCamViewer(TComponent* Owner)
  35. : TForm(Owner)//TdxCustomRibbonForm(Owner)//TForm(Owner)
  36. {
  37. //DoubleBuffered = true;
  38. IsLoading = false;
  39. if (g_AppCfg.sLang != "kr")
  40. {
  41. Caption = "CCTV Camera Monitoring";
  42. Font->Name = "Tahoma";
  43. BtnMonitoringMngr->Font->Name = "Tahoma";
  44. BtnMonitoringMngr->Caption = "Management";
  45. BtnMonitoringMngr->Hint = "Monitoring Screen management";
  46. LblScreenList->AutoSize = false;
  47. LblScreenList->Style->Font->Name = "Tahoma";
  48. LblScreenList->Caption = " Screen List: ";
  49. LblScreenList->AutoSize = true;
  50. CbScreenList->Style->Font->Name = "Tahoma";
  51. }
  52. g_AppCfg.lMainWinHandle = (long)Handle;
  53. String sLang = g_AppCfg.sLang;
  54. ITSSkin_Initialize(Application, sLang.UpperCase());
  55. ITSSkin_Load(this);
  56. ITSSkin_Caption(false);
  57. CMM_LoadForm(g_sFormsDir, this);
  58. if (WindowState == wsMinimized)
  59. {
  60. WindowState = wsMaximized;
  61. }
  62. if (WindowState == wsMaximized)
  63. {
  64. Width = 1375;
  65. Height = 851;
  66. WindowState = wsMaximized;
  67. }
  68. SetColorScheme(g_AppCfg.sSkinName);
  69. //PnlBack->ParentColor = false;
  70. //PnlBack->Color = clBlack;
  71. //PnlBack->Font->Color = clWhite;
  72. IsFormResizing = false;
  73. FOldWidth = Width;
  74. FOldHeight= Height;
  75. FCurrPage = NULL;
  76. }
  77. //---------------------------------------------------------------------------
  78. void __fastcall TFrmCctvCamViewer::FormCreate(TObject *Sender)
  79. {
  80. Application->ShowMainForm = false;
  81. try {
  82. Application->Icon->LoadFromResourceName(((unsigned int)HInstance), "MAINICON");
  83. } catch(...) { ShowMessage("LoadFromResourceName failed"); }
  84. g_AppCfg.lMainWinHandle = (long)Handle;
  85. FrmCameraScreen = new TFrmCameraScreen(PnlBack);
  86. FrmCameraScreen->Parent = PnlBack;
  87. FrmCameraScreen->Show();
  88. Application->ShowMainForm = true;
  89. }
  90. //---------------------------------------------------------------------------
  91. void __fastcall TFrmCctvCamViewer::FormShow(TObject *Sender)
  92. {
  93. Application->ProcessMessages();
  94. Refresh();
  95. TmrShow->Enabled = true;
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TFrmCctvCamViewer::FormClose(TObject *Sender, TCloseAction &Action)
  99. {
  100. CommClose();
  101. Action = caFree;
  102. }
  103. //---------------------------------------------------------------------------
  104. void __fastcall TFrmCctvCamViewer::CommClose()
  105. {
  106. try
  107. {
  108. ITSSkin_Term();
  109. CMM_SaveForm(g_sFormsDir, this);
  110. }
  111. catch(Exception &e)
  112. {
  113. }
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TFrmCctvCamViewer::SetColorScheme(String ASkinName)
  117. {
  118. dxSkinController1->SkinName = ASkinName;
  119. dxSkinController1->Refresh();
  120. }
  121. //---------------------------------------------------------------------------
  122. void __fastcall TFrmCctvCamViewer::TmrShowTimer(TObject *Sender)
  123. {
  124. TmrShow->Enabled = false;
  125. FormInit();
  126. }
  127. //---------------------------------------------------------------------------
  128. void __fastcall TFrmCctvCamViewer::FormInit()
  129. {
  130. ObjScreenManager = new TMonitoringScreenManager();
  131. ObjCtlrManager = new TMonitoringCtlrManager(enMonitoringCamera);
  132. FrmInitialize = new TFrmInitialize(this);
  133. FrmInitialize->ShowModal();
  134. FrmInitialize = NULL;
  135. IsLoading = true;
  136. CreateMonitoringScreen();
  137. PnlBack->ParentColor = true;
  138. //BtnMonitoringMngr->Visible = true;
  139. }
  140. //---------------------------------------------------------------------------
  141. void __fastcall TFrmCctvCamViewer::ApplicationEvents1Minimize(TObject *Sender)
  142. {
  143. //영상표출을 정지한다.
  144. if (FrmCameraScreen && IsLoading) FrmCameraScreen->Stop();
  145. }
  146. //---------------------------------------------------------------------------
  147. void __fastcall TFrmCctvCamViewer::ApplicationEvents1Restore(TObject *Sender)
  148. {
  149. //영상표출을 재상영한다.
  150. if (FrmCameraScreen && IsLoading) FrmCameraScreen->Play();
  151. }
  152. //---------------------------------------------------------------------------
  153. void __fastcall TFrmCctvCamViewer::FormResize(TObject *Sender)
  154. {
  155. if (IsFormResizing == false)
  156. {
  157. RecalFormSize();
  158. }
  159. }
  160. //---------------------------------------------------------------------------
  161. void __fastcall TFrmCctvCamViewer::WMEnterSizeMove(TMessage &Msg)
  162. {
  163. IsFormResizing = true;
  164. }
  165. //---------------------------------------------------------------------------
  166. void __fastcall TFrmCctvCamViewer::WMExitSizeMove(TMessage &Msg)
  167. {
  168. IsFormResizing = false;
  169. RecalFormSize();
  170. }
  171. //---------------------------------------------------------------------------
  172. void __fastcall TFrmCctvCamViewer::RecalFormSize()
  173. {
  174. int nNewW = Width;
  175. int nNewH = Height;
  176. if (nNewW == FOldWidth && nNewH == FOldHeight)
  177. {
  178. return;
  179. }
  180. Application->ProcessMessages();
  181. FOldWidth = nNewW;
  182. FOldHeight= nNewH;
  183. if (FrmCameraScreen && IsLoading) FrmCameraScreen->RecalFormSize();
  184. }
  185. //---------------------------------------------------------------------------
  186. void __fastcall TFrmCctvCamViewer::CreateMonitoringScreen()
  187. {
  188. Application->ProcessMessages();
  189. CbScreenList->Properties->OnChange = NULL;
  190. try
  191. {
  192. LockWindowUpdate(Handle);
  193. CbScreenList->Properties->Items->Clear();
  194. FOR_STL(TMonitoringScreen*, pObj, ObjScreenManager->FLists)
  195. {
  196. CbScreenList->Properties->Items->Add(" " + pObj->NAME + " ");
  197. }
  198. CbScreenList->ItemIndex = 0;
  199. }
  200. __finally
  201. {
  202. LockWindowUpdate(0);
  203. CbScreenList->Properties->OnChange = CbScreenListPropertiesChange;
  204. ResetScreenForm();
  205. }
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TFrmCctvCamViewer::CbScreenListPropertiesChange(TObject *Sender)
  209. {
  210. EdFocus->SetFocus();
  211. ResetScreenForm();
  212. }
  213. //---------------------------------------------------------------------------
  214. void __fastcall TFrmCctvCamViewer::ResetScreenForm()
  215. {
  216. if (FrmCameraScreen && IsLoading) FrmCameraScreen->ResetScreenForm(CbScreenList->Text.Trim());
  217. }
  218. //---------------------------------------------------------------------------
  219. void __fastcall TFrmCctvCamViewer::BtnMonitoringMngrClick(TObject *Sender)
  220. {
  221. if (!DMDb->Connect())
  222. {
  223. if (g_AppCfg.sLang != "kr")
  224. {
  225. Application->MessageBox(L"Database connection failed.\r\n\r\nPlease restart the program.",
  226. L"Database connection error !!!",
  227. MB_OK|MB_ICONERROR);
  228. }
  229. else
  230. {
  231. Application->MessageBox(L"데이터베이스 연결에 실패하였습니다.\r\n\r\n프로그램을 다시 시작하십시요.",
  232. L"데이터베이스 연결 오류!!!",
  233. MB_OK|MB_ICONERROR);
  234. }
  235. return;
  236. }
  237. TFrmCameraScreenManager *pForm = new TFrmCameraScreenManager(this);
  238. pForm->ShowModal();
  239. bool bUpdate = pForm->FUpdate;
  240. if(pForm)
  241. {
  242. delete pForm;
  243. pForm = NULL;
  244. }
  245. if (bUpdate)
  246. {
  247. ObjCtlrManager->LoadMonitoringFormFromDb(DMDb->GetConnection());
  248. CreateMonitoringScreen();
  249. }
  250. DMDb->Close();
  251. EdFocus->SetFocus();
  252. }
  253. //---------------------------------------------------------------------------