#include "StdAfx.h" #include "MBFileLogoMgr.h" ////////////// ÎļþlogoÐÅÏ¢ /////////////////////// CMBFileLogoInfo::CMBFileLogoInfo(void) { } CMBFileLogoInfo::~CMBFileLogoInfo(void) { } // ÓÐÎļþÀàÐÍ bool CMBFileLogoInfo::HasFilType( CString strFileType ) { CString strTmpFileType; strFileType = strFileType.Trim(); int nCount = m_arFileType.GetCount(); for( int i = 0;i < nCount;i++ ) { strTmpFileType = m_arFileType[i]; if( strTmpFileType.CompareNoCase(strFileType) ==0 ) return true; } return false; } ///////////// Îļþlogo¹ÜÀíÆ÷ //////////////////////// CMBFileLogoMgr::CMBFileLogoMgr(void) { } CMBFileLogoMgr::~CMBFileLogoMgr(void) { } // µÃµ½ÎļþlogoÐÅÏ¢ CMBFileLogoInfo *CMBFileLogoMgr::GetFileLogoInfo( CString strName ) { strName = strName.Trim(); if( strName.IsEmpty() ) { return NULL; } CMBFileLogoInfoMap::iterator it; CMBFileLogoInfo *pFileLogoInfo = NULL; it = m_mapFileLogoInfo.find(strName); if( it!= m_mapFileLogoInfo.end() ) pFileLogoInfo = it->second; return pFileLogoInfo; } // µÃµ½ÎļþlogoÃû³Æ CString CMBFileLogoMgr::GetFileLogoName( CString strFileType ) { int nPos = strFileType.Find(_T(".")); if( nPos == 0 ) { strFileType = strFileType.Right(strFileType.GetLength()-1); } CMBFileLogoInfoMap::iterator it; CMBFileLogoInfo *pFileLogoInfo = NULL; for( it = m_mapFileLogoInfo.begin();it != m_mapFileLogoInfo.end();it++ ) { pFileLogoInfo = it->second; if( pFileLogoInfo->HasFilType(strFileType) ) return pFileLogoInfo->m_strName; } return _T("OtherType"); } // Ìí¼ÓÎļþlogoÐÅÏ¢ bool CMBFileLogoMgr::AddFileLogoInfo( CMBFileLogoInfo *pFileLogoInfo ) { if( NULL == pFileLogoInfo || pFileLogoInfo->m_strName.IsEmpty() ) return false; CMBFileLogoInfoMap::iterator it; CString strName; strName = pFileLogoInfo->m_strName; it = m_mapFileLogoInfo.find(strName); // Èç¹ûÕҵõ½ ·µ»Ø if( it != m_mapFileLogoInfo.end() ) return false; m_mapFileLogoInfo[strName] = pFileLogoInfo; return true; } // ÒÆ³ýÎļþlogoÐÅÏ¢ bool CMBFileLogoMgr::RemoveAllFileLogoInfo() { CMBFileLogoInfoMap::iterator it; CMBFileLogoInfo *pFileLogoInfo = NULL; for( it = m_mapFileLogoInfo.begin();it != m_mapFileLogoInfo.end();it++ ) { pFileLogoInfo = it->second; delete pFileLogoInfo; pFileLogoInfo = NULL; } m_mapFileLogoInfo.clear(); return true; } // µÃµ½´óͼƬ SStringT CMBFileLogoMgr::GetFileLogoBigIcon( CString strFileType ) { SStringT strTmpSkin; strTmpSkin.Format(_T("%sBigIcon\\%s.png"),m_strSkinPath,GetFileLogoName(strFileType)); return strTmpSkin; } // µÃµ½Ð¡Í¼Æ¬ SStringT CMBFileLogoMgr::GetFileLogoSmallIcon( CString strFileType ) { SStringT strTmpSkin; strTmpSkin.Format(_T("%sSmallIcon\\%s.png"),m_strSkinPath,GetFileLogoName(strFileType)); return strTmpSkin; } // µÃµ½ÖÐͼƬ SStringT CMBFileLogoMgr::GetFileLogoMiddleIcon( CString strFileType ) { SStringT strTmpSkin; strTmpSkin.Format(_T("%sMiddleIcon\\%s.png"),m_strSkinPath,GetFileLogoName(strFileType)); return strTmpSkin; } // ½âÎöxmlÎļþÐÅÏ¢ bool CMBFileLogoMgr::ParseXml( CString &strErrInfo ) { CString strWorkDir = CBaseCommFun::GetWorkDir(); CString strFileName; pugi::xml_document xmlDoc; m_strSkinPath.Format( _T("%s\\skin\\"),strWorkDir ); strFileName = strWorkDir + _T("\\skin\\FileLogo.xml"); if (!xmlDoc.load_file(strFileName)) { strErrInfo = _T("¼ÓÔØÎļþ ") + strFileName + _T(" ʧ°Ü£¡"); return false; } pugi::xml_node form = xmlDoc.child(_T("Body")).child(_T("FileLogo")); for(pugi::xml_node node = form; node; node = node.next_sibling(_T("FileLogo"))) { CMBFileLogoInfo *pFileLogoInfo = new CMBFileLogoInfo(); pFileLogoInfo->m_strName = node.attribute(_T("Name")).value(); form = node.child(_T("FileType")); for(pugi::xml_node nodeTmp = form; nodeTmp; nodeTmp = nodeTmp.next_sibling(_T("FileType"))) { pFileLogoInfo->m_arFileType.Add(nodeTmp.child_value()); } if( !AddFileLogoInfo( pFileLogoInfo ) ) { delete pFileLogoInfo; pFileLogoInfo = NULL; } } return true; } //ISkinObj *CMBFileLogoMgr::GetFileLogoSmallIconSkin( CString strFileType ) //{ // SStringT _skinId = L"skin.richedit.msgwaitimg"; // ISkinObj* pSkin =NULL; // if (!ImageProvider::IsExist(_skinId)) // { // pSkin = GETSKIN(_skinId, 100); // pSkin->AddRef(); // if (pSkin) // { // ImageProvider::Insert(_skinId, pSkin); // } // } // _skinId = L"skin.richedit.msgerrorimg"; // if (!ImageProvider::IsExist(_skinId)) // { // pSkin = GETSKIN(_skinId, 100); // pSkin->AddRef(); // if (pSkin) // { // ImageProvider::Insert(_skinId, pSkin); // } // } // SAntialiasSkin* pSkin = new SAntialiasSkin(); // pSkin->SetRoundCorner(5, 5, 5, 5); // Ìí¼ÓÔ²½Ç´¦Àí // if (pSkin->LoadFromFile(info.AvatarPath)) // { // ImageProvider::Insert(info.AvatarId, pSkin); // } // else // { // delete pSkin; // } //} // //ISkinObj *CMBFileLogoMgr::GetFileLogoMiddleIconSkin( CString strFileType ) //{ //} // µÃµ½ÎļþlogoÃû³Æ CMBFileLogoInfoMap * CMBFileLogoMgr::GetFileLogoMap ( ) { return &m_mapFileLogoInfo; }