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

#include <vcl.h>
#include "ITSSkinF.h"
#include "ITSUtilF.h"
#include "ITSDbF.h"
#include "ITS_OPLibF.h"
#include "ITSLangTransF.h"
#pragma hdrstop

#include "PlugInSetChartF.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxButtons"
#pragma link "cxCheckBox"
#pragma link "cxContainer"
#pragma link "cxControls"
#pragma link "cxDropDownEdit"
#pragma link "cxEdit"
#pragma link "cxGraphics"
#pragma link "cxImageComboBox"
#pragma link "cxLabel"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxMaskEdit"
#pragma link "cxTextEdit"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinsCore"
#pragma link "dxSkinMcSkin"
#pragma resource "*.dfm"
//TPlugInSetChart *PlugInSetChart = NULL;
//---------------------------------------------------------------------------
__fastcall TPlugInSetChart::TPlugInSetChart(TComponent* Owner)
	: TForm(Owner)
{
    LangTrans->Translate(this, ITSDb_GetConnection());
    ITSSkin_Load(this);
    LoadLocalSkin();
}
//---------------------------------------------------------------------------

/*
 * 공통으로 처리되지 않는 스킨을 변경한다.
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TPlugInSetChart::LoadLocalSkin()
{
    //BtnSave->Caption = "Apply";
    //BtnSave->Hint = "Apply a graph display entries.";
}
//---------------------------------------------------------------------------

/*
 * form을 보여줄때 호출되는 event 메서드이다.
 *  arguments
 *      Sender : event handler 객체
 *  return
 *      void
 */
void __fastcall TPlugInSetChart::FormShow(TObject *Sender)
{
    // form 초기화
    FormInit();
}
//---------------------------------------------------------------------------

/*
 * form 초기화
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TPlugInSetChart::FormInit()
{
    TmrRefresh->Enabled = true;
    m_bUpdate = false;
}
//---------------------------------------------------------------------------

/*
 * Form을 닫을때 호출되는 event 메서드
 *  arguments
 *      Sender : event handler 객체
 *      Action : TCloseAction 객체
 *  return
 *      void
 */
void __fastcall TPlugInSetChart::FormClose(TObject *Sender, TCloseAction &Action)
{
    CommClose();
    //PlugInSetChart = NULL;
    //Action = caFree;
}
//---------------------------------------------------------------------------

/*
 * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
 * Form과 DataModule class를 delete시킨다.
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TPlugInSetChart::CommClose()
{
    //공통코드를 사용한 경우 반드시 delete해야한다.
    try
    {
    }
    catch(...)
    {
    }
}
//---------------------------------------------------------------------------

/*
 * 화면이 로딩된 후 리스트 목록을 조회하도록 한다.
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TPlugInSetChart::TmrRefreshTimer(TObject *Sender)
{
	TmrRefresh->Enabled = false;
    RefreshData();
}
//---------------------------------------------------------------------------

/*
 * Refresh Data Event Function
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TPlugInSetChart::RefreshData()
{
    CbChartKind->ItemIndex = (int)m_nSrsType;
}
//---------------------------------------------------------------------------

/*
 * 서버(장치) 저장
 *  arguments
 *
 *  return
 *      void
 */
void __fastcall TPlugInSetChart::BtnSaveClick(TObject *Sender)
{
    // save
    m_nSrsType = CbChartKind->ItemIndex;

    ModalResult = mrOk;
}
//---------------------------------------------------------------------------

void __fastcall TPlugInSetChart::PnlItemColorClick(TObject *Sender)
{
    ColorDialog->Color = ((TPanel*)Sender)->Color;
    if (!ColorDialog->Execute()) return;

    ((TPanel*)Sender)->Color = ColorDialog->Color;
}
//---------------------------------------------------------------------------

