Source code of Windows XP (NT5)
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.

279 lines
7.2 KiB

  1. // SInfodlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "evtview.h"
  5. #include "SInfodlg.h"
  6. #include "globals.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CScheduleInfo dialog
  14. CScheduleInfo::CScheduleInfo(CWnd* pParent /*=NULL*/)
  15. : CDialog(CScheduleInfo::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CScheduleInfo)
  18. //}}AFX_DATA_INIT
  19. }
  20. void CScheduleInfo::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CScheduleInfo)
  24. DDX_Control(pDX, IDC_TIMEINFOLIST, m_ctrlTime);
  25. DDX_Control(pDX, IDC_EVENTINFOLIST, m_ctrlEvent);
  26. DDX_Control(pDX, IDC_ACTIONINFOLIST, m_ctrlAction);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CScheduleInfo, CDialog)
  30. //{{AFX_MSG_MAP(CScheduleInfo)
  31. ON_BN_CLICKED(IDC_ADDACTIONINFOBUTTON, OnAddactioninfobutton)
  32. ON_BN_CLICKED(IDC_ADDEVENTINFOBUTTON, OnAddeventinfobutton)
  33. ON_BN_CLICKED(IDC_ADDTIMEINFOBUTTON, OnAddtimeinfobutton)
  34. ON_BN_CLICKED(IDC_REMOVEACTIONINFOBUTTON, OnRemoveactioninfobutton)
  35. ON_BN_CLICKED(IDC_REMOVEEVENTINFOBUTTON, OnRemoveeventinfobutton)
  36. ON_BN_CLICKED(IDC_REMOVETIMEINFOBUTTON, OnRemovetimeinfobutton)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CScheduleInfo message handlers
  41. void CScheduleInfo::OnOK()
  42. {
  43. // TODO: Add extra validation here
  44. CDialog::OnOK();
  45. }
  46. void
  47. CScheduleInfo::InsertEventInfo (SCHEDULE_EVENTINFO *pEventInfo)
  48. {
  49. int iCount ;
  50. PEVENTDEFINITION pEvtDef ;
  51. PDWORDTOSTRINGMAP pTypeMap ;
  52. pEvtDef = GetEventDefinition (pEventInfo->dwCatagory) ;
  53. pTypeMap = pEvtDef->pFilter ;
  54. m_ctrlEvent.InsertItem (iCount = m_ctrlEvent.GetItemCount(), pEvtDef->szCatagory) ;
  55. m_ctrlEvent.SetItemText (iCount, 1, pEventInfo->szSourceName) ;
  56. m_ctrlEvent.SetItemText (iCount, 2, pEventInfo->szObjectName) ;
  57. m_ctrlEvent.SetItemText (iCount, 3, GetType (pEventInfo->dwCatagory, pEventInfo->dwFilter)) ;
  58. // m_ctrlEvent.SetItemText (iCount, 4, GetType (aTypeMap, pEventInfo->dwSubFilter)) ;
  59. }
  60. void
  61. CScheduleInfo::InsertActionInfo (SCHEDULE_ACTIONINFO *pActionInfo)
  62. {
  63. int iCount ;
  64. m_ctrlAction.InsertItem (iCount = m_ctrlAction.GetItemCount(), GetType (aAction, pActionInfo->dwActionType)) ;
  65. m_ctrlAction.SetItemText (iCount, 1, pActionInfo->stParam) ;
  66. }
  67. void
  68. CScheduleInfo::InsertTimeInfo (SCHEDULE_TIMEINFO *pTimeInfo)
  69. {
  70. int iCount ;
  71. WCHAR szBuf [NAME_LEN] ;
  72. wsprintf (szBuf, L"%d", pTimeInfo->iYear) ;
  73. m_ctrlTime.InsertItem (iCount = m_ctrlTime.GetItemCount (), szBuf) ;
  74. wsprintf (szBuf, L"%d", pTimeInfo->iMonth) ;
  75. m_ctrlTime.SetItemText (iCount, 1, szBuf) ;
  76. wsprintf (szBuf, L"%d", pTimeInfo->iDay) ;
  77. m_ctrlTime.SetItemText (iCount, 2, szBuf) ;
  78. szBuf [0] = L'\0' ;
  79. if (pTimeInfo->iWeekDay & SCHEDULE_SUNDAY)
  80. wcscat (szBuf, L"Su ") ;
  81. if (pTimeInfo->iWeekDay & SCHEDULE_MONDAY)
  82. wcscat (szBuf, L"Mo ") ;
  83. if (pTimeInfo->iWeekDay & SCHEDULE_TUESDAY)
  84. wcscat (szBuf, L"Tu ") ;
  85. if (pTimeInfo->iWeekDay & SCHEDULE_WEDNESDAY)
  86. wcscat (szBuf, L"We ") ;
  87. if (pTimeInfo->iWeekDay & SCHEDULE_THURSDAY)
  88. wcscat (szBuf, L"Th ") ;
  89. if (pTimeInfo->iWeekDay & SCHEDULE_FRIDAY)
  90. wcscat (szBuf, L"Fr ") ;
  91. if (pTimeInfo->iWeekDay & SCHEDULE_SATURDAY)
  92. wcscat (szBuf, L"Sa ") ;
  93. m_ctrlTime.SetItemText (iCount, 3, szBuf) ;
  94. wsprintf (szBuf, L"%d", pTimeInfo->iHour) ;
  95. m_ctrlTime.SetItemText (iCount, 4, szBuf) ;
  96. wsprintf (szBuf, L"%d", pTimeInfo->iMin) ;
  97. m_ctrlTime.SetItemText (iCount, 5, szBuf) ;
  98. wsprintf (szBuf, L"%d", pTimeInfo->iSec) ;
  99. m_ctrlTime.SetItemText (iCount, 6, szBuf) ;
  100. }
  101. BOOL CScheduleInfo::OnInitDialog()
  102. {
  103. CDialog::OnInitDialog();
  104. m_ctrlAction.InsertColumn (0, L"Type", LVCFMT_LEFT, 70, 0) ;
  105. m_ctrlAction.InsertColumn (1, L"Parameters", LVCFMT_LEFT, 90, 1) ;
  106. POSITION pos ;
  107. SCHEDULE_ACTIONINFO *pActionInfo ;
  108. pos = pSInfo->lstActionInfo.GetHeadPosition () ;
  109. while (pos)
  110. {
  111. pActionInfo = (SCHEDULE_ACTIONINFO *)pSInfo->lstActionInfo.GetNext (pos) ;
  112. InsertActionInfo (pActionInfo) ;
  113. }
  114. m_ctrlEvent.InsertColumn (0, L"Catagory", LVCFMT_LEFT, 100) ;
  115. m_ctrlEvent.InsertColumn (3, L"Source Name", LVCFMT_LEFT, 140) ;
  116. m_ctrlEvent.InsertColumn (0, L"ObjectName", LVCFMT_LEFT, 100) ;
  117. m_ctrlEvent.InsertColumn (1, L"Filter", LVCFMT_LEFT, 100) ;
  118. m_ctrlEvent.InsertColumn (2, L"SubFilter", LVCFMT_LEFT, 80) ;
  119. SCHEDULE_EVENTINFO *pEventInfo ;
  120. pos = pSInfo->lstEventInfo.GetHeadPosition () ;
  121. while (pos)
  122. {
  123. pEventInfo = (SCHEDULE_EVENTINFO *)pSInfo->lstEventInfo.GetNext (pos) ;
  124. InsertEventInfo (pEventInfo) ;
  125. }
  126. m_ctrlTime.InsertColumn (0, L"Year", LVCFMT_LEFT, 60) ;
  127. m_ctrlTime.InsertColumn (1, L"Month", LVCFMT_LEFT, 60) ;
  128. m_ctrlTime.InsertColumn (2, L"Day", LVCFMT_LEFT, 60) ;
  129. m_ctrlTime.InsertColumn (3, L"Week Day", LVCFMT_LEFT, 100) ;
  130. m_ctrlTime.InsertColumn (4, L"Hour", LVCFMT_LEFT, 60) ;
  131. m_ctrlTime.InsertColumn (5, L"Minute", LVCFMT_LEFT, 60) ;
  132. m_ctrlTime.InsertColumn (6, L"Second", LVCFMT_LEFT, 60) ;
  133. SCHEDULE_TIMEINFO *pTimeInfo ;
  134. pos = pSInfo->lstTimeInfo.GetHeadPosition () ;
  135. while (pos)
  136. {
  137. pTimeInfo = (SCHEDULE_TIMEINFO *)pSInfo->lstTimeInfo.GetNext (pos) ;
  138. InsertTimeInfo (pTimeInfo) ;
  139. }
  140. return TRUE; // return TRUE unless you set the focus to a control
  141. // EXCEPTION: OCX Property Pages should return FALSE
  142. }
  143. void CScheduleInfo::OnAddactioninfobutton()
  144. {
  145. if (oAction.DoModal () == IDOK)
  146. {
  147. SCHEDULE_ACTIONINFO *pActionInfo = new SCHEDULE_ACTIONINFO ;
  148. *pActionInfo = oAction.sActionInfo ;
  149. pSInfo->lstActionInfo.AddTail (pActionInfo) ;
  150. InsertActionInfo (pActionInfo) ;
  151. }
  152. }
  153. void CScheduleInfo::OnAddeventinfobutton()
  154. {
  155. oEvent.dwCatagory = EVENT_CATAGORY_CLUSTER ;
  156. if (oEvent.DoModal () == IDOK)
  157. {
  158. SCHEDULE_EVENTINFO *pEventInfo = new SCHEDULE_EVENTINFO ;
  159. *pEventInfo = oEvent.sEventInfo ;
  160. pSInfo->lstEventInfo.AddTail (pEventInfo) ;
  161. InsertEventInfo (pEventInfo) ;
  162. }
  163. }
  164. void CScheduleInfo::OnAddtimeinfobutton()
  165. {
  166. if (oTime.DoModal () == IDOK)
  167. {
  168. SCHEDULE_TIMEINFO *pTimeInfo = new SCHEDULE_TIMEINFO ;
  169. *pTimeInfo = oTime.sTimeInfo ;
  170. pSInfo->lstTimeInfo.AddTail (pTimeInfo) ;
  171. InsertTimeInfo (pTimeInfo) ;
  172. }
  173. }
  174. void CScheduleInfo::OnRemoveactioninfobutton()
  175. {
  176. int iIndex = m_ctrlAction.GetNextItem (-1, LVNI_SELECTED) ;
  177. if (iIndex != -1)
  178. {
  179. POSITION pos = pSInfo->lstActionInfo.FindIndex (iIndex) ;
  180. pSInfo->lstActionInfo.RemoveAt (pos) ;
  181. m_ctrlAction.DeleteItem (iIndex) ;
  182. }
  183. }
  184. void CScheduleInfo::OnRemoveeventinfobutton()
  185. {
  186. int iIndex = m_ctrlEvent.GetNextItem (-1, LVNI_SELECTED) ;
  187. if (iIndex != -1)
  188. {
  189. POSITION pos = pSInfo->lstEventInfo.FindIndex (iIndex) ;
  190. pSInfo->lstEventInfo.RemoveAt (pos) ;
  191. m_ctrlEvent.DeleteItem (iIndex) ;
  192. }
  193. }
  194. void CScheduleInfo::OnRemovetimeinfobutton()
  195. {
  196. int iIndex = m_ctrlTime.GetNextItem (-1, LVNI_SELECTED) ;
  197. if (iIndex != -1)
  198. {
  199. POSITION pos = pSInfo->lstTimeInfo.FindIndex (iIndex) ;
  200. pSInfo->lstTimeInfo.RemoveAt (pos) ;
  201. m_ctrlTime.DeleteItem (iIndex) ;
  202. }
  203. }
  204. void CScheduleInfo::Terminate()
  205. {
  206. if (GetSafeHwnd())
  207. {
  208. AfxMessageBox (L"The data being edited is scheduled so it closes the dialog") ;
  209. if (oTime.GetSafeHwnd ())
  210. oTime.EndDialog (IDCANCEL) ;
  211. if (oEvent.GetSafeHwnd ())
  212. oEvent.EndDialog (IDCANCEL) ;
  213. if (oAction.GetSafeHwnd ())
  214. oAction.EndDialog (IDCANCEL) ;
  215. EndDialog (IDCANCEL) ;
  216. }
  217. }