![]() ![]() |
||
Steps: 1. Change the canvas setting: void CTestTimerView::DoChangeModel(CFODataModel * pModel) { CSize szCanvas = CSize(1000,1000); pModel->SetCanvasSize(szCanvas); pModel->ShowGrid(FALSE); pModel->SetBorderShow(FALSE); pModel->SetPageBkColor(RGB(255,255,255)); pModel->ShowMargin(FALSE); } 2. Initial the canvas void CTestTimerView::OnInitialUpdate() { SetCurrentModel(GetDocument()->m_pDataModel); CFODrawView::OnInitialUpdate(); DrawMyShape(); if(GetCurrentModel()->GetShapes()->GetCount() > 0) { MyHandleTool *myTool = new MyHandleTool(this); int xy = 0; for (xy = 0; xy < GetCurrentModel()->GetShapes()->GetCount(); xy ++ ) { CFODrawShape *pObj = (CFODrawShape *)GetCurrentModel()->GetShapes()->GetObject(xy); myTool->AddShape(pObj); } AddPlugin(myTool); myTool->Start(); } bStarted = TRUE; } 3. Drawing, play and stop timer: void CTestTimerView::CreateNode(CRect rc) { CString strPathX = AfxGetApp()->m_pszHelpFilePath; strPathX = strPathX.Left(strPathX.ReverseFind('\\')); CString strOtherFile; strOtherFile = strPathX+_T("\\test.wmf"); CMyShape *pShape = (CMyShape *)CreateShape(strOtherFile, rc); pShape->m_iNetGroupId = 1; InvalidateShape(pShape); } CMyShape *CTestTimerView::CreateShape(CString strFile, CRect rcCreate) { CRect rc(rcCreate); CMyShape *pShape = NULL; pShape = new CMyShape; pShape->Create(rc,""); pShape->LoadImage(strFile); pShape->PositionShape(rcCreate); CString strCaption = GetCurrentModel()->GetUniqueCaption(pShape->GetType()); CString strName = GetCurrentModel()->GetUniqueName(pShape->GetType()); pShape->SetObjectCaption(strCaption); pShape->SetObjectName(strName); pShape->SetCopyProtect(TRUE); pShape->SetDeleteProtect(TRUE); GetCurrentModel()->GetShapes()->AddTail(pShape); return pShape; } #define NODEWIDTH 199 #define NODEHEIGHT 105 #define SPACEHEIGHT 50 #define SPACEWIDTH 50 #define YTOPPOINT 50 #define TEXTHEIGHT 25 void CTestTimerView::DrawMyShape() { int nNodeHeight = NODEHEIGHT; int nNodeWidth = NODEWIDTH; int nSpaceHeight = SPACEHEIGHT; int nSpaceWidth = SPACEWIDTH; CRect rcFirst; CRect rcCur; int nCurRow = 0; int nCurCol = 0; rcFirst = CRect(CPoint(nSpaceWidth, YTOPPOINT), CSize(nNodeWidth, nNodeHeight)); int i = 0; for(i=0; i<5; i++) { rcCur = rcFirst; rcCur.OffsetRect(CSize((nNodeWidth+nSpaceWidth)*nCurCol, (nNodeHeight+nSpaceHeight)*nCurRow)); CreateNode(rcCur); if(++nCurCol >= 5) { nCurCol = 0; nCurRow++; } } rcFirst.OffsetRect(CPoint(0,nNodeHeight *2)); for(i=0; i<5; i++) { rcCur = rcFirst; rcCur.OffsetRect(CSize((nNodeWidth+nSpaceWidth)*nCurCol, (nNodeHeight+nSpaceHeight)*nCurRow)); CreateNode(rcCur); if(++nCurCol >= 5) { nCurCol = 0; nCurRow++; } } rcFirst.OffsetRect(CPoint(0,nNodeHeight *2)); for(i=0; i<5; i++) { rcCur = rcFirst; rcCur.OffsetRect(CSize((nNodeWidth+nSpaceWidth)*nCurCol, (nNodeHeight+nSpaceHeight)*nCurRow)); CreateNode(rcCur); if(++nCurCol >= 5) { nCurCol = 0; nCurRow++; } } ClearSelection(); } void CTestTimerView::OnPlay() { // TODO: Add your command handler code here if(!bStarted) { POSITION posevent = m_pluginList.GetHeadPosition(); while (posevent) { MyHandleTool* pEvent = (MyHandleTool*) m_pluginList.GetNext(posevent); pEvent->Start(); } bStarted = TRUE; } } void CTestTimerView::OnUpdatePlay(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable(!bStarted); } void CTestTimerView::OnStop() { // TODO: Add your command handler code here if(bStarted) { POSITION posevent = m_pluginList.GetHeadPosition(); while (posevent) { MyHandleTool* pEvent = (MyHandleTool*) m_pluginList.GetNext(posevent); pEvent->Stop(); } bStarted = FALSE; } } void CTestTimerView::OnUpdateStop(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable(bStarted); } |
Copyright ?1998-2007 UCanCode.Net Software, all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.
Please direct your questions or comments to webmaster@ucancode.com