![]() ![]() |
||
Steps: 1. Load a flow chart file at running time: // Dispatch commands specified on the command line if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) { CString strPathX = AfxGetApp()->m_pszHelpFilePath; strPathX = strPathX.Left(strPathX.ReverseFind('\\')); CString strOtherFile; strOtherFile = strPathX+_T("\\flow.udn"); this->OpenDocumentFile(strOtherFile); } else if (!ProcessShellCommand(cmdInfo)) { return FALSE; } 2. Change the setting of canvas: void CUDesignerView::DoChangeModel(CFODataModel * pModel) { CSize szCanvas = CSize(3000,3000); pModel->SetCanvasSize(szCanvas); } void CUDesignerView::OnInitialUpdate() { SetCurrentModel(GetDocument()->m_pDataModel); CFODrawView::OnInitialUpdate(); GetCurrentModel()->SetLockWithPages(FALSE); GetCurrentModel()->SetGridLineType(GRID_DOT); GetCurrentModel()->SetGridColor(RGB(0,0,0)); CFOFormProperties *pProp = GetCurrentModel()->GetDefaultProperty(); pProp->ShowMargin(FALSE); ShowRulers(FALSE); // GetCurrentModel()->SetAllowHoleLink(FALSE); UpdateScrollBarSize(); } 3. Change the default canvas origin offset with codes: CSize CUDesignerView::GetCanvasOrginOffset() const { // if(m_pCurDataModel == NULL) { return CSize(0,0); } } 4. Drawing shapes on the canvas: void CUDesignerView::OnDrawFlobot() { // TODO: Add your command handler code here if(m_drawshape == FO_COMP_COMPOSITE && m_nCurShapeResID == IDR_FLOBOT) { m_action_state = State_SelectNone; m_drawshape = FO_COMP_NONE; FOSetSystemCursor(IDC_ARROW); return; } StartCustomShapeID(IDR_FLOBOT); AddShapePort(0.5,0.5); } void CUDesignerView::OnUpdateDrawFlobot(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here BOOL bDesign = GetCurrentModel()->IsDesignMode(); pCmdUI->Enable(bDesign); pCmdUI->SetCheck(m_drawshape == FO_COMP_COMPOSITE && m_nCurShapeResID == IDR_FLOBOT); } 5. Animate shapes that choosing: void CUDesignerView::AnimateShapes() { CExtDataModel *pModel = static_cast<CExtDataModel *>(GetCurrentModel()); CFODrawShapeList m_UpdateList; POSITION pos = pModel->m_ShapesList.GetHeadPosition(); CFODrawShape *pShape = NULL; while(pos != NULL) { pShape = (CFODrawShape *)pModel->m_ShapesList.GetNext(pos); BOOL bFlag = m_nTimerCount % 2; pShape->SetVisible(bFlag); if(HAS_BASE(pShape,CFOCompositeShape)) { CFOCompositeShape *pGroup = static_cast<CFOCompositeShape *>(pShape); pGroup->SetGroupVisible(bFlag); } m_UpdateList.AddTail(pShape); } if(m_UpdateList.GetCount() > 0) { UpdateShapes(&m_UpdateList); } } void CUDesignerView::AnimateLinks() { CExtDataModel *pModel = static_cast<CExtDataModel *>(GetCurrentModel()); CFODrawShapeList m_UpdateList; POSITION pos = pModel->m_LinksList.GetHeadPosition(); CFODrawShape *pShape = NULL; while(pos != NULL) { pShape = (CFODrawShape *)pModel->m_LinksList.GetNext(pos); BOOL bFlag = !(m_nTimerCount % 2); pShape->SetVisible(bFlag); m_UpdateList.AddTail(pShape); } if(m_UpdateList.GetCount() > 0) { UpdateShapes(&m_UpdateList); } } void CUDesignerView::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default CExtDataModel *pModel = static_cast<CExtDataModel *>(GetCurrentModel()); if (nIDEvent == COUNT_TIMER) { if (m_nTimerCount > 0) { if (pModel->m_ShapesList.GetCount() > 0) { AnimateShapes(); } if (pModel->m_LinksList.GetCount() > 0) { AnimateLinks(); } m_nTimerCount--; } else { KillTimer(COUNT_TIMER); if(pModel->m_LinksList.GetCount() > 0) { CFODrawShapeList m_UpdateList; POSITION pos = pModel->m_LinksList.GetHeadPosition(); CFODrawShape *pShape = NULL; while(pos != NULL) { pShape = (CFODrawShape *)pModel->m_LinksList.GetNext(pos); pShape->SetVisible(TRUE); m_UpdateList.AddTail(pShape); } pModel->m_LinksList.RemoveAll(); if(m_UpdateList.GetCount() > 0) { UpdateShapes(&m_UpdateList); } } if(pModel->m_ShapesList.GetCount() > 0) { CFODrawShapeList m_UpdateList; POSITION pos = pModel->m_ShapesList.GetHeadPosition(); CFODrawShape *pShape = NULL; while(pos != NULL) { pShape = (CFODrawShape *)pModel->m_ShapesList.GetNext(pos); pShape->SetVisible(TRUE); if(HAS_BASE(pShape,CFOCompositeShape)) { CFOCompositeShape *pGroup = static_cast<CFOCompositeShape *>(pShape); pGroup->SetGroupVisible(TRUE); } m_UpdateList.AddTail(pShape); } pModel->m_ShapesList.RemoveAll(); if(m_UpdateList.GetCount() > 0) { UpdateShapes(&m_UpdateList); } } m_nTimerCount = 0; } } else { CFODrawView::OnTimer(nIDEvent); } } 6. RelationShip between shapes: void CUDesignerView::OnFindAllshapes() { CExtDataModel *pModel = static_cast<CExtDataModel *>(GetCurrentModel()); // TODO: Add your command handler code here if( m_listSelectComp.GetCount() == 1) { CFODrawShape *pShape = GetCurrentSelectShape(); if(HAS_BASE(pShape,CFODrawPortsShape)) { CFODrawPortsShape *pPortsShape = static_cast<CFODrawPortsShape *>(pShape); pPortsShape->GetAllLinkShapes(pModel->m_ShapesList); m_nTimerCount = 10; SetTimer(COUNT_TIMER, 100, NULL); } } } void CUDesignerView::OnUpdateFindAllshapes(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable(m_listSelectComp.GetCount() == 1); } void CUDesignerView::OnFindAllshapesFrom() { // TODO: Add your command handler code here CExtDataModel *pModel = static_cast<CExtDataModel *>(GetCurrentModel()); // TODO: Add your command handler code here if( m_listSelectComp.GetCount() == 1) { CFODrawShape *pShape = GetCurrentSelectShape(); if(HAS_BASE(pShape,CFODrawPortsShape)) { CFODrawPortsShape *pPortsShape = static_cast<CFODrawPortsShape *>(pShape); pPortsShape->GetAllLinkFromShapes(pModel->m_ShapesList); m_nTimerCount = 10; SetTimer(COUNT_TIMER, 100, NULL); } } } void CUDesignerView::OnUpdateFindAllshapesFrom(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable(m_listSelectComp.GetCount() == 1); }
|
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