FrmPCamViewerF.cpp 8.3 KB

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