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

#ifndef ITS_OPLibFH
#define ITS_OPLibFH
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#ifndef __ITS_OPLib_EXPORT__
#pragma comment(lib, "ITS_OPLib.lib")
#endif // #ifndef __ITS_OPLib_EXPORT__
//---------------------------------------------------------------------------
#include <vcl.h>
#include "cxControls.hpp"
#include "cxDropDownEdit.hpp"
//---------------------------------------------------------------------------

//COMMON LIBRARY
#include "CenterCommF.h"
#include "EncryptionF.h"
#include "ITSDbF.h"
#include "ITSLangTransF.h"
#include "ITSLibF.h"
#include "ITSLogF.h"
#include "ITSMapF.h"
#include "ITSNetF.h"
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "FilterGrid.hpp"
//#include "UJSExec.hpp"

//MSG
#include "DataTypesF.h"
#include "WindowMsgF.h"


//FRM
#include "FrmResourceF.h"

/*
******************************************************************************
* Defines
******************************************************************************
*/
#define DBERRMSG(v,w,x,y) FDbLog->LogDbError(v,w,x,y,__FILE__, String(__FUNC__), __LINE__,true)
#define DBERRLOG(v,w,x,y) FDbLog->LogDbError(v,w,x,y,__FILE__, String(__FUNC__), __LINE__,false)

/*
******************************************************************************
* User Data Types
******************************************************************************
*/
#define     STR_DATETIME    String("YYYY-MM-DD HH:NN:SS")
#define     STR_HHNN        String("YYYY-MM-DD HH:NN")
#define     STR_DATEHOUR    String("YYYY-MM-DD HH")
#define     STR_DATE        String("YYYY-MM-DD")
#define     STR_MM          String("YYYY-MM")
#define     STR_YY          String("YYYY")

typedef enum
{
    icon_n = 0,
    icon_e,
    icon_m,
    icon_r,
    icon_s,
} facility_icon;

typedef struct
{
    String  ICON[5];
} FACILITY_ICON;

typedef struct tag_AppConfig
{
    String      sConfigFile;
    bool        bAppClose;
    long        lMainWinHandle;     /* Main Window Handle */
    String      sTitle;
    String      sProcessId;       	/* ÇÁ·Î¼¼½º ID */
    String      sSkinName;
    bool        bSaveForm;
    bool        bLoginPrompt;
    String      sDefUseId;

    int         nLogLevel;
    AnsiString  sLogDay;
    bool        bDebug;
    String      sAppPath;

    String      sLang;

    struct
    {
        bool    Window;
        bool    Enabled;
        int     TimeOut;
    } Alarm;
    struct
    {
        bool    Window;
        bool    Enabled;
        int     TimeOut;
    } Incident;
    struct
    {
        int     AlarmValue;
    } Temp;

    struct
    {
        bool    Enabled;
        int     IntervalMin;
        bool    LogoutExit;
    } AutoLogout;

    FACILITY_ICON   vms;
    FACILITY_ICON   vds;

    struct
    {
        TThread     *pThread;
        DWORD        dwThreadId;
        unsigned int nHandle;
        bool         bRunning;
    } thr;
    struct
    {
        String  sProvider;
        String  sServerName;
        String  sUserName;
        String  sPassword;
        String  sConnectStr;
        bool    bSqlLog;
    } itsdb;
    struct
    {
        String  sProvider;
        String  sServerName;
        String  sUserName;
        String  sPassword;
        bool    bSqlLog;
    } utisdb;
    struct
    {
        String  sMainMap;
        String  sLinkMap;
    } flashmap;

    struct
    {
        String  sComModel;
        String  sDevModel;
    } vmscam;

    struct
    {
        String  saveDir;
        String  viewer;
        String  server;
        int     port;
        String  user;
        String  pswd;
        String  dir;
    } blackbox;

    struct
    {
        String SERVER;
        int    PORT;
        String USER;
        String PSWD;
        bool   PASSIVE;
    } vmsFtp;

    bool bOnlyOneScreen;
    bool bTermChildProg;

    bool isLoadFromFile;
} APP_CONFIG;

/*
******************************************************************************
* Global variable definitions
******************************************************************************
*/
extern TITSLog         *ITSLog;
extern String           g_sMapDir;
extern int              g_nMapSource;
extern ST_GISINFO       g_GisInfo;
extern ST_SELLINK       g_SelLink;
extern APP_CONFIG       g_AppCfg;

/*
******************************************************************************
* Global function prototype
******************************************************************************
*/
#define MAX_DISPCOLOR   20
void   APP_InitDisplayColor();
TColor APP_GetDisplayColor(int ASeq);
void   APP_ImageClear(TCanvas *c, int offX, int offY, int w, int h, TColor color);

void APP_ShowErrorMsg(String ATitle, String AErrMsg);
TDateTime APP_StrToDateTime(String AStrDateTime);

String APP_FillCode(TcxComboBox *ACombo, String ACode);
String APP_GetCode(TcxComboBox *ACombo);
String APP_GetCodeName(TcxComboBox *ACombo, String ACode);
String APP_GetCodeDesc(TcxComboBox *ACombo, String ACode);
String APP_GetCodeIdByName(TcxComboBox *ACombo, String AName);
String APP_GetCodeDefCode(TcxComboBox *ACombo);
String APP_GetCodeDefDesc(TcxComboBox *ACombo);
int    APP_SetCode(TcxComboBox *ACombo, String ACode);

//////////////////////////////////////////////////////////////////////////////////
class TVmsSizeType : public TObject
{
public:	// User declarations
    String TypeCd;
    String TypeNm;
    int    Width;
    int    Height;

public:		// User declarations
    __fastcall TVmsSizeType(String ATypeCd,
                            String ATypeNm,
                            int    AWidth,
                            int    AHeight)
    {
        TypeCd = ATypeCd;
        TypeNm = ATypeNm;
        Width  = AWidth;
        Height = AHeight;
    }
};
//////////////////////////////////////////////////////////////////////////////////

void APP_DelVmsSizeCombo(TcxComboBox *cboBox);
void APP_FillVmsSizeType(TcxComboBox *cboBox, bool bAddAll=false);
TVmsSizeType* APP_GetVmsSizeTypeObject(TcxComboBox *cboBox);

String APP_FormatStr(String AStrDateTime, String AFormat);
void APP_SetSummaryItemKind(TcxSummaryEventArguments    &Arguments,
                            TcxSummaryEventOutArguments &OutArguments,
                            int                         pKind,
                            bool                        pCaptionDisplay,
                            bool                        pPointDisplay);

bool APP_WriteConfigInfo(String sCfgFile, String sTitle, String sItem, String sValue);
bool APP_IsDirectoryExists(LPCTSTR path);


#endif

