// DialogTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DialogTest.h"
#include "DialogTestDlg.h"
#include "ExtDataModel.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialogTestDlg dialog

CDialogTestDlg::CDialogTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogTestDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	m_pDataModel = NULL;
}

void CDialogTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogTestDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDialogTestDlg, CDialog)
	//{{AFX_MSG_MAP(CDialogTestDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_DESTROY()
	ON_COMMAND(ID_DRAW_LINE, OnDrawLine)
	ON_UPDATE_COMMAND_UI(ID_DRAW_LINE, OnUpdateDrawLine)
	ON_WM_INITMENUPOPUP()
	ON_COMMAND(ID_DRAW_SELECT, OnDrawSelect)
	ON_UPDATE_COMMAND_UI(ID_DRAW_SELECT, OnUpdateDrawSelect)
	ON_COMMAND(ID_DRAW_RECTANGLE, OnDrawRectangle)
	ON_UPDATE_COMMAND_UI(ID_DRAW_RECTANGLE, OnUpdateDrawRectangle)
	ON_COMMAND(ID_DRAW_ELLIPSE, OnDrawEllipse)
	ON_UPDATE_COMMAND_UI(ID_DRAW_ELLIPSE, OnUpdateDrawEllipse)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileOpen)
	ON_COMMAND(ID_FILE_SAVE, OnFileSave)
	ON_COMMAND(ID_PAGE_SETUP, OnPageSetup)
	ON_UPDATE_COMMAND_UI(ID_PAGE_SETUP, OnUpdatePageSetup)
	ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialogTestDlg message handlers

CFOLinkShape *CDialogTestDlg::AddLinkShape(CFOListPortShape *pStart,CFOListPortShape *pEnd)
{
	CFOPExtCornerLinkShape* pLinkComp = new CFOPExtCornerLinkShape;
	pLinkComp->AddRef();
	CPoint ptPoints[2];
	ptPoints[0] = pStart->GetLinkPoint();
	ptPoints[1] = pEnd->GetLinkPoint();
	pLinkComp->Create(ptPoints,2);
	
	pLinkComp->SetFromPort(pStart);
	pLinkComp->SetToPort(pEnd);
	
	pLinkComp->SetLineWidth(4);
	pLinkComp->SetShadow(FALSE);
	
	pStart->AddLinkShape(pLinkComp);
	pEnd->AddLinkShape(pLinkComp);
	
	// Set arrow type.
	int nType = 3;
	pLinkComp->SetEndArrowType(nType);
	m_pDataModel->AddChildAtTail(pLinkComp);
	pLinkComp->UpdateComp();
	pLinkComp->RelayoutPoints();
	pLinkComp->Release();
	
	return pLinkComp;
}

BOOL CDialogTestDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	m_pDataModel = new CExtDataModel;

	CRect theRect;
	GetDlgItem(IDC_CANVAS)->GetWindowRect( &theRect );
	ScreenToClient(&theRect);

//	m_wndClock.Create(WS_CHILD|WS_VISIBLE|WS_BORDER,theRect, this,1001);
	DWORD dwStyle = WS_CHILD|WS_VISIBLE|WS_BORDER|WS_TABSTOP;

	m_wndCanvas.SetCurrentModel(m_pDataModel);
	m_wndCanvas.Create(dwStyle, theRect,this,IDC_CANVAS);
	CRect rcClient;
	m_wndCanvas.GetClientRect(&rcClient);

	m_wndCanvas.SetVirtualOrigin(0, 0);
	m_wndCanvas.SetVirtualSize(1000, 1000);

	m_pDataModel->SetBorderShow(FALSE);
	m_pDataModel->ShowMargin(FALSE);
	//	m_pDataModel->SetPageBkColor(RGB(255,255,255));
	m_pDataModel->SetPageBkColor(RGB(255,255,255));
	m_pDataModel->SetDesignMode(FALSE);
//	m_wndCanvas.ShowRulers(FALSE);

	CPoint ptStart = CPoint(100,100);
	CSize sz = CSize(160,150);

	CFOListCtrlShape *pNode1 = NULL;
	CFOListCtrlShape *pNode2 = NULL;
	CFOListCtrlShape *pNode3 = NULL;

	CFOListCtrlShape *pNode4 = NULL;
	CFOListCtrlShape *pNode5 = NULL;
	CFOListCtrlShape *pNode6 = NULL;

//#1
	CRect rcPos = CRect(ptStart,sz);
	CFOListCtrlShape *pNode = new CFOListCtrlShape;
	pNode->AddRef();
	pNode->Create(rcPos,_T("Customers"));
	m_pDataModel->AddChildAtTail(pNode);

	int nIdx = 1000;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("CustomerID")); // 1000

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("Company"));

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("Address"));

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("Phone"));

	nIdx ++;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("ShipToID")); // 1004

	pNode->UpdateComp();
	pNode->Release();

	pNode1 = pNode;

//#2
	sz = CSize(160,130);
	rcPos = CRect(ptStart,sz);
	rcPos.OffsetRect(CPoint(sz.cx + 40,sz.cy));
	pNode = new CFOListCtrlShape;
	pNode->AddRef();
	pNode->Create(rcPos,_T("Sales"));
	m_pDataModel->AddChildAtTail(pNode);

	nIdx = 1000;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("SalesID")); // 1000

	nIdx ++;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("OrderID")); // 1001

	nIdx ++;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("CustomerID")); // 1002

	pNode->UpdateComp();
	pNode->Release();

	pNode2 = pNode;

//#3
	sz = CSize(160,130);
	rcPos = CRect(ptStart,sz);
	rcPos.OffsetRect(CPoint(sz.cx *2 + 80,0));
	pNode = new CFOListCtrlShape;
	pNode->AddRef();
	pNode->Create(rcPos,_T("Orders"));
	m_pDataModel->AddChildAtTail(pNode);

	nIdx = 1000;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("OrderID")); // 1000

	nIdx ++;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("CustomerID")); // 1001

	nIdx ++;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("DetailID")); // 1002

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("ShipDate"));

	pNode->UpdateComp();
	pNode->Release();

	pNode3 = pNode;

//#4
	sz = CSize(160,130);
	rcPos = CRect(ptStart,sz);
	rcPos.OffsetRect(CPoint(sz.cx *3 + 160,sz.cy));
	pNode = new CFOListCtrlShape;
	pNode->AddRef();
	pNode->Create(rcPos,_T("Items"));
	m_pDataModel->AddChildAtTail(pNode);

	nIdx = 1000;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("ItemID")); // 1000

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("ProductName"));

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("ProductPrice"));

	pNode->UpdateComp();
	pNode->Release();

	pNode4 = pNode;

//#5
	sz = CSize(160,130);
	rcPos = CRect(ptStart,sz);
	rcPos.OffsetRect(CPoint(0,sz.cy * 2 + 40));
	pNode = new CFOListCtrlShape;
	pNode->AddRef();
	pNode->Create(rcPos,_T("ShipTo"));
	m_pDataModel->AddChildAtTail(pNode);

	nIdx = 1000;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("ShipToID")); // 1000

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("Address"));

	nIdx ++;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("ShipInstID")); // 1002

	pNode->UpdateComp();
	pNode->Release();

	pNode5 = pNode;

//#6
	sz = CSize(160,150);
	rcPos = CRect(ptStart,sz);
	rcPos.OffsetRect(CPoint(sz.cx + 50,sz.cy * 2 + 40));
	pNode = new CFOListCtrlShape;
	pNode->AddRef();
	pNode->Create(rcPos,_T("Details"));
	m_pDataModel->AddChildAtTail(pNode);

	nIdx = 1000;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("DetailID")); // 1000

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("Fields1"));

	nIdx ++;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("ItemID")); // 1002

	nIdx ++;
	pNode->AddNewItem(nIdx,FALSE,FALSE,_T("Fields3"));

	nIdx ++;
	pNode->AddNewItem(nIdx,TRUE,TRUE,_T("OrderID")); // 1004

	pNode->UpdateComp();
	pNode->Release();

	pNode6 = pNode;


	CFOListPortShape *pFrom = NULL;
	CFOListPortShape *pTo = NULL;

	pFrom = pNode1->FindPortFromIndex(1000,TRUE);
	pTo = pNode2->FindPortFromIndex(1002,TRUE);
	AddLinkShape(pFrom,pTo);

	pFrom = pNode1->FindPortFromIndex(1000,FALSE);
	pTo = pNode3->FindPortFromIndex(1001,TRUE);
	AddLinkShape(pFrom,pTo);

	pFrom = pNode2->FindPortFromIndex(1001,FALSE);
	pTo = pNode3->FindPortFromIndex(1000,TRUE);
	AddLinkShape(pFrom,pTo);

	pFrom = pNode1->FindPortFromIndex(1004,FALSE);
	pTo = pNode5->FindPortFromIndex(1000,TRUE);
	AddLinkShape(pFrom,pTo);

	pFrom = pNode3->FindPortFromIndex(1000,FALSE);
	pTo = pNode6->FindPortFromIndex(1004,TRUE);
	AddLinkShape(pFrom,pTo);

	pFrom = pNode4->FindPortFromIndex(1000,TRUE);
	pTo = pNode6->FindPortFromIndex(1002,FALSE);
	AddLinkShape(pFrom,pTo);

	m_wndTool.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_EX_CLIENTEDGE,CRect(0,0,100,100),this,IDC_TOOLBOX);
	
	// Do create toolbox pages.
	DoCreatePages();
	
	GetDlgItem(IDC_TOOLBOX)->GetWindowRect( &theRect );
	ScreenToClient(&theRect);
	
	m_wndTool.SetWindowPos( NULL, theRect.left, theRect.top, theRect.Width(), theRect.Height(),
		SWP_NOZORDER|SWP_NOACTIVATE );

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDialogTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDialogTestDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDialogTestDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CDialogTestDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
	if(m_pDataModel != NULL)
	{
		delete m_pDataModel;
	}

	POSITION pos = m_Shapes.GetHeadPosition();
	while(pos != NULL)
	{
		delete m_Shapes.GetNext(pos);
	}
	m_Shapes.RemoveAll();
}

void CDialogTestDlg::DoCreatePages()
{
	LoadFromFile();	

	if(m_Shapes.GetCount() <= 0)
	{
		CString strNewTitle;
		strNewTitle.LoadString(IDS_FO_NEW_TOOLBOXPAGE);
		m_wndTool.AddPage(strNewTitle);
		m_wndTool.ActivatePage(0);
	}
	else
	{
		POSITION pos = m_Shapes.GetHeadPosition();
		while(pos != NULL)
		{
			CFOListItemObj *pObj = (CFOListItemObj *)m_Shapes.GetNext(pos);
			CString strPathX = AfxGetApp()->m_pszHelpFilePath;
			strPathX = strPathX.Left(strPathX.ReverseFind('\\'));
			CString strOtherFile;
			strOtherFile = strPathX+_T("\\Shapes\\");
			strOtherFile += pObj->strFileName;
			CString strTitle = pObj->strFileName;
			strTitle = strTitle.Left(strTitle.GetLength() -4);
			m_wndTool.AddPage(strTitle);
			m_wndTool.GetToolBoxWnd()->LoadResFile(strOtherFile);
			m_wndTool.GetToolBoxWnd()->GetCurrentPage()->SetObjectCaption(strTitle);

		}
		
		m_wndTool.ActivatePage(0);
	}
}

CFOListItemObj *CDialogTestDlg::FindObjByID(int nIndex)
{
	POSITION pos = m_Shapes.GetHeadPosition();
	while(pos != NULL)
	{
		CFOListItemObj *pObj = (CFOListItemObj *)m_Shapes.GetNext(pos);
		if(pObj->nID == nIndex)
		{
			return pObj;
		}
	}
	return NULL;
}

void CDialogTestDlg::LoadFromFile()
{
	CString strPathX = AfxGetApp()->m_pszHelpFilePath;
	strPathX = strPathX.Left(strPathX.ReverseFind('\\'));
	CString strOtherFile;
	strOtherFile = strPathX+_T("\\Shapes\\index.dat");
	CStdioFile m_File;
	if(m_File.Open(strOtherFile,CFile::modeRead | CFile::typeText))
	{
		CString strTemp;
		int nNumber = 100;
		while (m_File.ReadString(strTemp))
		{
			
			strTemp.TrimLeft();
			strTemp.TrimRight();
			if(!strTemp.IsEmpty())
			{
				CString strTitle;
				CString strFile;
				strTitle = strTemp.Left(strTemp.ReverseFind('#'));
				strFile = strTemp.Right(strTemp.GetLength() - strTitle.GetLength() -1);
				if((!strTitle.IsEmpty()) && (!strFile.IsEmpty()))
				{
					CFOListItemObj *pObj = new CFOListItemObj;
					pObj->strTitle = strTitle;
					pObj->strFileName = strFile;
					pObj->nID = nNumber;
					m_Shapes.AddTail(pObj);
					nNumber ++;
				}
			}	
		}
		m_File.Close();
	}
}

void CDialogTestDlg::OnDrawLine() 
{
	// TODO: Add your command handler code here
	m_wndCanvas.OnFOPFoDrawLine();
}

void CDialogTestDlg::OnUpdateDrawLine(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	m_wndCanvas.OnFOPUpdateFoDrawLine(pCmdUI);
}

void CDialogTestDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
	UNREFERENCED_PARAMETER( nIndex );

	Default( );
	
	if (!bSysMenu)
	{
		ASSERT(pPopupMenu != NULL);
		
		CCmdUI stCmd;        
		stCmd.m_pMenu = pPopupMenu;
		ASSERT(stCmd.m_pOther == NULL);
		
		stCmd.m_nIndexMax = pPopupMenu->GetMenuItemCount( );
		for (stCmd.m_nIndex = 0; stCmd.m_nIndex < stCmd.m_nIndexMax;stCmd.m_nIndex++)
		{
			stCmd.m_nID = pPopupMenu->GetMenuItemID(stCmd.m_nIndex);
			if (stCmd.m_nID == 0)
			{
				continue;
			}
				
			ASSERT(stCmd.m_pOther == NULL);
			ASSERT(stCmd.m_pMenu != NULL);
			if (stCmd.m_nID == (UINT)-1)
			{
				stCmd.m_pSubMenu = pPopupMenu->GetSubMenu(stCmd.m_nIndex);
				if (stCmd.m_pSubMenu == NULL ||
				    (stCmd.m_nID = stCmd.m_pSubMenu->GetMenuItemID(0) ) == 0 ||
				    stCmd.m_nID == (UINT)-1)
				{				    			 
			        continue;
			    }

			    stCmd.DoUpdate(this, FALSE);
			}
			else
			{
				stCmd.m_pSubMenu = NULL;
				stCmd.DoUpdate(this, stCmd.m_nID < 0xF000);
			}
		}
	}

}

void CDialogTestDlg::OnDrawSelect() 
{
	// TODO: Add your command handler code here
	m_wndCanvas.OnFOPFoDrawSelect();
}

void CDialogTestDlg::OnUpdateDrawSelect(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	m_wndCanvas.OnFOPUpdateFoDrawSelect(pCmdUI);
}

void CDialogTestDlg::OnDrawRectangle() 
{
	// TODO: Add your command handler code here
	m_wndCanvas.OnFOPFoDrawRectangle();
}

void CDialogTestDlg::OnUpdateDrawRectangle(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	m_wndCanvas.OnFOPUpdateFoDrawRectangle(pCmdUI);
}

void CDialogTestDlg::OnDrawEllipse() 
{
	// TODO: Add your command handler code here
	m_wndCanvas.OnFOPFoDrawEllipse();
}

void CDialogTestDlg::OnUpdateDrawEllipse(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	m_wndCanvas.OnFOPUpdateFoDrawEllipse(pCmdUI);
}

void CDialogTestDlg::OnFileOpen() 
{
	// TODO: Add your command handler code here
	static CString szFilter = _T("Test Dialog file(*.tdf)|*.tdf|");

	CFileDialog fileDlg(TRUE, _T(".tdf"), "", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter, NULL);

	if (fileDlg.DoModal() != IDOK)
		return;
	
	CString m_lstfilename = fileDlg.GetPathName();
	m_wndCanvas.OpenDocument(m_lstfilename);
}

void CDialogTestDlg::OnUpdateFileOpen(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI;
}

void CDialogTestDlg::OnFileSave() 
{
	// TODO: Add your command handler code here
	static CString szFilter = _T("Test Dialog file(*.tdf)|*.tdf|");

	CFileDialog fileDlg(FALSE, _T(".tdf"), "Test.tdf", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter, NULL);

	if (fileDlg.DoModal() != IDOK)
		return;
	
	CString m_lstfilename = fileDlg.GetPathName();
	
	m_wndCanvas.SaveDocument(m_lstfilename);
}

void CDialogTestDlg::OnPageSetup() 
{
	// TODO: Add your command handler code here
	if(m_wndCanvas.OnFOPPageSetup())
	{
		m_wndCanvas.DoUpdateScrollBars();
	}
	
}

void CDialogTestDlg::OnUpdatePageSetup(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI;
}

void CDialogTestDlg::OnFilePrint() 
{
	// TODO: Add your command handler code here
//	m_wndCanvas.DoPrint();
	if(!m_NewCanvas.m_hWnd)
	{
		m_NewCanvas.SetCurrentModel(m_pDataModel);
		CString strWnd = AfxRegisterWndClass(CS_OWNDC, 0,0,0);
		
		if(!(m_NewCanvas.CreateEx(WS_EX_LEFT, (LPCTSTR)strWnd,
			"UCanCode Canvas",
			WS_VISIBLE|WS_POPUP,
			0,0,0,0,
			NULL,
			NULL
			)))
		{
			return;
		}
		m_NewCanvas.SetVirtualOrigin(0, 0);
		m_NewCanvas.SetVirtualSize(1000, 1000);
		m_NewCanvas.ShowRulers(FALSE);
	}
	else
	{
		m_NewCanvas.ShowWindow(SW_SHOW);
	}

}

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	GetDlgItem(IDC_EDIT1)->SetWindowText(_T("If you want to learn more about E-XD++ Diagrammer Enterprise Edition,Visit:http://www.ucancode.net"));

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
