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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "AppGlobalF.h"
#include "CDSCodeF.h"
#include "CDSFacilityF.h"
#include "CDSNodeF.h"
#include "CDSLinkF.h"
#include "ITSLangTransF.h"
#include "ITSMapF.h"
#include "CDSLayerF.h"
#include "ITS_OPLibF.h"
#pragma hdrstop

#include "CRSM200MF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "FRAME_CrsCamListF"
#pragma link "cxButtons"
#pragma link "cxCheckBox"
#pragma link "cxClasses"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxDropDownEdit"
#pragma link "cxEdit"
#pragma link "cxFilter"
#pragma link "cxGraphics"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxGroupBox"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxMaskEdit"
#pragma link "cxSpinEdit"
#pragma link "cxSplitter"
#pragma link "cxStyles"
#pragma link "cxTextEdit"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "FRAME_OpenMapF"
#pragma link "cxCalc"
#pragma link "dxSkinMcSkin"
#pragma resource "*.dfm"

TCRSM200M *CRSM200M = NULL;
//---------------------------------------------------------------------------
void TCRSM200M_MapCallback(TObject *ASender, const String AFunc, const String AArgs, const bool AFirst)
{
    try
    {
        if (!CRSM200M) return;
        CRSM200M->OpenMapCallback(ASender, AFunc, AArgs, AFirst);
    }
    catch(Exception &exception)
    {
    }
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
__fastcall TCRSM200M::TCRSM200M(TComponent* Owner)
    : TForm(Owner)
{
    LangTrans->Translate(this, ITSDb_GetConnection());
    ITSSkin_Load(this);
    CMM_LoadForm(g_sFormsDir, this);

    FUpdate= false;
    FTitle = Caption;

    m_pGDC = FRAMECrsCamList1->TvList->DataController;

    FRAMECrsCamList1->PnlTop->Visible = false;
    FRAMECrsCamList1->PnlBottom->Visible = false;
    FRAMECrsCamList1->ColumnSel->Visible = false;

    FLayerIdx = LyrTp_CrsCam;
    FRAMEOpenMap1->LayerIdx = FLayerIdx;
    FRAMEOpenMap1->MapCallbackFunc = TCRSM200M_MapCallback;
    FRAMEOpenMap1->ChkShowNmbr->Caption = "카메라 ID";

    EditMode = false;
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::CommClose()
{
    try
    {
        CMM_SaveForm(g_sFormsDir, this);
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::FormShow(TObject *Sender)
{
    Refresh();

    FRAMEOpenMap1->OpenMap();

    CbCTLR_MNGM_NMBR->Properties->Items->Clear();

    CrossManager->FLists.Lock();
    try
    {
        FOR_STL(TCross*, pObj, CrossManager->FLists)
        {
            if (pObj->DEL_YN == "Y") continue;

            String sId = pObj->CROSS_ID;  //관리번호
            String sNm = pObj->CROSS_NM;            //위치
            CbCTLR_MNGM_NMBR->Properties->Items->Add("[" + sId + "] " + sNm);

            pObj->FData3 = NULL;

            FOR_STL(TCrossCam*, pTmp, pObj->FLists)
            {
                if (pTmp->DEL_YN == "Y") continue;
                pTmp->FData3 = NULL;
            }
        }
    }
    __finally
    {
        CrossManager->FLists.UnLock();
    }
    CbCTLR_MNGM_NMBR->ItemIndex = -1;

    FormInit();
    ChangeEditMode(1);
    TmrShow->Enabled = true;
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::FormInit()
{
    EdCrossId->Text = "";
	EdNmbr->Text    = "";
    EdCamId->Text   = "";
	EdCamNm->Text   = "";
    EdCtlrIp->Text  = "";
    EdRtspUrl->Text = "";
    EdRtspId->Text  = "";
    EdRtspPwd->Text = "";

    ChkRightTurn->Checked = true;

    SePosX->Value = 0;
    SePosY->Value = 0;

    Cb_USE_YN->ItemIndex = 1;

    FNewDb = false;
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::TmrShowTimer(TObject *Sender)
{
    TmrShow->Enabled = false;

    //CrossManager->LoadCrossCam();
    UpdateList();
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::UpdateList()
{
    FRAMECrsCamList1->UpdateList();
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::BtnCloseClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::FormClose(TObject *Sender, TCloseAction &Action)
{
    CommClose();
    CRSM200M = NULL;
    Action = caFree;
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::FormCloseQuery(TObject *Sender, bool &CanClose)
{
    if (FUpdate)
    {
        POST_MSG(Application->MainForm->Handle, WM_DATABASE_REFRESH, WP_MSG_14, 0);
    }

    FRAMECrsCamList1->OnCloseQuery(CanClose);
    FRAMEOpenMap1->OnCloseQuery(CanClose);
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::DisplayInfo(TCrossCam* AObj, bool AMoveObj/*=true*/)
{
    FormInit();

    if (!AObj) return;

    if (AMoveObj)
    {
        sJs.printf(L"selectLayerObject(%d, '%s', %d)", FLayerIdx, AObj->CAM_ID.c_str(), FRAMEOpenMap1->MapZoom);
        FRAMEOpenMap1->ExecScript(sJs);
    }

    CMM_SetComboBoxItem(CbCTLR_MNGM_NMBR, AObj->CROSS_ID);

    EdCrossId->Text = AObj->CROSS_ID;
	EdNmbr->Text    = AObj->CAM_ID;
    EdCamId->Text   = AObj->CAM_ID;
	EdCamNm->Text   = AObj->CAM_NM;

    EdCtlrIp->Text  = AObj->IP;
    EdRtspUrl->Text = AObj->RTSP_URL;
    EdRtspId->Text  = AObj->ID;
    EdRtspPwd->Text = AObj->PWD;

    ChkRightTurn->Checked = AObj->RIGHT_USE == "1" ? true : false;
    SeRtspPort->Value     = AObj->RTSP_PORT;
    SeHttpPort->Value     = AObj->HTTP_PORT;
    SeAngle->Value        = AObj->ANGLE;

    SePosX->Value = AObj->X_CRDN;
    SePosY->Value = AObj->Y_CRDN;

    //Cb_USE_YN->Text = AObj->DEL_YN;

    ChangeEditMode(3);
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::UpdateIcon()
{
    if (!FRAMEOpenMap1->MapStart) return;

    sJs.printf(L"removeLayerObject(%d)", FLayerIdx);
    FRAMEOpenMap1->ExecScript(sJs);

    String arrObj = "";
    String sTemp;

    CrossManager->FLists.Lock();
    try
    {
        FOR_STL(TCross*, pTmp, CrossManager->FLists)
        {
            if (pTmp->DEL_YN == "Y") continue;

            FOR_STL(TCrossCam*, pObj, pTmp->FLists)
            {
                if (pObj->DEL_YN == "Y") continue;

                if (arrObj != "") arrObj += "|";

                sTemp.printf(L"%s,%s,%s,%.6f,%.6f,0,0,0,0", pObj->CAM_ID.c_str(), pObj->CAM_ID.c_str(), pObj->CAM_NM.c_str(), pObj->X_CRDN, pObj->Y_CRDN);
                arrObj += sTemp;
            }
        }
    }
    __finally
    {
        CrossManager->FLists.UnLock();
        if (arrObj != "")
        {
            sJs.printf(L"addFacility(%d, '%s')", FLayerIdx, arrObj.c_str());
            FRAMEOpenMap1->ExecScript(sJs);
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::BtnEditClick(TObject *Sender)
{
    String sCrossId = EdCrossId->Text;
    String sCamId = EdNmbr->Text;
    TCross *pCross = CrossManager->FLists.Find(sCrossId);
    TCrossCam *pObj = NULL;
    if (pCross)
    {
        pObj = pCross->FLists.Find(sCamId);
    }

    if (BtnEdit->Caption == FrmLang->lblEdit->Caption)//"편집")
    {
        ChangeEditMode(0);
        if (pObj)
        {
            //시설물아이콘을 편집아이콘으로 변경
            //function editFacilityObject(ALyrIdx, ANmbr, AComm(0:오류-편집,1:정상), AEdit(편집모드:1-편집,0-편집취소))
            sJs.printf(L"editFacilityObject(%d, '%s', 1, 1)", FLayerIdx, pObj->CAM_ID.c_str());
            FRAMEOpenMap1->ExecScript(sJs);
            FNewDb = false;
        }
    }
    else
    {
        //편집모드 취소
        ChangeEditMode(1);
        if (pObj)
        {
            //원래 정보를 화면에 표출
            CMM_SetGridRow(FRAMECrsCamList1->CxList, FRAMECrsCamList1->TvList, sCamId, FRAMECrsCamList1->Column02->Index);
            DisplayInfo(pObj, false);

            //추가 모드에서 취소하는 경우 지도에 신규로 추가한 객체를 찾아서 삭제해 주는것 보다
            //새롭게 다시 그리자
            UpdateIcon();
        }
        else
        {
            //객체가 없는 경우는 추가 모드에서 취소한 경우임
            sJs.printf(L"removeFacilityObject(%d, '%s')", FLayerIdx, sCamId.c_str());
            FRAMEOpenMap1->ExecScript(sJs);
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::ChangeEditMode(int AEdit)
{
    bool bGisEdit = true;
    bool bEnabled = false;

    switch(AEdit)
    {
    case 0: //편집버튼클릭
        {
            BtnEdit->Enabled = true;
            BtnInsert->Enabled = false;
            BtnDelete->Enabled = false;
            BtnSave->Enabled = true;

            BtnEdit->Caption = FrmLang->lblCancel->Caption;//"취소";
            BtnEdit->Hint    = FrmLang->lblCancel->Hint;//데이터 편집 취소";
            bEnabled = true;
            EditMode = true;
        }
        break;
    case 1: //편집[취소]버튼클릭
        {
            FormInit(); //화면을 모두 지운다.
            BtnEdit->Enabled = false;
            BtnInsert->Enabled = true;
            BtnDelete->Enabled = false;
            BtnSave->Enabled = false;

            BtnEdit->Caption = FrmLang->lblEdit->Caption;//"편집";
            BtnEdit->Hint    = FrmLang->lblEdit->Hint;//데이터 편집";
            bEnabled = true;
            bGisEdit = false;
            EditMode = false;
        }
        break;
    case 2: //추가
        {
            BtnEdit->Enabled = true;
            BtnInsert->Enabled = false;
            BtnDelete->Enabled = false;
            BtnSave->Enabled = true;

            BtnEdit->Caption = FrmLang->lblCancel->Caption;//"취소";
            BtnEdit->Hint    = FrmLang->lblCancel->Hint;//데이터 편집 취소";
            bEnabled = false;
            EditMode = true;
        }
        break;
    case 3: //수정모드
        {
            BtnEdit->Enabled = true;
            BtnInsert->Enabled = true;
            BtnDelete->Enabled = true;
            BtnSave->Enabled = false;

            BtnEdit->Caption = FrmLang->lblEdit->Caption;//"편집";
            BtnEdit->Hint    = FrmLang->lblEdit->Hint;//데이터 편집";
            bEnabled = true;
            EditMode = true;
        }
        break;
    }

    if (AEdit == 0 || AEdit == 2)
    {
        FRAMECrsCamList1->CxList->Enabled = false;
    }
    else
    {
        FRAMECrsCamList1->CxList->Enabled = true;
    }
    CbCTLR_MNGM_NMBR->Properties->ReadOnly = bEnabled;
    PnlEdit->Enabled = EditMode;
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::BtnInsertClick(TObject *Sender)
{
    int nMsgType = MB_OK|MB_ICONERROR|MB_APPLMODAL;

    String sCrossId = ITSUtil_GetCode(CbCTLR_MNGM_NMBR->Text);
    if (sCrossId == "")
    {
        if (CbCTLR_MNGM_NMBR->Properties->Items->Count == 0)
        {
            Application->MessageBox(L"교통량교차로 정보를 선택하세요.",
                                     FTitle.c_str(), nMsgType);
		    return;
        }
        else
        {
            CbCTLR_MNGM_NMBR->ItemIndex = 0;
            sCrossId = ITSUtil_GetCode(CbCTLR_MNGM_NMBR->Text);
        }
    }

	String sCamId = InputBox("카메라 ID",
                          "신규 카메라 ID를 입력하세요.",
                          "최대10자리" );

    sCamId = sCamId.Trim();
	if (sCamId == "최대10자리" || sCamId == "")
	{
		return;
	}
	if (AnsiString(sCamId).Length() > 10)
	{
        Application->MessageBox(L"카메라 ID는 10Byte를 초과할 수 없습니다.",
                                FTitle.c_str(), nMsgType);
		return;
	}

    CrossManager->FLists.Lock();
    FOR_STL(TCross*, pObj, CrossManager->FLists)
    {
        TCrossCam *pDb = pObj->FLists.Find(sCamId);
        if (pDb)
        {
            String sErr = "카메라 ID [" + sCamId + "]는 이미 사용 중 입니다.";
            Application->MessageBox(sErr.c_str(), FTitle.c_str(), nMsgType);
            CrossManager->FLists.UnLock();
            return;
        }
    }
    CrossManager->FLists.UnLock();


    FormInit();

    EdCrossId->Text  = sCrossId;
    EdNmbr->Text     = sCamId;
    EdCamId->Text    = EdNmbr->Text;
    SePosX->Value = FRAMEOpenMap1->CenterX;
    SePosY->Value = FRAMEOpenMap1->CenterY;

    //지도에 새로운 시설물 아이콘 추가하면서 편집모드로 변경
    String arrObj = "";
    arrObj.printf(L"%s,New,New,%.6f,%.6f,1", sCamId.c_str(), FRAMEOpenMap1->CenterX, FRAMEOpenMap1->CenterY);
    sJs.printf(L"addFacilityObject(%d, '%s')", FLayerIdx, arrObj.c_str());
    FRAMEOpenMap1->ExecScript(sJs);

    ChangeEditMode(2);
    FNewDb = true;
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::BtnDeleteClick(TObject *Sender)
{
    int nIdx = m_pGDC->FocusedRecordIndex;
    if (nIdx < 0) return;

    TCross *pCross;
    TCrossCam *pObj;

    String sCamId   = EdNmbr->Text;
    String sCrossId = ITSUtil_GetCode(CbCTLR_MNGM_NMBR->Text);

    pCross = CrossManager->FLists.Find(sCrossId);
    if (pCross)
    {
        pObj = pCross->FLists.Find(sCamId);
    }

    if (!pCross || !pObj)
    {
        Application->MessageBox(lblText2->Caption.c_str(),
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
        return;
    }

    String sMsg;
    sMsg = lblText3->Caption + ": " + sCamId;
    sMsg+= "\r\n" + lblText4->Caption;

    if (Application->MessageBox(sMsg.c_str(), FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return;

    if (pObj)
    {
		if (CrossManager->DeleteCrossCam(pObj))
		{
            pObj->DEL_YN = "Y";
            UpdateList();
		}

        Application->MessageBox(lblText5->Caption.c_str(), FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);

        FUpdate = true;

        FormInit();
        ChangeEditMode(1);
        UpdateIcon();
	}
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::BtnSaveClick(TObject *Sender)
{
    TCross *pCross;
    TCrossCam *pObj;

    String sCamId   = EdNmbr->Text;
    String sCrossId = ITSUtil_GetCode(CbCTLR_MNGM_NMBR->Text);

    pCross = CrossManager->FLists.Find(sCrossId);

    if (!pCross                           ||
        EdCrossId->Text.Trim().IsEmpty()  ||
        EdCamId->Text.Trim().IsEmpty()    ||
        EdNmbr->Text.Trim().IsEmpty()     ||
        EdCamNm->Text.Trim().IsEmpty()    ||
        SePosX->Value == 0                ||
        SePosY->Value == 0                ||
        CbCTLR_MNGM_NMBR->ItemIndex < 0  )
	{
        Application->MessageBox(FrmLang->lblCnfm->Caption.c_str(),
                                FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
		return;
	}

    if (!FNewDb)
    {
        //수정모드일때 컨트롤러가 다르다면 신규로 처리한다.
        if (EdCrossId->Text != sCrossId)
        {
            TCross *pTmpCross = CrossManager->FLists.Find(EdCrossId->Text);
            if (pTmpCross)
            {
                pTmpCross->FLists.Remove(sCamId);
            }
            FNewDb = true;
        }
    }

    if (FNewDb)
    {
        pObj = new TCrossCam();
        pObj->DIRECTION = "0";
        pObj->DEL_YN = "N";
    }
    else
    {
        pObj = pCross->FLists.Find(sCamId);
    }

    if (pObj)
    {
        pObj->CROSS_ID = EdCrossId->Text;
        pObj->CAM_ID   = EdCamId->Text;
        pObj->CAM_NM   = EdCamNm->Text.Trim();

        pObj->IP       = EdCtlrIp->Text.Trim();
        pObj->RTSP_URL = EdRtspUrl->Text.Trim();
        pObj->ID       = EdRtspId->Text.Trim();
        pObj->PWD      = EdRtspPwd->Text.Trim();

        pObj->RIGHT_USE = ChkRightTurn->Checked ? "1" : "0";
        pObj->RTSP_PORT = SeRtspPort->Value;
        pObj->HTTP_PORT = SeHttpPort->Value;
        pObj->ANGLE     = SeAngle->Value;

        pObj->X_CRDN = SePosX->Value;
        pObj->Y_CRDN = SePosY->Value;

        bool bResult;
        bResult = CrossManager->SaveCrossCam(pObj);

        if (bResult)
        {
            Application->MessageBox(FrmLang->lblDbSave->Caption.c_str(),//L"VDS-검지기 정보저장\r\nVDS-검지기 정보를 저장 하였습니다.",
                                    FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);

            if (FNewDb)
            {
                pCross->FLists.Push(pObj->CAM_ID, pObj);
                TCrossCam *pTmp = new TCrossCam();
                pObj->Copy(pTmp);
                CrossManager->FCamLists.Push(pTmp->CAM_ID, pTmp);
            }

            FUpdate = true;

            UpdateList();
            UpdateIcon();
            CMM_SetGridRow(FRAMECrsCamList1->CxList, FRAMECrsCamList1->TvList, sCamId, FRAMECrsCamList1->Column02->Index);
            DisplayInfo(pObj, true);
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::FRAMECrsCamList1TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
          TMouseButton AButton, TShiftState AShift, bool &AHandled)
{
	if (!ACellViewInfo) return;
	int nRow = FRAMECrsCamList1->TvList->DataController->FocusedRecordIndex;
	if( nRow <= -1 )
		return;

    int nMemPtr = FRAMECrsCamList1->TvList->DataController->Values[nRow][FRAMECrsCamList1->Column99->Index];
    TCrossCam* pObj = (TCrossCam*)nMemPtr;
    DisplayInfo(pObj);
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::UpdateEditLink()
{
    if (!FRAMEOpenMap1->MapStart) return;

    TItsNode* pNode;
    String    STRT_NM;
    String    END_NM;

    try
    {
        ItsLinkManager->FLists.Lock();
        try
        {
            FOR_STL(TItsLink*, pLink, ItsLinkManager->FLists)
            {
                if (pLink->DEL_YN == "Y")   continue;

#if 0
                pVrtx = pLink->Vrtxs.Find(nZoom);
                if (!pVrtx) continue;

                pNode = ItsNodeManager->FLists.Find(pLink->F_NODE_ID);
                if (pNode) STRT_NM = pNode->NODE_NAME; else STRT_NM = " ";
                pNode = ItsNodeManager->FLists.Find(pLink->T_NODE_ID);
                if (pNode) END_NM = pNode->NODE_NAME; else END_NM = " ";

                sJs.printf(L"addEditLink('%s', '%s', '%s', '%s', '%s', '%s')",
                    pLink->LINK_ID.c_str(),
                    pLink->ROAD_NAME.c_str(),
                    STRT_NM.c_str(),
                    END_NM.c_str(),
                    pVrtx->X_CRDN_ARR.c_str(),
                    pVrtx->Y_CRDN_ARR.c_str());

                FRAMEOpenMap1->ExecScript(sJs);
#else
                if (pLink->IsVertex)
                {
                    pNode = ItsNodeManager->FLists.Find(pLink->F_NODE_ID);
                    if (pNode) STRT_NM = pNode->NODE_NAME; else STRT_NM = " ";
                    pNode = ItsNodeManager->FLists.Find(pLink->T_NODE_ID);
                    if (pNode) END_NM = pNode->NODE_NAME; else END_NM = " ";

                    sJs.printf(L"addEditLink('%s', '%s', '%s', '%s', '%s', '%s')",
                        pLink->LINK_ID.c_str(),
                        pLink->ROAD_NAME.c_str(),
                        STRT_NM.c_str(),
                        END_NM.c_str(),
                        pLink->X_CRDN_ARR.c_str(),
                        pLink->Y_CRDN_ARR.c_str());

                    FRAMEOpenMap1->ExecScript(sJs);
                }
#endif
            }
        }
        __finally
        {
            ItsLinkManager->FLists.UnLock();
        }
        FRAMEOpenMap1->ExecScript("makeEditLinkLayer()");
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::OpenMapCallback(TObject *ASender, const String AFunc, const String AArgs, const bool AFirst)
{
    try
    {
        if (AFirst)
        {
            //지도를 편집모드로 변경
            sJs.printf(L"setEditMode(%d, 1)", FLayerIdx);
            FRAMEOpenMap1->ExecScript(sJs);

            //시설물아이콘 등록
            UpdateIcon();

            sJs.printf(L"extentLayer(%d)", FLayerIdx);
            FRAMEOpenMap1->ExecScript(sJs);
            return;
        }

        if (AFunc.Pos("onfacilitydragend"))
        {
            TStringList *pStringList = new TStringList;
            pStringList->CommaText = AArgs;

            try
            {
                String sNmbr      = pStringList->Strings[0];
                String sCenterLat = pStringList->Strings[1];
                String sCenterLng = pStringList->Strings[2];
                SePosX->Value = sCenterLat.ToDouble();
                SePosY->Value = sCenterLng.ToDouble();
            }
            catch(Exception &e)
            {
            }
            delete pStringList;
        }
    }
    catch(Exception &exception)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TCRSM200M::ChkViewIconClick(TObject *Sender)
{
    if (!FRAMEOpenMap1->MapStart) return;
    sJs.printf(L"showLayerText(%d, %d)", FLayerIdx, (ChkViewIcon->Checked) ? 1: 0);
    FRAMEOpenMap1->ExecScript(sJs);
}
//---------------------------------------------------------------------------

