VMS0410MF.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "AppGlobalF.h"
  5. #include "ITSLangTransF.h"
  6. #pragma hdrstop
  7. #include "VMS0410MF.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma link "cxControls"
  11. #pragma link "cxGraphics"
  12. #pragma link "cxLookAndFeelPainters"
  13. #pragma link "cxLookAndFeels"
  14. #pragma link "cxPC"
  15. #pragma link "cxPCdxBarPopupMenu"
  16. #pragma resource "*.dfm"
  17. //TVMS0410M *VMS0410M;
  18. //---------------------------------------------------------------------------
  19. __fastcall TVMS0410M::TVMS0410M(TComponent* Owner, HWND AHandle, TcxTabSheet *ASheet, TXView *AObj)
  20. : TForm(Owner)
  21. {
  22. LangTrans->Translate(this, ITSDb_GetConnection());
  23. ITSSkin_Load(this);
  24. FLayout = -1;
  25. FSheet = ASheet;
  26. FView = AObj;
  27. FWndParent = AHandle;
  28. Caption = ASheet->Caption;
  29. for (int ii = 0; ii < MAX_VMS_CAMERA; ii++)
  30. {
  31. FFrmCamera[ii] = new TVMSWCAM0(this, NULL);
  32. FFrmCamera[ii]->Parent = PnlClient;
  33. FFrmCamera[ii]->FTitle = ASheet->Caption;
  34. }
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TVMS0410M::SetLayout(int ALayout)
  38. {
  39. if (FLayout == ALayout) return;
  40. switch(ALayout)
  41. {
  42. case 0:/* (1 * 1) */ FCols = 1; FRows = 1; break;
  43. case 1:/* (2 * 2) */ FCols = 2; FRows = 2; break;
  44. case 2:/* (3 * 3) */ FCols = 3; FRows = 3; break;
  45. case 3:/* (3 * 2) */ FCols = 3; FRows = 2; break;
  46. case 4:/* (4 * 3) */ FCols = 4; FRows = 3; break;
  47. case 5:/* (4 * 4) */ FCols = 4; FRows = 4; break;
  48. case 6:/* (4 * 5) */ FCols = 4; FRows = 5; break;
  49. case 7:/* (5 * 4) */ FCols = 5; FRows = 4; break;
  50. case 8:/* (6 * 4) */ FCols = 6; FRows = 4; break;
  51. case 9:/* (6 * 5) */ FCols = 6; FRows = 5; break;
  52. case 10:/* (7 * 6) */ FCols = 7; FRows = 6; break;
  53. case 11:/* (8 * 7) */ FCols = 8; FRows = 7; break;
  54. case 12:/* (8 * 8) */ FCols = 8; FRows = 8; break;
  55. default: ALayout = 0; FCols = 1; FRows = 1; break;
  56. }
  57. FLayout = ALayout;
  58. if (FSheet)
  59. {
  60. TXView *pObj = (TXView*)FSheet->Tag;
  61. if (pObj) pObj->Layout = FLayout;
  62. }
  63. RecalFormSize();
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TVMS0410M::RecalFormSize()
  67. {
  68. int ii;
  69. int nMaxForm = FCols * FRows;
  70. for (ii = nMaxForm; ii < MAX_VMS_CAMERA; ii++)
  71. {
  72. TVMSWCAM0 *pFrmCam = FFrmCamera[ii];
  73. if (pFrmCam->Visible)
  74. {
  75. pFrmCam->CamStop();
  76. if (pFrmCam->Showing)
  77. {
  78. pFrmCam->TmrStop->Enabled = true;
  79. pFrmCam->Hide();
  80. }
  81. }
  82. }
  83. int nRows = 0;
  84. int nCols = 0;
  85. int nTop = 0;
  86. int nLeft = 0;
  87. int nTotTop, nTotLeft;
  88. int nWidth = (PnlClient->Width - FCols+1) / FCols;
  89. int nHeight= (PnlClient->Height- FRows+1) / FRows;
  90. try
  91. {
  92. LockWindowUpdate(Handle);
  93. for (ii = 0; ii < nMaxForm; ii++)
  94. {
  95. TVMSWCAM0 *pFrmCam = FFrmCamera[ii];
  96. if (!pFrmCam)
  97. continue;
  98. pFrmCam->Width = nWidth;
  99. pFrmCam->Height= nHeight;
  100. nTotTop = (nRows * pFrmCam->Height)+(nTop*(nRows+1));
  101. nTotLeft = (nCols * pFrmCam->Width)+(nLeft*(nCols+1));
  102. pFrmCam->Top = nTotTop;
  103. pFrmCam->Left= nTotLeft;
  104. if ((ii%FCols) == (FCols-1))
  105. {
  106. nRows++;
  107. nCols = 0;
  108. }
  109. else
  110. {
  111. nCols++;
  112. }
  113. if (!pFrmCam->Showing)
  114. {
  115. pFrmCam->FWndParent = Handle;
  116. pFrmCam->Show();
  117. //pFrmCam->TmrPlay->Enabled = true;
  118. }
  119. }
  120. }
  121. __finally
  122. {
  123. LockWindowUpdate(0);
  124. }
  125. }
  126. //---------------------------------------------------------------------------
  127. void __fastcall TVMS0410M::InitCamera()
  128. {
  129. if (!FView) return;
  130. for (int ii = 0; ii < MAX_VMS_CAMERA; ii++)
  131. {
  132. if (!FView->FCamera[ii].Installed) continue;
  133. TVmsCtlr *pVms = VmsManager->FLists.Find(FView->FCamera[ii].Id);
  134. if (!pVms) continue;
  135. FFrmCamera[ii]->InitCamera((void*)pVms, FView->FCamera[ii].Play);
  136. }
  137. }
  138. //---------------------------------------------------------------------------
  139. void __fastcall TVMS0410M::UpdateCctvMasterInfo()
  140. {
  141. for (int ii = 0; ii < MAX_VMS_CAMERA; ii++)
  142. {
  143. //FFrmCamera[ii]->UpdateCctvMasterInfo();
  144. }
  145. }
  146. //---------------------------------------------------------------------------
  147. void __fastcall TVMS0410M::Play()
  148. {
  149. for (int ii = 0; ii < MAX_VMS_CAMERA; ii++)
  150. {
  151. if (FFrmCamera[ii]->FAutoPlay)
  152. {
  153. FFrmCamera[ii]->TmrPlay->Enabled = true;
  154. }
  155. }
  156. }
  157. //---------------------------------------------------------------------------
  158. void __fastcall TVMS0410M::Stop()
  159. {
  160. for (int ii = 0; ii < MAX_VMS_CAMERA; ii++)
  161. {
  162. FFrmCamera[ii]->TmrStop->Enabled = true;
  163. }
  164. }
  165. //---------------------------------------------------------------------------
  166. void __fastcall TVMS0410M::OnVmsSelectMessage(TMessage &Msg)
  167. {
  168. if (FWndParent)
  169. {
  170. POST_MSG(FWndParent, WM_VMS_SELECT, (WPARAM)Msg.WParam, (LPARAM)Msg.LParam);
  171. }
  172. }
  173. //---------------------------------------------------------------------------
  174. void __fastcall TVMS0410M::OnVmsSelectDblClickMessage(TMessage &Msg)
  175. {
  176. if (FWndParent)
  177. {
  178. POST_MSG(FWndParent, WM_VMS_SELECT_DBLCLICK, (WPARAM)Msg.WParam, (LPARAM)Msg.LParam);
  179. }
  180. }
  181. //---------------------------------------------------------------------------