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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "AppGlobalF.h"
#include "CDSVmsIfscF.h"
#include "ITSLangTransF.h"
#include "CDSFontF.h"
#pragma hdrstop

#include "VMSM630MF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "VmsDesignerF"
#pragma link "FFBaseComponent"
#pragma link "FFBasePlay"
#pragma link "FFPlay"
#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 "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 "cxImage"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxMaskEdit"
#pragma link "cxStyles"
#pragma link "cxTextEdit"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinCaramel"
#pragma link "dxSkinCoffee"
#pragma link "dxSkinDarkRoom"
#pragma link "dxSkinDarkSide"
#pragma link "dxSkinFoggy"
#pragma link "dxSkinGlassOceans"
#pragma link "dxSkiniMaginary"
#pragma link "dxSkinLilian"
#pragma link "dxSkinLiquidSky"
#pragma link "dxSkinLondonLiquidSky"
#pragma link "dxSkinMcSkin"
#pragma link "dxSkinMoneyTwins"
#pragma link "dxSkinOffice2007Black"
#pragma link "dxSkinOffice2007Blue"
#pragma link "dxSkinOffice2007Green"
#pragma link "dxSkinOffice2007Pink"
#pragma link "dxSkinOffice2007Silver"
#pragma link "dxSkinOffice2010Black"
#pragma link "dxSkinOffice2010Blue"
#pragma link "dxSkinOffice2010Silver"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxSkinSeven"
#pragma link "dxSkinSharp"
#pragma link "dxSkinSilver"
#pragma link "dxSkinStardust"
#pragma link "cxBlobEdit"
#pragma resource "*.dfm"

#define LICENSE_KEY "FSXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX"

TVMSM630M *VMSM630M = NULL;
//---------------------------------------------------------------------------

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

    FSelected = false;
    FUpdate= false;
    FTitle = Caption;//"VMS 교통상황 폼 관리";

    FPlayerFile  = "";
    FTrackBar    = TrackBar1;
    FLblDuration = lblDuration1;
    FLblCurrPTS  = lblCurrentPTS1;
    FFPlayer     = FFPlayer1;
    FDispArea    = PnlEdtBack;
    FDispArea->Tag = 0;
    FDispArea->ParentColor = false;
    FDispArea->Color = clBlack;
    FDispArea->Caption = "";
    FDispArea->Refresh();

    String sAVILibDir = g_sAppDir + "LibAV";
    FFPlayer1->SetLicenseKey(LICENSE_KEY);
    FFPlayer1->DisableFPUExceptions();
    if (!FFPlayer1->LoadAVLib(sAVILibDir))
    {
        if (g_AppCfg.sLang != "kr") Application->MessageBox(L"Stream display library load failed.", L"Stream display fail", MB_OK|MB_ICONERROR|MB_APPLMODAL);
        else                        Application->MessageBox(L"영상표출 라이브러리를 로드하지 못하였습니다.", L"영상표출 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
    }

    TvList->OptionsView->DataRowHeight  = 0;
    TvList->OptionsView->CellAutoHeight = true;
    TvList->OptionsView->Indicator      = false;

    TvList->OptionsCustomize->ColumnMoving  = false;
    TvList->OptionsCustomize->ColumnSorting = false;

	FListSymb = new TList;

#if 0
	//Col03->DataBinding->ValueTypeClass = __classid(TcxBLOBValueType);
	Col03->PropertiesClass = __classid(TcxImageProperties);
	((TcxImageProperties*)Col03->Properties)->GraphicClassName = "TdxSmartImage";
#endif
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::CommClose()
{
    try
    {
        BtnStopClick(NULL);
        if (m_pEdtDesigner)
        {
            delete m_pEdtDesigner;
            m_pEdtDesigner = NULL;
        }
        ClearSymbloList();

        //CMM_SaveForm(g_sFormsDir, this);
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::FormCreate(TObject *Sender)
{
    m_pEdtDesigner = new TVmsFormDesigner(PnlEditForm);
    FOR_STL(TCDSFontColor*, pObj, CDSFontManager->FColors)
    {
        m_pEdtDesigner->InitFontColor(pObj->VMS_FONT_COLR_CD, (TColor)pObj->VMS_FONT_COLR_VAL);
    }
}
//---------------------------------------------------------------------------

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

    FormInit();

    PnlEdtBack->Width = FVmsWidth+4;
    PnlEdtBack->Height= FVmsHeight+4;

    LoadStreamInfo();

    TmrShow->Enabled = true;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::FormInit()
{
    //TvObjList->OptionsView->NoDataToDisplayInfoText = "<등록되어 있는 객체 정보가 없습니다>";

    m_pEdtDesigner->ApplicationHandle = (long)Handle;

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

void __fastcall TVMSM630M::ClearSymbloList()
{
	for(int ii = 0; ii < FListSymb->Count; ii++)
	{
		Graphics::TBitmap *bitmap = (Graphics::TBitmap *)FListSymb->Items[ii];
		delete bitmap;
	}
	FListSymb->Clear();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::LoadStreamInfo()
{
    CMM_ClearGridTableView(TvList);

    String sQry;
    TADOQuery *pADO = NULL;

    sQry = "SELECT *                \r\n"
           "  FROM VW_STREAM_URL    \r\n";

    //ForceDirectories(g_sVideoDir.c_str());

    String sFileName = "";
    try
    {
        int nRow;
        TcxDataController *pGDC = TvList->DataController;
        TvList->BeginUpdate();
        try
        {
            pADO = new TADOQuery(NULL);
			pADO->Close();
            pADO->Connection = ITSDb_GetConnection();

            ITSDb_SQLText(pADO, sQry);
            ITSDb_SQLOpen(pADO);

            for( ; !pADO->Eof; pADO->Next())
            {
                nRow = pGDC->AppendRecord();

                String sUrl = pADO->FieldByName("URL")->AsString;
                pGDC->Values[nRow][Col00->Index] = pADO->FieldByName("URL_NMBR")->AsString;
                pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("URL_ID")->AsString;
                pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("URL_NAME")->AsString;
                pGDC->Values[nRow][Col03->Index] = sUrl;
                pGDC->Values[nRow][Col04->Index] = pADO->FieldByName("URL_TYPE")->AsVariant;

                if (sUrl == FStreamAddr)
                {
                    FPlayerFile = sUrl;
                }
            }
        }
        catch(EDatabaseError &E)
        {
            DBERRORMSG("TVMSM630M::LoadStreamInfo", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &e)
        {
            DBERRORMSG("TVMSM630M::LoadStreamInfo", String(e.ClassName()), e.Message, sQry);
            throw Exception(String(e.ClassName()) + e.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
        TvList->EndUpdate();
    }

    BtnPlay->Enabled = false;
    BtnStop->Enabled = false;
    BtnPause->Enabled = false;
    if (FPlayerFile != "")
    {
        BtnPlay->Enabled = true;
    }
    EdSymbLibNmbr->Text = FSymbLibNmbr;
    EdStreamAddr->Text  = FStreamAddr;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::TmrShowTimer(TObject *Sender)
{
    TmrShow->Enabled = false;
    BtnSearchClick(NULL);
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::BtnSearchClick(TObject *Sender)
{
    RefreshData();

    EdFocus->SetFocus();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::RefreshData()
{
    // 검색조건에 의한 링크 데이터 조회
    FormClear();

    m_pEdtDesigner->Clear();
    m_pEdtDesigner->SizeType = FVmsTypeCd;
    m_pEdtDesigner->SetSize(FVmsWidth, FVmsHeight);
    m_pEdtDesigner->SetPos(0, 0);
    m_pEdtDesigner->BkColorCode = FFormColor;

    m_pEdtDesigner->EditMode = true;
    m_pEdtDesigner->Show();

    InitObjectList();

    LoadFormObjectInfo(FFormId, m_pEdtDesigner);

    DispObjectListData();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::InitObjectList()
{
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::DispObjectListData()
{
    TVmsFormObject *pObj;
    int nObjCnt = m_pEdtDesigner->GetObjectCount();
    for(int ii = 0; ii < nObjCnt; ii++)
    {
        pObj = m_pEdtDesigner->GetObject(ii);
        if (pObj)
        {
            switch(pObj->ObjType.ToIntDef(0))
            {
            case 200: //동영상 기본이미지
                EdSymbLibNmbr->Text = pObj->ImageId;
                break;
            case 201: //@동영상이름
                EdStreamAddr->Text = pObj->Text;
                break;
            }
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::BtnClosexClick(TObject *Sender)
{
    FSelected = false;
    Close();
}
//---------------------------------------------------------------------------

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

void __fastcall TVMSM630M::LoadFormObjectInfo(String AFormId, TVmsFormDesigner *ADesigner)
{
    ADesigner->Clear();

    String     sQry;
    TADOQuery *pADO = NULL;

    sQry = "SELECT A.*,                                       \r\n"
           "       C.VMS_FONT_NAME_NM,                        \r\n"
           "       B.IMAG_DATA    AS SYMB_IMG,                \r\n"
           "       B.SYMB_EXPL    AS SYMB_IMG_NM,             \r\n"
           "       B.SYMB_FILE_NM AS SYMB_FILE_NM             \r\n"
           "  FROM TB_VMS_FORM_OBJECT  A,                     \r\n"
           "       TB_VMS_SYMB_LIB     B,                     \r\n"
           "       TB_VMS_FONT_NAME    C,                     \r\n"
           "       TB_VMS_FORM         D                      \r\n"
           " WHERE D.VMS_FORM_ID      = :p01                  \r\n"
           "   AND D.VMS_FORM_ID      = A.VMS_FORM_ID         \r\n"
           "   AND B.SYMBLIB_NMBR     = :p02                  \r\n"
           "   AND A.VMS_FONT_NAME_CD = C.VMS_FONT_NAME_CD(+) \r\n"
           " ORDER BY A.FORM_OBJECT_ID ASC                    \r\n";

    try
    {
        try
        {
            pADO = new TADOQuery(NULL);
			pADO->Close();
            pADO->Connection = ITSDb_GetConnection();

            ITSDb_SQLText(pADO, sQry);
            ITSDb_SQLBind(pADO, "p01", AFormId);
            ITSDb_SQLBind(pADO, "p02", FSymbLibNmbr);
            ITSDb_SQLOpen(pADO);

            int    nDrawType;
            String sObjKind;
            for( ; !pADO->Eof; pADO->Next())
            {
                int nFormId = pADO->FieldByName("VMS_FORM_ID")->AsInteger;
                int nObjId  = pADO->FieldByName("FORM_OBJECT_ID")->AsInteger;

                int nObjType = pADO->FieldByName("VMS_FORM_OBJECT_TYPE_CD")->AsInteger;
                if (nObjType ==   1 || //심볼
                    nObjType ==   2 || //이미지
                    nObjType ==   3 || //배경이미지
                    nObjType ==  17 || //@소통정보이미지 (1열)
                    nObjType ==  27 || //@소통정보이미지2(2열)
                    nObjType ==  37 || //@소통정보이미지3(3열)
                    nObjType ==  47 || //소통이미지4
                    nObjType == 200 || //동영상
                    nObjType == 300 || //스트리밍영상
                    nObjType == 406 || //@통합대기등급 이미지
                    nObjType == 407 || //@미세먼지등급 이미지
                    nObjType == 408 || //@초미세먼지등급 이미지
                    nObjType == 413    //@오존등급이미지
                    )
                {
                    sObjKind  = OBJKIND_IMAGEID;    //Image Id
                    nDrawType = 1;  //이미지그리기
                }
                else
                {
                    sObjKind  = OBJKIND_TEXT;  //문자열
                    nDrawType = 0;  //문자열그리기
                }

                //실재 맵핑된 구간의 정보를 표출하도록 한다.

                int    nBlinking = pADO->FieldByName("VMS_DSPL_BLINKING")->AsInteger;
                int    nPosX     = pADO->FieldByName("VMS_DSPL_XCRDN")->AsInteger;
                int    nPosY     = pADO->FieldByName("VMS_DSPL_YCRDN")->AsInteger;

                TVmsFormObject *pObj = ADesigner->AddObject((VmsObjectDrawType)nDrawType);
                if (!pObj) continue;

                pObj->Text = pADO->FieldByName("SYMB_IMG_NM")->AsString.Trim();
                if (FStreamAddr == "") pObj->RunText = pObj->Text;
                else                   pObj->RunText = FStreamAddr;    //pObj->Text;

                pObj->EditMode    = false;
                pObj->ObjSeq      = nObjId;
                pObj->ObjId       = nObjId;
                pObj->ObjKind     = sObjKind;
                pObj->Tag         = pADO->FieldByName("VMS_IFSC_ID")->AsString;
                pObj->ObjType     = pADO->FieldByName("VMS_FORM_OBJECT_TYPE_CD")->AsString;
                pObj->ObjSize     = pADO->FieldByName("VMS_DSPL_SIZE")->AsInteger;
                pObj->BkColorCode = pADO->FieldByName("VMS_DSPL_BKCOLOR")->AsString;
                pObj->Blink       = nBlinking == 1 ? true : false;
                pObj->ImageId     = pADO->FieldByName("SYMBLIB_NMBR")->AsString;

                pObj->SetPos(nPosX, nPosY);
                if (pObj->ObjKind == OBJKIND_TEXT)    // 문자열
                {
                    int nFontBold       = pADO->FieldByName("VMS_FONT_BOLD")->AsInteger;

                    pObj->Text          = pADO->FieldByName("SYMB_FILE_NM")->AsString;
                    pObj->FontName      = pADO->FieldByName("VMS_FONT_NAME_NM")->AsString;
                    pObj->FontNameCode  = pADO->FieldByName("VMS_FONT_NAME_CD")->AsString;
                    pObj->FontColorCode = pADO->FieldByName("VMS_FONT_COLR_CD")->AsString;
                    pObj->FontSize      = pADO->FieldByName("VMS_FONT_SIZE")->AsInteger;
                    pObj->FontBold      = nFontBold == 1 ? true : false;
                    pObj->TextAlign     = pADO->FieldByName("VMS_FONT_ALIGN")->AsInteger;
                    pObj->SetSize(pADO->FieldByName("VMS_DSPL_WIDTH")->AsInteger, pADO->FieldByName("VMS_DSPL_HEIGHT")->AsInteger);
                    pObj->SetRuntimeText(pObj->RunText);
                }
                else //if (sObjKind == "1" || sObjKind == "2")    // 이미지(1), 이미지 ID(2)
                {
                    if (pObj->ObjKind == OBJKIND_IMAGEID)
                    {
                        pObj->Text = pADO->FieldByName("SYMBLIB_NMBR")->AsString;
                    }

                    TStream *pStream = NULL;
                    //pStream = pADO->CreateBlobStream(pADO->FieldByName("VMS_DSPL_FIGR"), bmRead);
                    pStream = pADO->CreateBlobStream(pADO->FieldByName("SYMB_IMG"), bmRead);
                    try
                    {
                        if (pStream && pStream->Size > 0)
                        {
                            Graphics::TBitmap *Bitmap = pObj->GetBitmap();
                            pStream->Position = 0;
                            Bitmap->LoadFromStream(pStream);
                            pObj->SetSize(Bitmap->Width, Bitmap->Height);
                            if (FSymbLibNmbr != "200" && FSymbLibNmbr != "300")
                                pObj->SetPos(0, 0);
                        }
                    }
                    __finally
                    {
                        SAFE_DELETE(pStream);
                    }
                }

#if 0
                switch(nObjType)
                {
                case 200: pObj->Text = FSymbLibNmbr; break;
                case 201: pObj->Text = FStreamAddr;  break;
                case 300: pObj->Text = FSymbLibNmbr; break;
                case 301: pObj->Text = FStreamAddr;  break;
                }
#endif
                pObj->Show();
                pObj->BringToFront();

            }
        }
        catch(EDatabaseError &E)
        {
            DBERRORMSG("TVMSM630M::LoadFormObjectInfo", String(E.ClassName()), E.Message, sQry);
            throw Exception(String(E.ClassName()) + E.Message);
        }
        catch(Exception &exception)
        {
            DBERRORMSG("TVMSM630M::LoadFormObjectInfo", String(exception.ClassName()), exception.Message, sQry);
            throw Exception(String(exception.ClassName()) + exception.Message);
        }
    }
    __finally
    {
        if (pADO)
        {
            pADO->Close();
            delete pADO;
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::FormClear()
{
    FSelIdx = -1;

    EdFormId->Clear();
    EdObjId->Clear();

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

void __fastcall TVMSM630M::BtnSaveClick(TObject *Sender)
{
    FSymbLibNmbr = EdSymbLibNmbr->Text;
    FStreamAddr  = EdStreamAddr->Text;

    m_pEdtDesigner->GetVmsFormImage(ImgForm);
    FSelected = true;
    Close();
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::TrackBar1Change(TObject *Sender)
{
    if (!FTrackChanging && !IsMouseDown())
    {
        FFPlayer->Seek(FDuration * FTrackBar->Position / FTrackBar->Max);
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::FFPlayer1FileOpen(TObject *Sender, const __int64 ADuration, int AFrameWidth, int AFrameHeight,
          int &AScreenWidth, int &AScreenHeight)
{
    if (PnlEditForm->Visible) PnlEditForm->Visible = false;

    FDuration = ADuration;
    FLblDuration->Caption = DurationToStr(ADuration);
    FLblCurrPTS->Caption = "N/A";

    // setup track bar
    FTrackBar->Frequency = 5;
    FTrackBar->TickStyle = tsAuto;
    FTrackBar->Max = FTrackBar->Width;
    FTrackBar->SelStart = 0;
    FTrackBar->SelEnd = 0;
    FTrackBar->SliderVisible = ADuration > 0;

    FTrackChanging = true;
    try
    {
        FTrackBar->Position = 0;
    }
    __finally
    {
        FTrackChanging= false;
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::FFPlayer1OpenFailed(TObject *Sender)
{
    String sLastErrMsg = FFPlayer->LastErrMsg;
    FDispArea->Caption = sLastErrMsg;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::FFPlayer1Position(TObject *Sender, const __int64 APTS)
{
    FLblCurrPTS->Caption = DurationToStr(APTS);
    if ((APTS >= 0) && (FDuration > 0))
    {
        FTrackBar->SelEnd = FTrackBar->Max * APTS / FDuration;
        if (FTrackChanging == false && (IsMouseDown() == false ||  FTrackBar->Focused() == false))
        {
            FTrackChanging = true;
            try
            {
                FTrackBar->Position = FTrackBar->Max * APTS / FDuration;
            }
            __finally
            {
                FTrackChanging = false;
            }
        }
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::FFPlayer1State(TObject *Sender, TPlayState APlayState)
{
    switch(APlayState)
    {
    case Ffbasecomponent::psPlay:
    case Ffbasecomponent::psResume:
        break;
    case Ffbasecomponent::psPause:
    case Ffbasecomponent::psStep:
        break;
    case Ffbasecomponent::psStop:
        if (FFPlayer->ScreenHandle != NULL)
        {
            PostMessage(FFPlayer->ScreenHandle, CM_INVALIDATE, 0, 0);
            UpdateWindow(FFPlayer->ScreenHandle);
        }
        break;
    case Ffbasecomponent::psEnd:
        {
            FFPlayer->Stop(true);
            if (PnlEditForm->Visible == false) PnlEditForm->Visible = true;
            //FFPlayer[nTag]->Seek((__int64)0, TSeekFlags()<<sfBackward);
        }
        break;
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::BtnPlayClick(TObject *Sender)
{
    BtnPlay->Enabled = false;

    Application->ProcessMessages();
    try
    {
        if (FPlayerFile != "")
        {
            if (FFPlayer->ScreenHandle != NULL)
            {
                FFPlayer->Stop(true);
                PostMessage(FFPlayer->ScreenHandle, CM_INVALIDATE, 0, 0);
                UpdateWindow(FFPlayer->ScreenHandle);
            }
        }

        FFPlayer->AspectRatio = ChkFullScreen->Checked ? -1 : 0;
        FFPlayer->TryOpen(FPlayerFile, FDispArea->Handle);

Application->ProcessMessages();
    }
    catch(Exception &e)
    {
    }

    //CxList->Enabled = false;
    BtnStop->Enabled = true;
    BtnPause->Enabled = true;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::BtnStopClick(TObject *Sender)
{
    BtnStop->Enabled = false;
    BtnPause->Enabled = false;

    try
    {
        if (FFPlayer->ScreenHandle != NULL)
        {
            FFPlayer->Stop(true);
        }
Application->ProcessMessages();
    }
    catch(Exception &e)
    {
    }

    //CxList->Enabled  = true;
    BtnPlay->Enabled = true;
    if (PnlEditForm->Visible == false) PnlEditForm->Visible = true;
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::BtnPauseClick(TObject *Sender)
{
    try
    {
        if (FFPlayer->ScreenHandle != NULL)
        {
            FFPlayer->TogglePause();
        }
Application->ProcessMessages();
    }
    catch(Exception &e)
    {
    }
}
//---------------------------------------------------------------------------

void __fastcall TVMSM630M::TvListFocusedRecordChanged(TcxCustomGridTableView *Sender, TcxCustomGridRecord *APrevFocusedRecord,
          TcxCustomGridRecord *AFocusedRecord, bool ANewItemRecordFocusingChanged)
{
    if (!AFocusedRecord) return;

	int nRow = TvList->DataController->FocusedRecordIndex;
	if( nRow <= -1 )
		return;

    TcxDataController *pGDC = TvList->DataController;

    EdSymbLibNmbr->Text = VarToStr(pGDC->Values[nRow][Col00->Index]);
    EdStreamAddr->Text  = VarToStr(pGDC->Values[nRow][Col03->Index]);

    if (BtnStop->Enabled)
        BtnStop->Click();

    FPlayerFile = EdStreamAddr->Text;
    BtnPlay->Enabled = false;
    BtnStop->Enabled = false;
    BtnPause->Enabled = false;
    if (FPlayerFile != "")
    {
        BtnPlay->Enabled = true;
    }

    //CxList->Enabled  = false;
    BtnPlay->Enabled = true;
    BtnStop->Enabled = false;
    BtnPause->Enabled = false;

    TVmsFormObject *pObj;
    int nObjCnt = m_pEdtDesigner->GetObjectCount();
    for(int ii = 0; ii < nObjCnt; ii++)
    {
        pObj = m_pEdtDesigner->GetObject(ii);
        if (!pObj) continue;

        int nObjType = pObj->ObjType.ToIntDef(0);
        switch(nObjType)
        {
        case 200: case 300:
            {
                if (nRow < FListSymb->Count)
                {
                    Graphics::TBitmap *bitmap = (Graphics::TBitmap*)FListSymb->Items[nRow];
                    pObj->SetBitmap(bitmap);
                    pObj->SetPos(0, 0);
                }
            }
            break;
        case 201: case 301:
            pObj->RunText = VarToStr(pGDC->Values[nRow][Col03->Index]);
            pObj->SetRuntimeText(pObj->RunText);
            break;
        }
    }
}
//---------------------------------------------------------------------------

