FrmCameraViewF.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "FrmCameraViewF.h"
  5. #include "AppGlobalF.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "cxControls"
  9. #pragma link "cxGraphics"
  10. #pragma link "cxLookAndFeelPainters"
  11. #pragma link "cxLookAndFeels"
  12. #pragma link "cxPC"
  13. #pragma link "cxPCdxBarPopupMenu"
  14. #pragma link "dxSkinsCore"
  15. #pragma link "dxSkinscxPCPainter"
  16. #pragma resource "*.dfm"
  17. TFrmCameraView *FrmCameraView;
  18. //---------------------------------------------------------------------------
  19. __fastcall TFrmCameraView::TFrmCameraView(TComponent* Owner, TcxTabSheet *ASheet, TXView *AObj)
  20. : TForm(Owner)
  21. {
  22. FLayout = -1;
  23. FSheet = ASheet;
  24. FView = AObj;
  25. Caption = ASheet->Caption;
  26. TXCctv *pCctv = NULL;
  27. for (int ii = 0; ii < MAX_CAMERA; ii++)
  28. {
  29. FStreamType[ii] = RTSP;
  30. if (FView->FCamera[ii].Installed)
  31. pCctv = XCctvManager->FLists.Find(FView->FCamera[ii].Id);
  32. else
  33. pCctv = NULL;
  34. if (pCctv)
  35. {
  36. if (pCctv->StreamingType == SAMSUNG)
  37. {
  38. FCameraForm[ii] = new TFrmSamsungCamera(this, pCctv, FView->FCamera[ii].Play);
  39. FStreamType[ii] = SAMSUNG;
  40. }
  41. else
  42. {
  43. FCameraForm[ii] = new TFrmCamera(this, pCctv, FView->FCamera[ii].Play);
  44. FStreamType[ii] = RTSP;
  45. }
  46. }
  47. else
  48. {
  49. FCameraForm[ii] = new TFrmCamera(this, pCctv, FView->FCamera[ii].Play);
  50. }
  51. FCameraForm[ii]->Parent = PnlClient;
  52. }
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TFrmCameraView::SetLayout(int ALayout)
  56. {
  57. if (FLayout == ALayout) return;
  58. switch(ALayout)
  59. {
  60. case 0:/* (1 * 1) */ FCols = 1; FRows = 1; break;
  61. case 1:/* (2 * 2) */ FCols = 2; FRows = 2; break;
  62. case 2:/* (3 * 3) */ FCols = 3; FRows = 3; break;
  63. case 3:/* (3 * 2) */ FCols = 3; FRows = 2; break;
  64. case 4:/* (4 * 3) */ FCols = 4; FRows = 3; break;
  65. case 5:/* (4 * 4) */ FCols = 4; FRows = 4; break;
  66. case 6:/* (4 * 5) */ FCols = 4; FRows = 5; break;
  67. case 7:/* (5 * 4) */ FCols = 5; FRows = 4; break;
  68. case 8:/* (6 * 4) */ FCols = 6; FRows = 4; break;
  69. case 9:/* (6 * 5) */ FCols = 6; FRows = 5; break;
  70. case 10:/* (7 * 6) */ FCols = 7; FRows = 6; break;
  71. case 11:/* (8 * 7) */ FCols = 8; FRows = 7; break;
  72. case 12:/* (8 * 8) */ FCols = 8; FRows = 8; break;
  73. default: ALayout = 0; FCols = 1; FRows = 1; break;
  74. }
  75. FLayout = ALayout;
  76. if (FView)
  77. {
  78. FView->Layout = FLayout;
  79. }
  80. RecalFormSize();
  81. }
  82. //---------------------------------------------------------------------------
  83. void __fastcall TFrmCameraView::RecalFormSize()
  84. {
  85. int ii;
  86. int nMaxForm = FCols * FRows;
  87. Application->ProcessMessages();
  88. for (ii = nMaxForm; ii < MAX_CAMERA; ii++)
  89. {
  90. if (FStreamType[ii] == SAMSUNG)
  91. {
  92. TFrmSamsungCamera *pFrmCam = (TFrmSamsungCamera*)FCameraForm[ii];
  93. if (pFrmCam->Visible)
  94. {
  95. pFrmCam->Disconnect();
  96. if (pFrmCam->Showing)
  97. {
  98. pFrmCam->TmrStop->Enabled = true;
  99. pFrmCam->Hide();
  100. }
  101. }
  102. }
  103. else
  104. {
  105. TFrmCamera *pFrmCam = (TFrmCamera*)FCameraForm[ii];
  106. if (pFrmCam->Visible)
  107. {
  108. pFrmCam->Disconnect();
  109. if (pFrmCam->Showing)
  110. {
  111. pFrmCam->TmrStop->Enabled = true;
  112. pFrmCam->Hide();
  113. }
  114. }
  115. }
  116. #if 0
  117. TFrmCamera *pFrmCam = (TFrmCamera*)FCameraForm[ii];
  118. if (pFrmCam->Visible)
  119. {
  120. pFrmCam->Disconnect();
  121. if (pFrmCam->Showing)
  122. {
  123. pFrmCam->TmrStop->Enabled = true;
  124. pFrmCam->Hide();
  125. }
  126. }
  127. #endif
  128. }
  129. int nRows = 0;
  130. int nCols = 0;
  131. int nTop = 0;
  132. int nLeft = 0;
  133. int nTotTop, nTotLeft;
  134. int nWidth = (PnlClient->Width - FCols+1) / FCols;
  135. int nHeight= (PnlClient->Height- FRows+1) / FRows;
  136. try
  137. {
  138. LockWindowUpdate(Handle);
  139. for (ii = 0; ii < nMaxForm; ii++)
  140. {
  141. TForm *pFrmCam = FCameraForm[ii];
  142. if (!pFrmCam)
  143. continue;
  144. pFrmCam->Width = nWidth;
  145. pFrmCam->Height= nHeight;
  146. nTotTop = (nRows * pFrmCam->Height)+(nTop*(nRows+1));
  147. nTotLeft = (nCols * pFrmCam->Width)+(nLeft*(nCols+1));
  148. pFrmCam->Top = nTotTop;
  149. pFrmCam->Left= nTotLeft;
  150. if ((ii%FCols) == (FCols-1))
  151. {
  152. nRows++;
  153. nCols = 0;
  154. }
  155. else
  156. {
  157. nCols++;
  158. }
  159. if (!pFrmCam->Showing)
  160. {
  161. pFrmCam->Show();
  162. //pFrmCam->TmrPlay->Enabled = true;
  163. }
  164. }
  165. }
  166. __finally
  167. {
  168. LockWindowUpdate(0);
  169. }
  170. }
  171. //---------------------------------------------------------------------------
  172. void __fastcall TFrmCameraView::Play()
  173. {
  174. for (int ii = 0; ii < MAX_CAMERA; ii++)
  175. {
  176. TForm *pFrmCam = FCameraForm[ii];
  177. if (!pFrmCam)
  178. continue;
  179. if (FStreamType[ii] == ICSVIEW)
  180. {
  181. TFrmIcsCamera *pFrmCam = (TFrmIcsCamera*)FCameraForm[ii];
  182. if (pFrmCam->FAutoPlay)
  183. {
  184. pFrmCam->TmrPlay->Enabled = true;
  185. }
  186. }
  187. else
  188. if (FStreamType[ii] == SAMSUNG)
  189. {
  190. TFrmSamsungCamera *pFrmCam = (TFrmSamsungCamera*)FCameraForm[ii];
  191. if (pFrmCam->FAutoPlay)
  192. {
  193. pFrmCam->TmrPlay->Enabled = true;
  194. }
  195. }
  196. else
  197. {
  198. TFrmCamera *pFrmCam = (TFrmCamera*)FCameraForm[ii];
  199. if (pFrmCam->FAutoPlay)
  200. {
  201. pFrmCam->TmrPlay->Enabled = true;
  202. }
  203. }
  204. #if 0
  205. if (pFrmCam->FAutoPlay)
  206. {
  207. pFrmCam->TmrPlay->Enabled = true;
  208. }
  209. #endif
  210. }
  211. }
  212. //---------------------------------------------------------------------------
  213. void __fastcall TFrmCameraView::Stop()
  214. {
  215. for (int ii = 0; ii < MAX_CAMERA; ii++)
  216. {
  217. TForm *pFrmCam = FCameraForm[ii];
  218. if (!pFrmCam)
  219. continue;
  220. if (FStreamType[ii] == ICSVIEW)
  221. {
  222. TFrmIcsCamera *pFrmCam = (TFrmIcsCamera*)FCameraForm[ii];
  223. pFrmCam->TmrStop->Enabled = true;
  224. }
  225. else
  226. if (FStreamType[ii] == SAMSUNG)
  227. {
  228. TFrmSamsungCamera *pFrmCam = (TFrmSamsungCamera*)FCameraForm[ii];
  229. pFrmCam->TmrStop->Enabled = true;
  230. }
  231. else
  232. {
  233. TFrmCamera *pFrmCam = (TFrmCamera*)FCameraForm[ii];
  234. pFrmCam->TmrStop->Enabled = true;
  235. }
  236. #if 0
  237. pFrmCam->TmrStop->Enabled = true;
  238. #endif
  239. }
  240. }
  241. //---------------------------------------------------------------------------