#include "StdAfx.h" #include "ViewMgr.h" #include "resource.h" #include "DisplayWnd.h" #include "Config.h" #include "MsgCenter.h" SINGLETON_IMPLEMENT(CViewMgr) CViewMgr::CViewMgr(void) { } CViewMgr::~CViewMgr(void) { } /***************************************************************** **【函数名称】 setup **【函数功能】 视图管理器创建 **【参数】 **【返回值】 ****************************************************************/ bool CViewMgr::setup( CDisplayWnd* pWnd ) { ASSERT(pWnd != NULL); m_pWnd = pWnd; if(!m_ViewLog.create(pWnd)) { AfxMessageBox(_T("日志视图创建失败!")); return false; } ILogger::getInstance().init(&m_ViewLog, LOG_DEV_VS, CConfig::logFilePath()); ILogger::getInstance().start(); if(!m_ViewRes.create(pWnd)) { AfxMessageBox(_T("设备资源视图创建失败!")); return false; } if(!m_ViewLine.create(pWnd)) { AfxMessageBox(_T("线路资源视图创建失败!")); return false; } if(!m_ViewFax.create(pWnd)) { AfxMessageBox(_T("传真资源视图创建失败!")); return false; } CMsgCenter& MsgCenter = CMsgCenter::GetInstance(); MsgCenter.regist(VS_MSG_DEV_FAX_STATE_UPDAET, this); MsgCenter.regist(VS_MSG_LINE_STATE_UPDATE, this); return true; } /***************************************************************** **【函数名称】 onMessage **【函数功能】 消息事件处理函数 **【参数】 MsgType: 消息事件类型 lpContent: 消息内容 **【返回值】 ****************************************************************/ void CViewMgr::onMessage( UINT MsgType, const PARAM lpContent ) { switch(MsgType) { case VS_MSG_LINE_STATE_UPDATE: // 线路资源状态变化 { m_ViewLine.onLineStateUpdated(reinterpret_cast(lpContent)); } break; case VS_MSG_DEV_FAX_STATE_UPDAET: // 传真资源状态变化 { m_ViewFax.onFaxStateUpdated(reinterpret_cast(lpContent)); } break; default: ASSERT(FALSE); break; } }