// ActivitySynchInfoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AG_MDA.h"
#include "ActivitySynchInfoDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// ActivitySynchInfoDlg dialog


ActivitySynchInfoDlg::ActivitySynchInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(ActivitySynchInfoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(ActivitySynchInfoDlg)
	m_Name = _T("");
	m_SynchName = _T("");
	m_SynchType = _T("");
	m_ID = 0;
	//}}AFX_DATA_INIT
}


void ActivitySynchInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(ActivitySynchInfoDlg)
	DDX_Control(pDX, IDC_LIST_CONTROLFLOWS, m_ListControlFlow);
	DDX_Control(pDX, IDC_COMBO_SYNCH_VISIBILITY, m_ComboSynchVisibility);
	DDX_Text(pDX, IDC_EDIT_NAME, m_Name);
	DDX_Text(pDX, IDC_EDIT_SYNCH_NAME, m_SynchName);
	DDX_Text(pDX, IDC_EDIT_SYNCH_TYPE, m_SynchType);
	DDX_Text(pDX, IDC_EDIT_ID, m_ID);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(ActivitySynchInfoDlg, CDialog)
	//{{AFX_MSG_MAP(ActivitySynchInfoDlg)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST_CONTROLFLOWS, OnDblclkListControlflows)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ActivitySynchInfoDlg message handlers

void ActivitySynchInfoDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData( );
	switch( m_ComboSynchVisibility.GetCurSel() )
	{
	case 0:
		m_SynchVisibility = VISIBILITY_PUBLIC;
		break;
	case 1:
		m_SynchVisibility = VISIBILITY_PRIVATE;
		break;
	case 2:
		m_SynchVisibility = VISIBILITY_PROTECTED;
		break;
	default:
		m_SynchVisibility = VISIBILITY_PACKAGE;
		break;
	};
	CDialog::OnOK();
}

BOOL ActivitySynchInfoDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_ComboSynchVisibility.InsertString( 0 , "PUBLIC" );
	m_ComboSynchVisibility.InsertString( 1 , "PRIVATE" );
	m_ComboSynchVisibility.InsertString( 2 , "PROTECTED" );
	m_ComboSynchVisibility.InsertString( 3 , "PACKAGE" );
	switch( m_SynchVisibility )
	{
	case VISIBILITY_PUBLIC:
		m_ComboSynchVisibility.SetCurSel( 0 );
		break;
	case VISIBILITY_PRIVATE:
		m_ComboSynchVisibility.SetCurSel( 1 );
		break;
	case VISIBILITY_PROTECTED:
		m_ComboSynchVisibility.SetCurSel( 2 );
		break;
	default:
		m_ComboSynchVisibility.SetCurSel( 3 );

	}
	m_ListControlFlow.SetExtendedStyle( 33 );
	m_ListControlFlow.InsertColumn( 0 , "Name" , LVCFMT_LEFT , 100 );
	m_ListControlFlow.InsertColumn( 1 , "Type" , LVCFMT_LEFT , 100 );

	for( int i = 0 ; i < m_MarkControlFlows.GetSize() ; i ++ )
	{
		MarkControlFlow mcf = m_MarkControlFlows.GetAt( i );
		m_ListControlFlow.InsertItem( i , mcf.m_Name );
		m_ListControlFlow.SetItemText( i , 1 ,mcf.m_Type );
	}
	//m_ListControlFlow.InsertColumn( 2 , "" , LVCFMT_LEFT , 100 );
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void ActivitySynchInfoDlg::OnDblclkListControlflows(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	int iSel = m_ListControlFlow.GetSelectionMark();
	if( iSel >= 0 )
	{
		ControlFlowInfoDlg dlg;
		MarkControlFlow mcf = m_MarkControlFlows.GetAt( iSel );
		dlg.m_Name = mcf.m_Name;
		dlg.m_Type = mcf.m_Type;
		if( dlg.DoModal() == IDOK )
		{
			mcf.m_Name = dlg.m_Name;
			mcf.m_Type = dlg.m_Type;
			m_MarkControlFlows.SetAt( iSel , mcf );
			m_ListControlFlow.SetItemText( iSel , 0 , mcf.m_Name );
			m_ListControlFlow.SetItemText( iSel , 1 , mcf.m_Type );
		}
	}
	*pResult = 0;
}
