FrmCctvCamViewerF.cpp 9.0 KB

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