bool CDocMgr::ReadXmlFile(string& szFileName) { //读取Xml文件,并遍历 XMLRdr xml(szFileName); //string str(m_DocLst.GetBuffer(1)); //m_DocLst.ReleaseBuffer(); //xml.ProcessString(str); XMLNode *root = xml.GetRootNode(); if(root == NULL) return false; long cnt = root->GetChildNodeCnt(); for(int i=0;i<cnt;i++) { XMLNode *chdNode = root->GetNextChild(); if(chdNode == NULL) return false; string sType = chdNode->GetElementValue("Type"); string sAlias = chdNode->GetElementValue("Alias"); string sTitle = chdNode->GetElementValue("Title"); string sEncode = chdNode->GetElementValue("Encode"); string sPage = chdNode->GetElementValue("iPage"); string sSize = chdNode->GetElementValue("Size"); //string sUpdated = chdNode->GetElementValue("Updated"); string sEdition = chdNode->GetElementValue("Edition"); string sURL = chdNode->GetElementValue("URL"); string sfullURL = chdNode->GetElementValue("fullURL"); string sProcessType = chdNode->GetElementValue("ProcessType"); string sIsZhengWen = chdNode->GetElementValue("IsZhengWen"); //string sMossSiteURL = chdNode->GetElementValue("MossSiteURL"); string sFolderName = chdNode->GetElementValue("FolderName"); string sFileName = chdNode->GetElementValue("FileName"); string sIsCopy = chdNode->GetElementValue("IsCopy"); string sWorkItemID = chdNode->GetElementValue("WorkItemID"); CString csType(sType.c_str()); CString csAlias(sAlias.c_str()); CString csTitle(sTitle.c_str()); CString csEncode(sEncode.c_str()); CString csPage(sPage.c_str()); CString csSize(sSize.c_str()); //CString csUpdated(sUpdated.c_str()); CString csEdition(sEdition.c_str()); CString csURL(sURL.c_str()); CString csfullURL(sfullURL.c_str()); CString csProcessType(sProcessType.c_str()); CString csIsZhengWen(sIsZhengWen.c_str()); //CString csMossSiteURL(sMossSiteURL.c_str()); CString csFolderName(sFolderName.c_str()); CString csFileName(sFileName.c_str()); CString csIsCopy(sIsCopy.c_str()); CString csWorkItemID(sWorkItemID.c_str()); InsertDocItem(csAlias, csEncode, csPage, csSize, csType, csTitle, csEdition, csURL, csfullURL,csProcessType, csIsZhengWen, csFolderName, csFileName, csIsCopy, csWorkItemID); } return true; }
void CDrawPictureElementCmd::Click() { ICommand::Click(); CString csFilter = "BMP(*.bmp)|*.bmp|TIFF(*.tif)|*.tif|TIFF(*.tiff)|*.tiff|JPEG(*.jpg)|*.jpg||"; CString csFileName(_T("*.BMP")); CFileDialog dlg(TRUE, "BMP", csFileName, OFN_HIDEREADONLY, csFilter); if( IDOK == dlg.DoModal() ) { CString csPath = dlg.GetPathName(); CString csDataSourceTmp=csPath; CString csThemeName = csPath.Mid (csPath.ReverseFind ('\\') + 1); csThemeName =csThemeName.Left(csThemeName.ReverseFind('.')); Geodatabase::IWorkspace *pWorkspace =CRasterWSFactory::GetInstance()->OpenFromFile(csDataSourceTmp); if(!pWorkspace) { MessageBox(NULL,"打开数据失败!","提示",MB_OK); return; } Geodatabase::IRasterDatasetPtr pRaster =pWorkspace->OpenRasterDataset(csDataSourceTmp); if(!pRaster) { MessageBox(NULL,"打开数据失败!","提示",MB_OK); return; } Carto::CRasterLayerPtr pLayer; pLayer = Carto::ILayer::CreateLayer(pRaster); pLayer->SetName(std::string(csThemeName)); //获取活动制图控件 if(!m_pMapCtrl) return; Carto::CMapPtr pMap = m_pMapCtrl->GetMap(); long picWidth, picHeight; pRaster->GetSize(&picWidth, &picHeight); RECT viewBound = pMap->GetDisplay()->GetDisplayTransformation().GetViewBound().GetRect(); DIS_RECT picBound; picBound.left = ((double)viewBound.left+(double)viewBound.right)/2.0 - (double)picWidth/2.0; picBound.right = picBound.left + picWidth; picBound.top = ((double)viewBound.top+(double)viewBound.bottom)/2.0 - (double)picHeight/2.0; picBound.bottom = picBound.top + picHeight; GEOMETRY::geom::Envelope picExtent; GEOMETRY::geom::Geometry *pGeoPic = NULL; Element::CPictureElementPtr pPictureElement = NULL; pMap->GetDisplay()->GetDisplayTransformation().TransformToGeo(picBound, &picExtent); pGeoPic = GEOMETRY::geom::GeometryFactory::getDefaultInstance()->toGeometry(&picExtent); pPictureElement.reset(new Element::CPictureElement(*pGeoPic)); pPictureElement->SetLayer(pLayer); pPictureElement->SetPicturePath((LPSTR)(LPCSTR)csDataSourceTmp); GEOMETRY::geom::GeometryFactory::getDefaultInstance()->destroyGeometry(pGeoPic); pMap->GetGraphicLayer()->UnselectAllElements(); pMap->GetGraphicLayer()->AddElement(pPictureElement); pMap->GetGraphicLayer()->SelectElement(pPictureElement); //加入回退堆栈 //pMap->GetElementOperationStack()->AddOperation(Element::OPT_ADD, pPictureElement); m_pMapCtrl->UpdateControl(drawElement | drawEdit); //设置m_pMapCtrl为选择图元 m_pMapCtrl->SetCurTool("SelectElementsTool"); } }