123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "FrmCamViewF.h"
- #include "FrmCctvMonitoringF.h"
- #include "AppGlobalF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "AcesTechXPlayer2Lib_OCX"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma resource "*.dfm"
- TFrmCamera *FrmCamera = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFrmCamera::TFrmCamera(TComponent* Owner)
- : TForm(Owner)
- {
- FPlay = false;
- FAutoPlay = true;
- FConHandle = 0;
- FInstalled = false;
- AcesTechXPlayer21->DoubleBuffered = true;
- InitCamera(NULL, FAutoPlay);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::MnuConnectClick(TObject *Sender)
- {
- FAutoPlay = true;
- Connect();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::MnuDisconnectClick(TObject *Sender)
- {
- FAutoPlay = false;
- Disconnect();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::MnuReleaseClick(TObject *Sender)
- {
- CameraRelease();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::Connect()
- {
- Disconnect();
- if (FId.IsEmpty()) return;
- if (FViewAddress.IsEmpty()) return;
- PnlCamera->Caption = "¿¬°áÁß...";
- AcesTechXPlayer21->Visible = true;
- try
- {
- Log(FTitle + " " + FName + " Connect");
- AcesTechXPlayer21->URL = FViewAddress;
- FConHandle = AcesTechXPlayer21->ConnectAsync();
- Log(FTitle + " " + FName + " Handle: " + String(FConHandle));
- }
- catch(...)
- {
- }
- FPlay = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::Disconnect()
- {
- if (!FPlay) return;
- try
- {
- //if (FConHandle)
- {
- Log(FTitle + " " + FName + " Disconnect");
- AcesTechXPlayer21->Close();
- }
- FConHandle = 0;
- }
- catch(...)
- {
- }
- PnlCamera->Caption = "Disconnected";
- AcesTechXPlayer21->Visible = false;
- FConHandle = 0;
- FPlay = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::CameraRelease()
- {
- Disconnect();
- InitCamera(NULL, FAutoPlay);
- PnlCamera->Caption = "";
- AcesTechXPlayer21->Visible = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::PnlCameraDragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept)
- {
- Accept = true;
- if (!g_Drag.Id.IsEmpty())
- {
- #if 0
- int x_gap = Top;
- int y_gap = Left;
- FrmMain->StDrag->Top = (Y-10-FrmMain->StDrag->Height) - y_gap;
- FrmMain->StDrag->Left = (X) - x_gap;
- if (!FrmMain->StDrag->Visible)
- {
- FrmMain->StDrag->Visible = true;
- }
- #endif
- }
- else
- {
- Accept = false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::PnlCameraDragDrop(TObject *Sender, TObject *Source, int X, int Y)
- {
- if (!g_Drag.Id.IsEmpty())
- {
- FId = g_Drag.Id;
- FGroup = g_Drag.Group;
- FName = g_Drag.Name;
- FStreamingType = g_Drag.StreamingType;
- FViewAddress = g_Drag.ViewAddress;
- FFullAddress = g_Drag.FullAddress;
- PnlCamera->Caption = "Disconnected";
- DisplayName(FName);
- FInstalled = true;
- if (FAutoPlay || FPlay)
- {
- Connect();
- }
- }
- g_Drag.Id = "";
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::InitCamera(TXCctv *ACctv, bool AAutoPlay/*=true*/)
- {
- FAutoPlay = AAutoPlay;
- if (!ACctv)
- {
- FId = "";
- FGroup = "";
- FName = "";
- FStreamingType = "";
- FViewAddress = "";
- FFullAddress = "";
- DisplayName(" ");
- FInstalled = false;
- }
- else
- {
- FId = ACctv->Id;
- FGroup = ACctv->Group;
- FName = ACctv->Name;
- FStreamingType = ACctv->StreamingType;
- FViewAddress = ACctv->ViewAddress;
- FFullAddress = ACctv->FullAddress;
- PnlCamera->Caption = "Disconnected";
- DisplayName(FName);
- FInstalled = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::DisplayName(String AName)
- {
- LblName->Visible = false;
- LblName->Caption = FName;
- LblName->Transparent = false;
- LblName->Transparent = true;
- LblName->Visible = true;
- LblName->Refresh();
- LblName->BringToFront();
- //::SetWindowLong(LblName->Handle, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TRANSPARENT);
- //::SetLayeredWindowAttributes(LblName->Handle, 0, 80, LWA_ALPHA);
- // long __fastcall DrawText(BSTR text, long x, long y, BSTR fontname, long fontsize,
- // long underline, long fontcolor, long bordercolor, long bkcolor);
- // AcesTechXPlayer21->DrawTextW(AName.c_str(), 10, 10, L"¸¼Àº °íµñ", 10, 0, 0, 0, 0);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::UpdateCctvMasterInfo()
- {
- if (!FInstalled) return;
- TXCctv *pCctv = XCctvManager->FLists.Find(FId);
- if (pCctv)
- {
- if (pCctv->EditMode == DB_DELETE ||
- pCctv->DEL_YN == "Y")
- {
- CameraRelease();
- return;
- }
- bool bReconnect = false;
- if (FViewAddress != pCctv->ViewAddress ||
- FFullAddress != pCctv->FullAddress)
- {
- bReconnect = true;
- }
- InitCamera(pCctv, FAutoPlay);
- if (bReconnect)
- {
- if (FPlay)
- {
- Connect();
- }
- }
- }
- else
- {
- CameraRelease();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::TmrPlayTimer(TObject *Sender)
- {
- TmrStop->Enabled = false;
- TmrPlay->Enabled = false;
- Connect();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::TmrStopTimer(TObject *Sender)
- {
- TmrPlay->Enabled = false;
- TmrStop->Enabled = false;
- Disconnect();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCamera::LblNameClick(TObject *Sender)
- {
- return;
- LblName->Parent = AcesTechXPlayer21;
- LblName->Transparent = false;
- LblName->Transparent = true;
- //AcesTechXPlayer21->Visible = !AcesTechXPlayer21->Visible;
- }
- //---------------------------------------------------------------------------
|