mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
287 lines
7.5 KiB
287 lines
7.5 KiB
// SystemsScopeItem.cpp: implementation of the CSystemsScopeItem class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
#include "snapin.h"
|
|
#include "SystemsScopeItem.h"
|
|
#include "SystemsResultsView.h"
|
|
#include "AllSystemsScopeItem.h"
|
|
#include "HealthmonScopePane.h"
|
|
#include "ClearEventsDlg.h"
|
|
#include "SystemGroup.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
IMPLEMENT_DYNCREATE(CSystemsScopeItem,CHMScopeItem)
|
|
|
|
// {ADE7EC03-B0C1-11d2-BD6C-0000F87A3912}
|
|
static GUID GUID_Systems =
|
|
{ 0xade7ec03, 0xb0c1, 0x11d2, { 0xbd, 0x6c, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12 } };
|
|
|
|
|
|
// icon table - associates state to icons
|
|
static UINT _Icons[HMS_MAX_STATES] =
|
|
{
|
|
IDI_ICON_SYSTEMS,
|
|
IDI_ICON_SYSTEMS_DISABLED,
|
|
IDI_ICON_SYSTEMS_OUTAGE,
|
|
IDI_ICON_SYSTEMS_UNKNOWN,
|
|
IDI_ICON_SYSTEMS_NO_CONNECT,
|
|
IDI_ICON_SYSTEMS_WARNING,
|
|
IDI_ICON_SYSTEMS_CRITICAL
|
|
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CSystemsScopeItem::CSystemsScopeItem()
|
|
{
|
|
m_lpguidItemType = &GUID_Systems;
|
|
}
|
|
|
|
CSystemsScopeItem::~CSystemsScopeItem()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Creation Members
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
bool CSystemsScopeItem::Create(CScopePane* pScopePane, CScopePaneItem* pParentItem)
|
|
{
|
|
TRACEX(_T("CSystemsScopeItem::Create\n"));
|
|
TRACEARGn(pScopePane);
|
|
TRACEARGn(pParentItem);
|
|
|
|
// set up all the icons first
|
|
for( int i = 0; i < HMS_MAX_STATES; i++ )
|
|
{
|
|
UINT nId = _Icons[i];
|
|
m_IconResIds.Add(nId);
|
|
m_OpenIconResIds.Add(nId);
|
|
}
|
|
SetIconIndex(HMS_NORMAL);
|
|
SetOpenIconIndex(HMS_NORMAL);
|
|
|
|
// call base class Create method
|
|
if( ! CHMScopeItem::Create(pScopePane,pParentItem) )
|
|
{
|
|
TRACE(_T("CHMScopeItem::Create failed.\n"));
|
|
return false;
|
|
}
|
|
|
|
// set display names
|
|
CString sName;
|
|
sName.LoadString(IDS_STRING_SYSTEMS_NODE);
|
|
SetDisplayName(0,sName);
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Results Pane View Members
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CResultsPaneView* CSystemsScopeItem::CreateResultsPaneView()
|
|
{
|
|
TRACEX(_T("CSystemsScopeItem::CreateResultsPaneView\n"));
|
|
|
|
return new CSystemsResultsView;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// MMC Notify Handlers
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
HRESULT CSystemsScopeItem::OnAddMenuItems(LPCONTEXTMENUCALLBACK piCallback,long __RPC_FAR *pInsertionAllowed)
|
|
{
|
|
TRACEX(_T("CSystemsScopeItem::OnAddMenuItems\n"));
|
|
TRACEARGn(piCallback);
|
|
TRACEARGn(pInsertionAllowed);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
// Add New Menu Items
|
|
if( CCM_INSERTIONALLOWED_NEW & *pInsertionAllowed )
|
|
{
|
|
CONTEXTMENUITEM cmi;
|
|
CString sResString;
|
|
CString sResString2;
|
|
|
|
sResString.LoadString(IDS_STRING_NEW_SYSTEMS_GROUP);
|
|
cmi.strName = LPTSTR(LPCTSTR(sResString));
|
|
sResString2.LoadString(IDS_STRING_NEW_SYSTEMS_GROUP_DESCRIPTION);
|
|
cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
|
|
cmi.lCommandID = IDM_NEW_GROUP;
|
|
cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_NEW;
|
|
cmi.fFlags = 0;
|
|
cmi.fSpecialFlags = 0;
|
|
|
|
hr = piCallback->AddItem(&cmi);
|
|
if( !SUCCEEDED(hr) )
|
|
{
|
|
TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
|
|
return hr;
|
|
}
|
|
|
|
}
|
|
|
|
// Add Task Menu Items
|
|
if( CCM_INSERTIONALLOWED_TASK & *pInsertionAllowed )
|
|
{
|
|
CONTEXTMENUITEM cmi;
|
|
CString sResString;
|
|
CString sResString2;
|
|
|
|
sResString.LoadString(IDS_STRING_CLEAR_EVENTS);
|
|
cmi.strName = LPTSTR(LPCTSTR(sResString));
|
|
sResString2.LoadString(IDS_STRING_CLEAR_EVENTS_DESCRIPTION);
|
|
cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
|
|
cmi.lCommandID = IDM_CLEAR_EVENTS;
|
|
cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
|
|
cmi.fFlags = 0;
|
|
cmi.fSpecialFlags = 0;
|
|
|
|
hr = piCallback->AddItem(&cmi);
|
|
if( !SUCCEEDED(hr) )
|
|
{
|
|
TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
|
|
return hr;
|
|
}
|
|
|
|
sResString.LoadString(IDS_STRING_RESET_STATUS);
|
|
cmi.strName = LPTSTR(LPCTSTR(sResString));
|
|
sResString2.LoadString(IDS_STRING_RESET_STATUS_DESCRIPTION);
|
|
cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
|
|
cmi.lCommandID = IDM_RESET_STATUS;
|
|
cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
|
|
cmi.fFlags = 0;
|
|
cmi.fSpecialFlags = 0;
|
|
|
|
hr = piCallback->AddItem(&cmi);
|
|
if( !SUCCEEDED(hr) )
|
|
{
|
|
TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
|
|
return hr;
|
|
}
|
|
|
|
// separator
|
|
cmi.strName = NULL;
|
|
cmi.strStatusBarText = NULL;
|
|
cmi.lCommandID = NULL;
|
|
cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
|
|
cmi.fFlags = MF_SEPARATOR;
|
|
cmi.fSpecialFlags = 0;
|
|
|
|
hr = piCallback->AddItem(&cmi);
|
|
if( !SUCCEEDED(hr) )
|
|
{
|
|
TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
|
|
return hr;
|
|
}
|
|
}
|
|
|
|
// Add View Menu Items
|
|
if( CCM_INSERTIONALLOWED_VIEW & *pInsertionAllowed )
|
|
{
|
|
CONTEXTMENUITEM cmi;
|
|
CString sResString;
|
|
CString sResString2;
|
|
|
|
sResString.LoadString(IDS_STRING_STATUS_ONLY);
|
|
cmi.strName = LPTSTR(LPCTSTR(sResString));
|
|
sResString2.LoadString(IDS_STRING_STATUS_ONLY_DESCRIPTION);
|
|
cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
|
|
cmi.lCommandID = IDM_STATUS_ONLY;
|
|
cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
|
|
cmi.fFlags = MF_UNCHECKED;
|
|
cmi.fSpecialFlags = 0;
|
|
|
|
hr = piCallback->AddItem(&cmi);
|
|
if( !SUCCEEDED(hr) )
|
|
{
|
|
TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
|
|
return hr;
|
|
}
|
|
|
|
sResString.LoadString(IDS_STRING_AUTO_FILTER);
|
|
cmi.strName = LPTSTR(LPCTSTR(sResString));
|
|
sResString2.LoadString(IDS_STRING_AUTO_FILTER_DESCRIPTION);
|
|
cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
|
|
cmi.lCommandID = IDM_AUTO_FILTER;
|
|
cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
|
|
cmi.fFlags = MF_CHECKED;
|
|
cmi.fSpecialFlags = 0;
|
|
|
|
hr = piCallback->AddItem(&cmi);
|
|
if( !SUCCEEDED(hr) )
|
|
{
|
|
TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
|
|
return hr;
|
|
}
|
|
|
|
// icon legend
|
|
sResString.LoadString(IDS_STRING_ICON_LEGEND);
|
|
cmi.strName = LPTSTR(LPCTSTR(sResString));
|
|
sResString2.LoadString(IDS_STRING_ICON_LEGEND_DESCRIPTION);
|
|
cmi.strStatusBarText = LPTSTR(LPCTSTR(sResString2));
|
|
cmi.lCommandID = IDM_ICON_LEGEND;
|
|
cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
|
|
cmi.fFlags = 0;
|
|
cmi.fSpecialFlags = 0;
|
|
|
|
hr = piCallback->AddItem(&cmi);
|
|
if( !SUCCEEDED(hr) )
|
|
{
|
|
TRACE(_T("FAILED : IContextMenuCallback::AddItem failed.\n"));
|
|
return hr;
|
|
}
|
|
|
|
}
|
|
|
|
return hr;
|
|
}
|
|
|
|
HRESULT CSystemsScopeItem::OnCommand(long lCommandID)
|
|
{
|
|
TRACEX(_T("CSystemsScopeItem::OnCommand\n"));
|
|
TRACEARGn(lCommandID);
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
switch(lCommandID)
|
|
{
|
|
case IDM_NEW_GROUP:
|
|
{
|
|
CHealthmonScopePane* pPane = (CHealthmonScopePane*)GetScopePane();
|
|
if( ! GfxCheckObjPtr(pPane,CHealthmonScopePane) )
|
|
{
|
|
TRACE(_T("FAILED : CGroupScopeItem::GetScopePane returns an invalid pointer.\n"));
|
|
return E_FAIL;
|
|
}
|
|
|
|
CSystemGroup* pMSG = pPane->GetRootGroup();
|
|
pMSG->CreateNewChildSystemGroup();
|
|
}
|
|
break;
|
|
|
|
default:
|
|
{
|
|
hr = CHMScopeItem::OnCommand(lCommandID);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return hr;
|
|
}
|
|
|
|
|