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

#ifndef VMS00MAPFH
#define VMS00MAPFH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <DB.hpp>
#include <DBClient.hpp>
#include <Provider.hpp>
#include <ADODB.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <ImgList.hpp>
#include <Menus.hpp>
#include <pngimage.hpp>
#include <map.h>
#include <vector.h>
#include "ImageBtn.h"
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include "DataTypesF.h"
#include "WindowMsgF.h"
#include "cxCheckBox.hpp"
#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 "cxMaskEdit.hpp"
#include "cxProgressBar.hpp"
#include "cxSpinEdit.hpp"
#include "cxTextEdit.hpp"
#include "dxGDIPlusClasses.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 "dxSkinSeven.hpp"
#include "dxSkinSharp.hpp"
#include "dxSkinSilver.hpp"
#include "dxSkinStardust.hpp"
//#include "ShockwaveEx.hpp"
//#include "ShockwaveFlashObjects_TLB.hpp"
#include <OleCtrls.hpp>

//---------------------------------------------------------------------------
/*
******************************************************************************
* Define constant
******************************************************************************
*/
/*
*  이전/다음 구현을 위한 구조체 선언(정적 이중링크로 구현)
*/
#define D_EXT_QUEUE_SIZE        256 //512//1024/2048
#define D_EXT_QUEUE_MASK        (D_EXT_QUEUE_SIZE-1)

/*
*  레이어 Extent 정보
*/
enum TXiMapOperation { Nothing, OnZoomIn, OnZoomOut, OnPanSt, OnDistance, OnSelect, OnGeoQuery, OnEditting, OnCircle, OnShortPath, OnArea, OnInsert, OnFindEvent, OnNearFind, OnUserDefine };

struct TLinkTrfGrd
{

public:
	Graphics::TColor SpdCOLOR;
	int MinSpeed;
	int MaxSpeed;
};

struct TDBLinkColor
{

public:
	TLinkTrfGrd GDLOW;
	TLinkTrfGrd GDMID;
	TLinkTrfGrd GDHIG;
};

struct TUTISLinkGrade
{

public:
	TDBLinkColor road101;
	TDBLinkColor road102;
	TDBLinkColor road103;
	TDBLinkColor road104;
	TDBLinkColor road105;
	TDBLinkColor road106;
	TDBLinkColor road107;
};

struct TDDPoint
{

public:
	double X;
	double Y;
};
struct TDDRect
{

	union
	{
		struct
		{
			TDDPoint MinXY;
			TDDPoint MaxXY;

		};
		struct
		{
			double MinX;
			double MinY;
			double MaxX;
			double MaxY;

		};

	};
};

typedef struct
{
    bool    bExtent;
    short   userIdx;
    short   currIdx;
    TDDRect extent[D_EXT_QUEUE_SIZE+1];
} EXTENT_LIST_QUEUE;

//---------------------------------------------------------------------------
class TVMS00MAP : public TForm
{
__published:	// IDE-managed Components
    TTimer *TmrShow;
    TPanel *PnlProgress;
    TcxProgressBar *PbLoadMap;
    TPanel *Panel5;
    TImage *ImgBoundary_n;
    TImage *ImgPrint_n;
    TImage *ImgPrint_c;
    TImage *ImgRefresh_c;
    TImage *ImgRefresh_n;
    TImage *ImgFull_n;
    TImage *ImgFull_c;
    TImage *ImgSquare_c;
    TImage *ImgSquare_n;
    TImage *ImgBoundary_c;
    TImage *ImgNext_c;
    TImage *ImgNext_n;
    TImage *ImgPan_n;
    TImage *ImgPan_c;
    TImage *ImgZoomOut_c;
    TImage *ImgZoomOut_n;
    TImage *ImgStnd_c;
    TImage *ImgSave_n;
    TImage *ImgSave_c;
    TImage *ImgStnd_n;
    TImage *ImgDist_c;
    TImage *ImgCircle_n;
    TImage *ImgCircle_c;
    TImage *ImgDist_n;
    TImage *ImgSel_c;
    TImage *ImgSel_n;
    TImage *ImgPrev_n;
    TImage *ImgPrev_c;
    TImage *ImgCenter_c;
    TImage *ImgCenter_n;
    TImage *ImgZoomIn_c;
    TImage *ImgZoomIn_n;
    TImageBtn *ImgBoundary;
    TImageBtn *ImgPrint;
    TImageBtn *ImgDist;
    TImageBtn *ImgSquare;
    TImageBtn *ImgCircle;
    TImageBtn *ImgSave;
    TImage *ImgSelect_old;
    TTimer *TmrSelect;
    TTimer *TmrLinkSelect;
    TImage *ImgSelect;
    TPanel *PnlToolBar;
    TGroupBox *GroupBox1;
    TImageBtn *ImgPan;
    TImageBtn *ImgZoomIn;
    TImageBtn *ImgZoomOut;
    TImageBtn *ImgSel;
    TImageBtn *ImgCenter;
    TImageBtn *ImgPrev;
    TImageBtn *ImgNext;
    TImageBtn *ImgFull;
    TImageBtn *ImgStnd;
    TImageBtn *ImgRefresh;
    TGroupBox *GroupBox2;
    TcxCheckBox *ChkViewExample;
    TcxCheckBox *ChkTrafficLayer;
    TcxCheckBox *ChkGisSearch;
    TcxCheckBox *ChkToolTip;
    TGroupBox *GrpPos;
    TLabel *Label11;
    TLabel *Label12;
    TcxSpinEdit *SePosY;
    TcxSpinEdit *SePosX;
    TcxGroupBox *panRemark;
    TGroupBox *GroupBox8;
    TGroupBox *GroupBox10;
    TcxLabel *cxLabel6;
    TcxLabel *cxLabel7;
    TcxLabel *cxLabel8;
    TPanel *PnlTrf01;
    TPanel *PnlTrf02;
    TPanel *PnlTrf03;
    TPanel *PnlTrf00;
    TcxLabel *cxLabel13;
    TcxLabel *cxLabel14;
    TcxLabel *cxLabel15;
    TcxLabel *cxLabel16;
    TImage *ImgOffice;
    TImage *ImgTemp;
    TImage *ImgTurn001;
    TImage *ImgTurn002;
    TImage *ImgTurn003;
    TImage *ImgTurn011;
    TImage *ImgTurn012;
    TImage *ImgTurn101;
    TImage *ImgTurn102;
    TImage *ImgTurn103;
    TPopupMenu *pmuVms;
    TMenuItem *mnuVmsMsg;
    TMenuItem *mnuVmsCam;
    TMenuItem *mnuVmsPingCtrl;
    TPanel *PnlMapInfo;
    TImage *ImgDesc27;
    TImage *ImgDesc37;
    TLabel *Label16;
    TLabel *Label3;
    TLabel *LblZoomLevel;
    TLabel *LblLinkLevel;
    TMenuItem *MnuVmsId;
    TMenuItem *N3;
    TMenuItem *NetworkPing2;
    TMenuItem *mnuVmsPingWeb;
    TGroupBox *GroupBox4;
    TImage *ImgCurrent;
    TcxLabel *LblCurrTemp;
    TGroupBox *GroupBox5;
    TImage *ImgForecast;
    TcxLabel *LblMaxFore;
    TcxLabel *LblMinFore;
    TcxLabel *LblTraffic;
    TTimer *TmrLblTraffic;
    TPanel *Panel2;
//    TShockwaveFlashEx *ShockwaveFlash1;
    TMemo *Memo1;
    TTimer *TmrRefresh;
    TPopupMenu *pmuGis;
    TMenuItem *N1;
    TMenuItem *pmuGisDefault;
    TMenuItem *pmuMove;
    TMenuItem *pmuZoomIn;
    TMenuItem *pmuZoomOut;
    TMenuItem *pmuIconSel;
    TMenuItem *pmuMoveCenter;
    TMenuItem *N2;
    TMenuItem *pmuCalLen;
    TMenuItem *pmuCalArea;
    TMenuItem *pmuRadius;
    TMenuItem *N7;
    TMenuItem *MnuSetStdArea;
    TMenuItem *MnuMoveStdArea;
    TcxCheckBox *ChkDrawIncident;
    TcxCheckBox *ChkDrawVms;
    TImage *ImgVmsN;
    TImage *ImgVmsC;
    TImage *ImgVmsM;
    TGroupBox *GroupBox3;
    TPanel *Pnl01;
    TPanel *Pnl02;
    TPanel *Pnl03;
    TPanel *Pnl00;
    TcxLabel *cxLabel1;
    TcxLabel *cxLabel2;
    TcxLabel *cxLabel3;
    TcxLabel *cxLabel4;
    TGroupBox *GroupBox6;
    TImage *Image1;
    TImage *Image2;
    TImage *Image3;
    TcxLabel *cxLabel5;
    TcxLabel *cxLabel9;
    TcxLabel *cxLabel10;
    TMenuItem *mnuVmsIfsc;
    TcxCheckBox *ChkViewAllIfsc;
    void __fastcall FormDestroy(TObject *Sender);
    void __fastcall FormShow(TObject *Sender);
    void __fastcall TmrShowTimer(TObject *Sender);
    void __fastcall pmuControlGisClick(TObject *Sender);
    void __fastcall ImgPrevClick(TObject *Sender);
    void __fastcall ImgNextClick(TObject *Sender);
    void __fastcall ImgStndClick(TObject *Sender);
    void __fastcall ImgRefreshClick(TObject *Sender);
    void __fastcall ChkTrafficLayerClick(TObject *Sender);
    void __fastcall ChkDrawGisClick(TObject *Sender);
    void __fastcall TmrSelectTimer(TObject *Sender);
    void __fastcall TmrLinkSelectTimer(TObject *Sender);
    void __fastcall MnuMoveStdAreaClick(TObject *Sender);
    void __fastcall mnuFacilityPingClick(TObject *Sender);
    void __fastcall pmuFacilityPopup(TObject *Sender);
    void __fastcall mnuVmsMsgClick(TObject *Sender);
    void __fastcall mnuVmsCamClick(TObject *Sender);
    void __fastcall ChkGisSearchClick(TObject *Sender);
    void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
    void __fastcall panRemarkMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y);
    void __fastcall ChkViewExamplePropertiesChange(TObject *Sender);
    void __fastcall TmrLblTrafficTimer(TObject *Sender);
    void __fastcall FormResize(TObject *Sender);
    //void __fastcall ShockwaveFlash1FlashCall(TObject *ASender, const WideString request);
    void __fastcall PnlToolBarDblClick(TObject *Sender);
    void __fastcall TmrRefreshTimer(TObject *Sender);
    void __fastcall mnuVmsIfscClick(TObject *Sender);
    void __fastcall ChkViewAllIfscClick(TObject *Sender);
    void __fastcall Memo1DblClick(TObject *Sender);

private:	// User declarations
public:

    bool            MapInit;
    bool            MapStart;
    bool            ModeSelect;

    // For Map
    int             m_nMapLevel;

	//마우스 제어 플래그
	TPoint          m_ptDown;
    bool            m_bMouseDown;
    bool            m_bMoveCenter;
    bool            m_bCalcMode;
    bool            m_bCalcCont;

public:
    /*
    *  지도 이전/이후 보기 핸들러, 전자지도엔진에서 함수지원은 하나 기능이 수행안됨
    */
    EXTENT_LIST_QUEUE   m_ExtQ;                 // 이전/다음 정보를 저장할 전역변수
    TDDRect             m_PrevExt;
    bool __fastcall PrevExtentQ();
    bool __fastcall NextExtentQ();
    bool __fastcall AddExtentQ(TDDRect &curRc);
    void __fastcall SetExtent(TDDRect &curRc);
    
public:		// User declarations
    __fastcall TVMS00MAP(TComponent* Owner, TForm *ParentForm);

    void __fastcall LoadLocalSkin();
    void __fastcall CommClose();
    bool __fastcall FormInit();

    void __fastcall LoadGisMap();
    void __fastcall SetMapOperation(TXiMapOperation nMapOper);
    
    void __fastcall GisMenuCheckClear();

    void __fastcall RefreshMapTraffic();
    
    // Object Select
    TDDPoint        m_ptSelect;
    void __fastcall SelectObjectByPos(double dPosX, double dPosY, bool bArrow=false);

    void __fastcall RefreshGisLink();
    bool __fastcall SelectLinkById(int ALinkLevel, String sId, bool bHide=false);

    void __fastcall ShowVmsMessage(String AId, TPoint pt);
    void __fastcall ShowVmsCamera(String AId, TPoint pt);

    void __fastcall ShowLinkDetailInfo(String sLinkId, int nLinkLevel);

    void __fastcall UpdateFacilityStatus();
    void __fastcall UpdateIncidentStatus();
    String  FSelId;

    void __fastcall LoadMap();
    void __fastcall ShowHideFacility();
    void __fastcall OnMapPopupMenu(String AType, String AId, String APosX, String APosY, String AInfo);
    void __fastcall SelGisItem(int AType, String AId);
};
//---------------------------------------------------------------------------
extern PACKAGE TVMS00MAP *VMS00MAP;
//---------------------------------------------------------------------------
#endif

