123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "FrmCameraViewF.h"
- #include "AppGlobalF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "cxControls"
- #pragma link "cxGraphics"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "cxPC"
- #pragma link "cxPCdxBarPopupMenu"
- #pragma link "dxSkinsCore"
- #pragma link "dxSkinscxPCPainter"
- #pragma resource "*.dfm"
- TFrmCameraView *FrmCameraView;
- //---------------------------------------------------------------------------
- __fastcall TFrmCameraView::TFrmCameraView(TComponent* Owner, TcxTabSheet *ASheet, TXView *AObj)
- : TForm(Owner)
- {
- FLayout = -1;
- FSheet = ASheet;
- FView = AObj;
- Caption = ASheet->Caption;
- TXCctv *pCctv = NULL;
- for (int ii = 0; ii < MAX_CAMERA; ii++)
- {
- FStreamType[ii] = RTSP;
- if (FView->FCamera[ii].Installed)
- pCctv = XCctvManager->FLists.Find(FView->FCamera[ii].Id);
- else
- pCctv = NULL;
- if (pCctv)
- {
- if (pCctv->StreamingType == SAMSUNG)
- {
- FCameraForm[ii] = new TFrmSamsungCamera(this, pCctv, FView->FCamera[ii].Play);
- FStreamType[ii] = SAMSUNG;
- }
- else
- {
- FCameraForm[ii] = new TFrmCamera(this, pCctv, FView->FCamera[ii].Play);
- FStreamType[ii] = RTSP;
- }
- }
- else
- {
- FCameraForm[ii] = new TFrmCamera(this, pCctv, FView->FCamera[ii].Play);
- }
- FCameraForm[ii]->Parent = PnlClient;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraView::SetLayout(int ALayout)
- {
- if (FLayout == ALayout) return;
- switch(ALayout)
- {
- case 0:/* (1 * 1) */ FCols = 1; FRows = 1; break;
- case 1:/* (2 * 2) */ FCols = 2; FRows = 2; break;
- case 2:/* (3 * 3) */ FCols = 3; FRows = 3; break;
- case 3:/* (3 * 2) */ FCols = 3; FRows = 2; break;
- case 4:/* (4 * 3) */ FCols = 4; FRows = 3; break;
- case 5:/* (4 * 4) */ FCols = 4; FRows = 4; break;
- case 6:/* (4 * 5) */ FCols = 4; FRows = 5; break;
- case 7:/* (5 * 4) */ FCols = 5; FRows = 4; break;
- case 8:/* (6 * 4) */ FCols = 6; FRows = 4; break;
- case 9:/* (6 * 5) */ FCols = 6; FRows = 5; break;
- case 10:/* (7 * 6) */ FCols = 7; FRows = 6; break;
- case 11:/* (8 * 7) */ FCols = 8; FRows = 7; break;
- case 12:/* (8 * 8) */ FCols = 8; FRows = 8; break;
- default: ALayout = 0; FCols = 1; FRows = 1; break;
- }
- FLayout = ALayout;
- if (FView)
- {
- FView->Layout = FLayout;
- }
- RecalFormSize();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraView::RecalFormSize()
- {
- int ii;
- int nMaxForm = FCols * FRows;
- Application->ProcessMessages();
- for (ii = nMaxForm; ii < MAX_CAMERA; ii++)
- {
- if (FStreamType[ii] == SAMSUNG)
- {
- TFrmSamsungCamera *pFrmCam = (TFrmSamsungCamera*)FCameraForm[ii];
- if (pFrmCam->Visible)
- {
- pFrmCam->Disconnect();
- if (pFrmCam->Showing)
- {
- pFrmCam->TmrStop->Enabled = true;
- pFrmCam->Hide();
- }
- }
- }
- else
- {
- TFrmCamera *pFrmCam = (TFrmCamera*)FCameraForm[ii];
- if (pFrmCam->Visible)
- {
- pFrmCam->Disconnect();
- if (pFrmCam->Showing)
- {
- pFrmCam->TmrStop->Enabled = true;
- pFrmCam->Hide();
- }
- }
- }
- #if 0
- TFrmCamera *pFrmCam = (TFrmCamera*)FCameraForm[ii];
- if (pFrmCam->Visible)
- {
- pFrmCam->Disconnect();
- if (pFrmCam->Showing)
- {
- pFrmCam->TmrStop->Enabled = true;
- pFrmCam->Hide();
- }
- }
- #endif
- }
- int nRows = 0;
- int nCols = 0;
- int nTop = 0;
- int nLeft = 0;
- int nTotTop, nTotLeft;
- int nWidth = (PnlClient->Width - FCols+1) / FCols;
- int nHeight= (PnlClient->Height- FRows+1) / FRows;
- try
- {
- LockWindowUpdate(Handle);
- for (ii = 0; ii < nMaxForm; ii++)
- {
- TForm *pFrmCam = FCameraForm[ii];
- if (!pFrmCam)
- continue;
- pFrmCam->Width = nWidth;
- pFrmCam->Height= nHeight;
- nTotTop = (nRows * pFrmCam->Height)+(nTop*(nRows+1));
- nTotLeft = (nCols * pFrmCam->Width)+(nLeft*(nCols+1));
- pFrmCam->Top = nTotTop;
- pFrmCam->Left= nTotLeft;
- if ((ii%FCols) == (FCols-1))
- {
- nRows++;
- nCols = 0;
- }
- else
- {
- nCols++;
- }
- if (!pFrmCam->Showing)
- {
- pFrmCam->Show();
- //pFrmCam->TmrPlay->Enabled = true;
- }
- }
- }
- __finally
- {
- LockWindowUpdate(0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraView::Play()
- {
- for (int ii = 0; ii < MAX_CAMERA; ii++)
- {
- TForm *pFrmCam = FCameraForm[ii];
- if (!pFrmCam)
- continue;
- if (FStreamType[ii] == ICSVIEW)
- {
- TFrmIcsCamera *pFrmCam = (TFrmIcsCamera*)FCameraForm[ii];
- if (pFrmCam->FAutoPlay)
- {
- pFrmCam->TmrPlay->Enabled = true;
- }
- }
- else
- if (FStreamType[ii] == SAMSUNG)
- {
- TFrmSamsungCamera *pFrmCam = (TFrmSamsungCamera*)FCameraForm[ii];
- if (pFrmCam->FAutoPlay)
- {
- pFrmCam->TmrPlay->Enabled = true;
- }
- }
- else
- {
- TFrmCamera *pFrmCam = (TFrmCamera*)FCameraForm[ii];
- if (pFrmCam->FAutoPlay)
- {
- pFrmCam->TmrPlay->Enabled = true;
- }
- }
- #if 0
- if (pFrmCam->FAutoPlay)
- {
- pFrmCam->TmrPlay->Enabled = true;
- }
- #endif
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraView::Stop()
- {
- for (int ii = 0; ii < MAX_CAMERA; ii++)
- {
- TForm *pFrmCam = FCameraForm[ii];
- if (!pFrmCam)
- continue;
- if (FStreamType[ii] == ICSVIEW)
- {
- TFrmIcsCamera *pFrmCam = (TFrmIcsCamera*)FCameraForm[ii];
- pFrmCam->TmrStop->Enabled = true;
- }
- else
- if (FStreamType[ii] == SAMSUNG)
- {
- TFrmSamsungCamera *pFrmCam = (TFrmSamsungCamera*)FCameraForm[ii];
- pFrmCam->TmrStop->Enabled = true;
- }
- else
- {
- TFrmCamera *pFrmCam = (TFrmCamera*)FCameraForm[ii];
- pFrmCam->TmrStop->Enabled = true;
- }
- #if 0
- pFrmCam->TmrStop->Enabled = true;
- #endif
- }
- }
- //---------------------------------------------------------------------------
|