//---------------------------------------------------------------------------

#ifndef VMS0500MFH
#define VMS0500MFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <DB.hpp>
#include <Menus.hpp>
#include <ExtCtrls.hpp>
#include <ADODB.hpp>
#include <ImgList.hpp>
#include <Graphics.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------

#include "CenterCommF.h"
#include "DataTypesF.h"
#include "WindowMsgF.h"
#include "CDSVmsCtlrF.h"
//---------------------------------------------------------------------------
#include "cxContainer.hpp"
#include "cxControls.hpp"
#include "cxEdit.hpp"
#include "cxGraphics.hpp"
#include "cxGroupBox.hpp"
#include "cxLabel.hpp"
#include "cxLookAndFeelPainters.hpp"
#include "cxLookAndFeels.hpp"
#include "cxPC.hpp"
#include "cxPCdxBarPopupMenu.hpp"
#include "cxSplitter.hpp"
#include "dxSkinBlack.hpp"
#include "dxSkinBlue.hpp"
#include "dxSkinCaramel.hpp"
#include "dxSkinCoffee.hpp"
#include "dxSkinDarkRoom.hpp"
#include "dxSkinDarkSide.hpp"
#include "dxSkinFoggy.hpp"
#include "dxSkinGlassOceans.hpp"
#include "dxSkiniMaginary.hpp"
#include "dxSkinLilian.hpp"
#include "dxSkinLiquidSky.hpp"
#include "dxSkinLondonLiquidSky.hpp"
#include "dxSkinMcSkin.hpp"
#include "dxSkinMoneyTwins.hpp"
#include "dxSkinOffice2007Black.hpp"
#include "dxSkinOffice2007Blue.hpp"
#include "dxSkinOffice2007Green.hpp"
#include "dxSkinOffice2007Pink.hpp"
#include "dxSkinOffice2007Silver.hpp"
#include "dxSkinOffice2010Black.hpp"
#include "dxSkinOffice2010Blue.hpp"
#include "dxSkinOffice2010Silver.hpp"
#include "dxSkinsCore.hpp"
#include "dxSkinscxPCPainter.hpp"
#include "dxSkinSeven.hpp"
#include "dxSkinSharp.hpp"
#include "dxSkinSilver.hpp"
#include "dxSkinStardust.hpp"
#include "cxClasses.hpp"
#include "cxCustomData.hpp"
#include "cxData.hpp"
#include "cxDataStorage.hpp"
#include "cxFilter.hpp"
#include "cxGrid.hpp"
#include "cxGridCustomTableView.hpp"
#include "cxGridCustomView.hpp"
#include "cxGridLevel.hpp"
#include "cxGridTableView.hpp"
#include "cxStyles.hpp"
#include "cxTextEdit.hpp"
#include "cxGridCardView.hpp"
#include "cxGridCustomLayoutView.hpp"
#include "cxCheckBox.hpp"
#include "cxDropDownEdit.hpp"
#include "cxImage.hpp"
#include "cxButtons.hpp"
#include "cxCalc.hpp"
#include "cxGridBandedTableView.hpp"
#include "FRAME_VmsStateListF.h"
#include "FRAME_VmsStateF.h"
#include "FRAME_VmsMsgListF.h"
#include "ImageBtn.h"
#include "cxMaskEdit.hpp"
#include "cxRadioGroup.hpp"
#include "cxSpinEdit.hpp"
#include "cxTimeEdit.hpp"
#include <OleCtrls.hpp>
#include <SHDocVw.hpp>

//---------------------------------------------------------------------------
#include "IdBaseComponent.hpp"
#include "IdComponent.hpp"
#include "IdIcmpClient.hpp"
#include "IdRawBase.hpp"
#include "IdRawClient.hpp"
#include "FFBaseComponent.hpp"
#include "FFBasePlay.hpp"
#include "FFPlay.hpp"
#include "IdHTTP.hpp"
#include "IdTCPClient.hpp"
#include "IdTCPConnection.hpp"
#include "IdAuthenticationDigest.hpp"
#include "AcesTechXPlayer2Lib_OCX.h"
#include "XNSSDKDEVICELib_OCX.h"
#include "XNSSDKWINDOWLib_OCX.h"   /* idhttp 권한 설정을 위해 필요함 */
//---------------------------------------------------------------------------

class TVMS0500M : public TForm
{
__published:	// IDE-managed Components
    TTimer *TmrShow;
    TPanel *PnlCenter;
    TPanel *PnlRight;
    TPanel *PnlLeft;
    TPanel *PnlRTop;
    TcxGroupBox *GrpList;
    TcxGroupBox *cxGroupBox1;
    TcxGroupBox *cxGroupBox2;
    TcxPageControl *PgControl;
    TcxTabSheet *cxTabSheet3;
    TcxTabSheet *cxTabSheet1;
    TcxTabSheet *cxTabSheet2;
    TImageList *ImageList1;
    TcxButton *BtnAllClear;
    TcxButton *BtnReverse;
    TcxButton *BtnAllSelect;
    TPanel *PnlVms;
    TPanel *Panel2;
    TcxRadioButton *RdbOn;
    TcxRadioButton *RdbOff;
    TcxRadioButton *RdbReset;
    TcxButton *BtnControl;
    TcxTimeEdit *cxTimeOn;
    TcxTimeEdit *cxTimeOff;
    TImage *ImgDesc11;
    TImage *ImgDesc01;
    TcxButton *BtnOnOffSet;
    TImage *ImgDesc40;
    TLabel *Label5;
    TImage *ImgDesc41;
    TLabel *Label8;
    TLabel *Label13;
    TImage *ImgDesc42;
    TLabel *Label2;
    TImage *ImgDesc43;
    TLabel *Label15;
    TImage *ImgDesc44;
    TImage *ImgDesc61;
    TImage *ImgDesc62;
    TLabel *Label6;
    TLabel *Label4;
    TLabel *Label16;
    TLabel *Label7;
    TLabel *Label9;
    TLabel *Label10;
    TLabel *Label11;
    TLabel *Label12;
    TLabel *Label17;
    TcxSpinEdit *Se03;
    TcxSpinEdit *Se04;
    TcxSpinEdit *Se02;
    TcxSpinEdit *Se05;
    TcxSpinEdit *Se01;
    TcxSpinEdit *Se06;
    TcxSpinEdit *Se07;
    TLabel *Label1;
    TLabel *Label14;
    TcxButton *BtnConfig;
    TcxTabSheet *cxTabSheet4;
    TcxRadioButton *RdbAuto;
    TcxRadioButton *RdbFix;
    TcxRadioButton *RdbBase;
    TcxButton *BtnModeControl;
    TLabel *Label18;
    TcxRadioButton *RdbLuminance;
    TcxSpinEdit *SeLuminance;
    TLabel *Label19;
    TcxPageControl *PgCam;
    TcxTabSheet *TabRtsp;
    TPanel *PnlCamera;
    TLabel *Label3;
    TcxButton *BtnWebCamUrl;
    TcxButton *BtnDefaultMsg;
    TcxButton *BtnBlankDisplay;
    TPanel *PnlVmsCam;
    TPanel *PnlCamConrtol;
    TcxButton *BtnImageSave;
    TPanel *PnlPTZ;
    TImageBtn *BtnUpLeft;
    TImageBtn *BtnUp;
    TImageBtn *BtnUpRight;
    TImageBtn *BtnLeft;
    TImageBtn *BtnHome;
    TImageBtn *BtnRight;
    TImageBtn *BtnDownLeft;
    TImageBtn *BtnDown;
    TImageBtn *BtnDownRight;
    TImageBtn *BtnZoomIn;
    TImageBtn *BtnZoomOut;
    TImageBtn *BtnFocusIn;
    TImageBtn *BtnFocusOut;
    TLabel *Label20;
    TTrackBar *PTZSpeed;
    TcxTabSheet *cxTabSheet5;
    TcxButton *BtnParamSetting;
    TImage *ImgDesc57;
    TLabel *Label21;
    TcxTimeEdit *cxDisplayTimeOn;
    TcxTimeEdit *cxDisplayTimeOff;
    TImage *ImgDesc53;
    TLabel *Label23;
    TImage *ImgDesc54;
    TLabel *Label24;
    TLabel *Label25;
    TImage *ImgDesc52;
    TLabel *Label26;
    TImage *ImgDesc56;
    TLabel *Label27;
    TImage *ImgDesc51;
    TLabel *Label28;
    TLabel *Label29;
    TLabel *Label30;
    TLabel *Label31;
    TLabel *Label32;
    TcxSpinEdit *SeModRate;
    TcxSpinEdit *SeModCycle;
    TcxSpinEdit *SeLumDay;
    TcxSpinEdit *SeMsgTime;
    TcxSpinEdit *SeLumNight;
    TLabel *Label33;
    TcxSpinEdit *SeCommErrTime;
    TcxSpinEdit *SeSlotCommErr;
    TcxSpinEdit *SeSlotPowerErr;
    TcxButton *BtnDefMsgDownload;
    TcxTabSheet *cxTabSheet6;
    TGroupBox *GroupBox1;
    TImage *ImgDesc59;
    TLabel *Label22;
    TcxSpinEdit *SeFormCycleTime;
    TLabel *Label34;
    TcxButton *BtnDisplayTimeSet;
    TcxButton *BtnMsgImmediateDownload;
    TTimer *TmrCommand;
    TLabel *Label35;
    TLabel *Label36;
    TLabel *Label37;
    TLabel *Label38;
    TFRAMEVmsStateList *FRAMEVmsStateList1;
    TcxTabSheet *TabPing;
    TcxGrid *CxPing;
    TcxGridBandedTableView *TvPing;
    TcxGridBandedColumn *ColumnSel;
    TcxGridBandedColumn *Col01;
    TcxGridBandedColumn *Col02;
    TcxGridBandedColumn *Col03;
    TcxGridBandedColumn *Col04;
    TcxGridBandedColumn *Col05;
    TcxGridBandedColumn *Col06;
    TcxGridBandedColumn *Col07;
    TcxGridBandedColumn *Col08;
    TcxGridBandedColumn *Col09;
    TcxGridBandedColumn *Col10;
    TcxGridBandedColumn *Col11;
    TcxGridBandedColumn *Col12;
    TcxGridBandedColumn *Col99;
    TcxGridLevel *GlPing;
    TPanel *PnlPing;
    TcxButton *BtnAllSelect0;
    TcxButton *BtnAllClear0;
    TcxButton *BtnReverse0;
    TImage *ImgDesc99;
    TLabel *Label39;
    TcxSpinEdit *EdPingTimeout;
    TLabel *Label40;
    TcxButton *BtnNwkPing;
    TcxButton *BtnNwkPingClear;
    TIdIcmpClient *IdIcmpClient1;
    TcxSpinEdit *EdPingPort;
    TLabel *Label41;
    TLabel *Label42;
    TImage *ImgDesc98;
    TcxLabel *lblSelVms;
    TcxLabel *cxLabel1;
    TcxLabel *cxLabel2;
    TcxLabel *cxLabel3;
    TcxLabel *cxLabel4;
    TcxLabel *cxLabel5;
    TcxLabel *cxLabel9;
    TcxLabel *cxLabel6;
    TcxLabel *cxLabel7;
    TcxLabel *cxLabel8;
    TcxLabel *cxLabel10;
    TcxLabel *cxLabel11;
    TcxLabel *cxLabel12;
    TcxLabel *cxLabel13;
    TcxLabel *cxLabel14;
    TcxLabel *cxLabel15;
    TcxLabel *cxLabel16;
    TcxLabel *cxLabel17;
    TcxLabel *cxLabel18;
    TcxLabel *cxLabel19;
    TcxLabel *cxLabel20;
    TcxLabel *cxLabel21;
    TcxLabel *cxLabel22;
    TcxLabel *cxLabel23;
    TcxLabel *cxLabel24;
    TcxLabel *cxLabel25;
    TcxLabel *cxLabel26;
    TcxLabel *cxLabel27;
    TcxLabel *cxLabel28;
    TcxLabel *cxLabel30;
    TcxLabel *cxLabel31;
    TcxLabel *cxLabel32;
    TcxComboBox *CbBrghMode;
    TcxSpinEdit *SeCurrBrgh;
    TLabel *Label44;
    TcxSpinEdit *SeWeekBrgh;
    TLabel *Label45;
    TcxSpinEdit *SeNghtBrgh;
    TLabel *Label46;
    TLabel *Label47;
    TImage *ImgDesc33;
    TcxTimeEdit *cxDispStrTm;
    TcxTimeEdit *cxDispEndTm;
    TLabel *Label49;
    TLabel *Label50;
    TLabel *Label51;
    TcxButton *BtnModuleOn;
    TcxButton *BtnModuleOff;
    TcxButton *BtnResetControl;
    TcxButton *BtnBrghControl;
    TcxButton *BtnImdFromDnld;
    TLabel *Label48;
    TcxComboBox *CbReset;
    TcxButton *BtnResetProgress;
    TcxButton *cxButton2;
    TcxButton *cxButton3;
    TcxButton *cxButton4;
    TLabel *Label43;
    TFFPlayer *FFPlayer1;
    TPanel *PnlSamsung;
    TcxLabel *LblErrMsg;
    TMemo *reMsg;
    TcxCheckBox *ChkFullScreen;
    TIdHTTP *IdHTTP1;
    TAcesTechXPlayer2 *AcesTechXPlayer21;
    TXnsSdkWindow *XnsSdkWindow1;
    TXnsSdkDevice *XnsSdkDevice1;
    void __fastcall FormShow(TObject *Sender);
    void __fastcall TmrShowTimer(TObject *Sender);
    void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
    void __fastcall FormActivate(TObject *Sender);
    void __fastcall FormDeactivate(TObject *Sender);
    void __fastcall BtnAllSelectClick(TObject *Sender);
    void __fastcall FRAMEVmsStateList1TvListCellDblClick(TcxCustomGridTableView *Sender,
          TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton,
          TShiftState AShift, bool &AHandled);
    void __fastcall Se01PropertiesChange(TObject *Sender);
    void __fastcall BtnConfigClick(TObject *Sender);
    void __fastcall BtnControlClick(TObject *Sender);
    void __fastcall BtnOnOffSetClick(TObject *Sender);
    void __fastcall BtnModeControlClick(TObject *Sender);
    void __fastcall BtnWebCamUrlClick(TObject *Sender);
    void __fastcall BtnDefaultMsgClick(TObject *Sender);
    void __fastcall BtnWebCamControlMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y);
    void __fastcall BtnWebCamControlMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y);
    void __fastcall BtnParamSettingClick(TObject *Sender);
    void __fastcall BtnDefMsgDownloadClick(TObject *Sender);
    void __fastcall BtnDisplayTimeSetClick(TObject *Sender);
    void __fastcall BtnMsgImmediateDownloadClick(TObject *Sender);
    void __fastcall TmrCommandTimer(TObject *Sender);
    void __fastcall PgControlPageChanging(TObject *Sender, TcxTabSheet *NewPage,
          bool &AllowChange);
    void __fastcall BtnNwkPingClick(TObject *Sender);
    void __fastcall BtnNwkPingClearClick(TObject *Sender);
    void __fastcall Col04CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas,
          TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone);
    void __fastcall IdIcmpClient1Reply(TComponent *ASender, const TReplyStatus *AReplyStatus);
    void __fastcall Col08CustomDrawCell(TcxCustomGridTableView *Sender, TcxCanvas *ACanvas,
          TcxGridTableDataCellViewInfo *AViewInfo, bool &ADone);
    void __fastcall TvPingCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
          TMouseButton AButton, TShiftState AShift,
          bool &AHandled);
    void __fastcall BtnImdFromDnldClick(TObject *Sender);
    void __fastcall BtnModuleControlClick(TObject *Sender);
    void __fastcall BtnResetClick(TObject *Sender);
    void __fastcall BtnBrghControlClick(TObject *Sender);
    void __fastcall FFPlayer1State(TObject *Sender, TPlayState APlayState);
    void __fastcall FFPlayer1OpenFailed(TObject *Sender);
    void __fastcall ChkFullScreenClick(TObject *Sender);
    void __fastcall IdHTTP1Authorization(TObject *Sender, TIdAuthentication *Authentication, bool &Handled);
    void __fastcall XnsSdkDevice1ConnectFailed(TObject *Sender, long nDeviceID, long nControlID);
    void __fastcall XnsSdkDevice1DeviceStatusChanged(TObject *Sender, long nDeviceID, long nErrorCode, long nDeviceStatus,
          long nHddCondition);

private:	// User declarations
    void __fastcall CommClose();

public:

    bool   FStrmPlay;
    String FStrmUser;
    String FStrmPswd;
    String FStrmHttp;
    String FStrmAddr;

    // xns-activex - start
    bool   m_bXnsInitialize;
	long   m_hDevice;			// Device handle
	long   m_hMediaSource;		// Media stream ID
	long   m_nControlId;		// Control ID
	bool   m_bIsMediaPlay;
    // xns-activex - end

    void __fastcall ErrorMsg(String AErrMsg);

    void __fastcall WebCamPlay(String AVmsNo);
    void __fastcall WebCamStop();

public:
    TForm       *FPalyerForm;
    TVmsCtlr    *FSelVmsObj;
    TStringList *FVmsIds;
    String       FTitle;
    long         FStrmHandle;
    TcxTabSheet *FCtrlTab;

public:		// User declarations
    __fastcall TVMS0500M(TComponent* Owner);

    void __fastcall LoadLocalSkin();

    void __fastcall DisplayInfo();

    void __fastcall ClearCheckList();
    int  __fastcall GetSelListItems(bool ACommCheck=true);

    void __fastcall ActivateForm(bool AActivate);

    bool __fastcall UpdateVmsParam(String AVmsNmbr, void *pData);
    bool __fastcall UpdateVmsParam2(String AVmsNmbr, void *pData);

    int     FPingType;
    bool    FPingTimeout;
    void __fastcall PingNetwork(String AIp, int APort);
    void __fastcall UpdatePingList();
    void __fastcall RefreshPingList(bool AInit=false);


    bool __fastcall InitializeXnsDevice();
    void __fastcall DestroyXnsDevice();
    bool __fastcall ConnectXnsDevice(TVmsCtlr *AObj);
    bool __fastcall OpenXnsDevice();
    void __fastcall PtzControlXnsDevice(int nCommand);

    void __fastcall PtzControlSamsung_iPoliceMouseDown(int ATag);
    void __fastcall PtzControlSamsung_iPoliceMouseUp(int ATag);

    void __fastcall PtzControlHanwha_WisenetMouseDown(int ATag);
    void __fastcall PtzControlHanwha_WisenetMouseUp(int ATag);

    void __fastcall OnVmsSelectMessage(TMessage &Msg);
    void __fastcall OnMainFormMessage(TMessage &Msg);
    void __fastcall OnVmsStateRefreshMessage(TMessage &Msg);
    void __fastcall OnVmsFormRefreshMessage(TMessage &Msg);
	BEGIN_MESSAGE_MAP
        MESSAGE_HANDLER(WM_VMS_SELECT, TMessage, OnVmsSelectMessage)
        MESSAGE_HANDLER(WM_MAINFORM, TMessage, OnMainFormMessage)
        MESSAGE_HANDLER(WM_VMS_STATE_REFRESH, TMessage, OnVmsStateRefreshMessage)
        MESSAGE_HANDLER(WM_VMS_FORM_REFRESH, TMessage, OnVmsFormRefreshMessage)
    END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern PACKAGE TVMS0500M *VMS0500M;
//---------------------------------------------------------------------------

#endif

