ActionDlg.cpp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. // ActionDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "IDE.h"
  5. #include "ActionDlg.h"
  6. //#include "Afxcoll.h"
  7. //#include <io.h>
  8. #include "SystemManager.h"
  9. #include ".\actiondlg.h"
  10. #include "Dlg_Pwd.h"
  11. //
  12. //const CString actionType[] =
  13. //{
  14. // g_strControl, g_strSet, g_strAdjust, g_strPictureLink, g_strExit, g_strExLink
  15. //};
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CActionDlg dialog
  18. CActionDlg::CActionDlg(CWnd* pParent /*=NULL*/)
  19. : CDialog(CActionDlg::IDD, pParent)
  20. {
  21. //{{AFX_DATA_INIT(CActionDlg)
  22. m_strActionType = _T("");
  23. m_strActionValue = _T("");
  24. m_strVariant = _T("");
  25. m_strPicPath = _T("");
  26. m_arrayActionType[0] = g_strControl;
  27. m_arrayActionType[1] = g_strSet;
  28. m_arrayActionType[2] = g_strAdjust;
  29. m_arrayActionType[3] = g_strPictureLink;
  30. m_arrayActionType[4] = g_strExit;
  31. m_arrayActionType[5] = g_strExLink;
  32. m_arrayActionType[6] = g_strTestAlarm;
  33. m_arrayActionType[7] = g_strAlarmRed;
  34. m_arrayActionType[8] = g_strNoticeRed;
  35. m_arrayActionType[9] = g_strDeviceLog;
  36. m_arrayActionType[10] = g_strSystemLog;
  37. m_arrayActionType[11] = g_strVarManage;
  38. m_arrayActionType[12] = g_strUserManage;
  39. m_arrayActionType[13] = g_strPwdManage;
  40. m_arrayActionType[14] = g_strFirstPage;
  41. m_arrayActionType[15] = g_strNativageTree;
  42. //}}AFX_DATA_INIT
  43. }
  44. void CActionDlg::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CActionDlg)
  48. DDX_CBString(pDX, IDC_ACTION_TYPE, m_strActionType);
  49. DDX_Text(pDX, IDC_ACTION_VALUE, m_strActionValue);
  50. DDX_CBString(pDX, IDC_VARIANTS, m_strVariant);
  51. DDX_CBString(pDX, IDC_PIC_PATH, m_strPicPath);
  52. //}}AFX_DATA_MAP
  53. }
  54. BEGIN_MESSAGE_MAP(CActionDlg, CDialog)
  55. //{{AFX_MSG_MAP(CActionDlg)
  56. ON_CBN_SELCHANGE(IDC_ACTION_TYPE, OnSelchangeActionType)
  57. //}}AFX_MSG_MAP
  58. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  59. ON_CBN_SELENDOK(IDC_VARIANTS, OnCbnSelendokVariants)
  60. END_MESSAGE_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CActionDlg message handlers
  63. void CActionDlg::OnSelchangeActionType()
  64. {
  65. // 根据不同操作类型,列变量列表
  66. CComboBox* pComType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
  67. CComboBox* pComVar = (CComboBox*)GetDlgItem(IDC_VARIANTS);
  68. CComboBox* pComPath = (CComboBox*)GetDlgItem(IDC_PIC_PATH);
  69. pComVar->ResetContent();
  70. pComPath->ResetContent();
  71. switch(pComType->GetCurSel())
  72. {
  73. case 0:
  74. case 1:
  75. case 2:
  76. {
  77. //pComVar->ResetContent();
  78. CStringArray aAnalogName;
  79. pVariantsManager->GetAnalogNameArray(aAnalogName);
  80. int size = aAnalogName.GetSize();
  81. for ( int i = 0; i < size; i++)
  82. {
  83. pComVar->AddString(aAnalogName[i]);
  84. }
  85. pComVar->SetCurSel(0);
  86. pComVar->ShowWindow(SW_SHOW);
  87. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  88. pStatic->ShowWindow(SW_SHOW);
  89. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  90. pStatic1->ShowWindow(SW_HIDE);
  91. }
  92. break;
  93. case 3: // 画面链接
  94. {
  95. //pComVar->ResetContent();
  96. //pComPath->ResetContent();
  97. CStringArray picName, picPath;
  98. CSystemManager::GetPicNameArray(picName, picPath);
  99. int size = picName.GetSize();
  100. for ( int i = 0; i < size; i++)
  101. {
  102. int nPos = picPath[i].Find("\\\\");
  103. if( nPos!=-1 )
  104. {
  105. picPath[i].Delete( nPos );
  106. }
  107. int nLen = picPath[i].GetLength();
  108. nPos = picPath[i].Find("View");
  109. CString sTemp;
  110. if( nPos<nLen-5 )
  111. sTemp = picPath[i].Right( nLen-nPos-5 );
  112. //sTemp = sTemp+"\\"+picName[i];
  113. pComVar->AddString(sTemp);
  114. pComPath->AddString(picPath[i]);
  115. TRACE1("%s\r\n", picPath[i]);
  116. }
  117. pComVar->SetCurSel(0);
  118. pComPath->SetCurSel(0);
  119. pComVar->ShowWindow(SW_SHOW);
  120. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC23);
  121. pStatic->ShowWindow(SW_SHOW);
  122. }
  123. break;
  124. case 4: // 组态
  125. case 5: // 退出
  126. {
  127. //pComVar->ShowWindow(SW_HIDE);
  128. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  129. pStatic->ShowWindow(SW_HIDE);
  130. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  131. pStatic1->ShowWindow(SW_HIDE);
  132. pComVar->ShowWindow( SW_HIDE );
  133. }
  134. case 6://外部链接
  135. {
  136. //pComVar->ShowWindow(SW_HIDE);
  137. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  138. pStatic->ShowWindow(SW_HIDE);
  139. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  140. pStatic1->ShowWindow(SW_HIDE);
  141. pComVar->ShowWindow( SW_HIDE );
  142. }
  143. break;
  144. case 7: //
  145. case 8: //
  146. case 9: //
  147. case 10: //
  148. case 11: //
  149. case 12: //
  150. case 13: //
  151. case 14: //
  152. case 15: //
  153. {
  154. //pComVar->ShowWindow(SW_HIDE);
  155. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  156. pStatic->ShowWindow(SW_HIDE);
  157. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  158. pStatic1->ShowWindow(SW_HIDE);
  159. pComVar->ShowWindow( SW_HIDE );
  160. }
  161. break;
  162. }
  163. }
  164. BOOL CActionDlg::OnInitDialog()
  165. {
  166. CDialog::OnInitDialog();
  167. CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
  168. pActionType->AddString( g_strControl );
  169. pActionType->AddString( g_strSet );
  170. pActionType->AddString( g_strAdjust );
  171. pActionType->AddString( g_strPictureLink );
  172. pActionType->AddString( g_strExit );
  173. pActionType->AddString( g_strExLink );
  174. pActionType->AddString( g_strTestAlarm);
  175. pActionType->AddString( g_strAlarmRed );
  176. pActionType->AddString( g_strNoticeRed );
  177. pActionType->AddString( g_strDeviceLog );
  178. pActionType->AddString( g_strSystemLog );
  179. pActionType->AddString( g_strVarManage );
  180. pActionType->AddString( g_strUserManage );
  181. pActionType->AddString( g_strPwdManage );
  182. pActionType->AddString( g_strFirstPage );
  183. pActionType->AddString( g_strNativageTree );
  184. CComboBox* pComVar = (CComboBox*)GetDlgItem(IDC_VARIANTS);
  185. CComboBox* pComPath = (CComboBox*)GetDlgItem(IDC_PIC_PATH);
  186. int nType = GetActionTypeNo(m_strActionType);
  187. switch (nType)
  188. {
  189. case 0:
  190. case 1:
  191. case 2:
  192. {
  193. //pComVar->ResetContent();
  194. CStringArray aAnalogName;
  195. pVariantsManager->GetAnalogNameArray(aAnalogName);
  196. int size = aAnalogName.GetSize();
  197. for ( int i = 0; i < size; i++)
  198. {
  199. pComVar->AddString(aAnalogName[i]);
  200. }
  201. if( m_strVariant=="" )
  202. pComVar->SetCurSel(0);
  203. pComVar->ShowWindow(SW_SHOW);
  204. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  205. pStatic->ShowWindow(SW_SHOW);
  206. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  207. pStatic1->ShowWindow(SW_HIDE);
  208. }
  209. break;
  210. case 3:
  211. {
  212. CStringArray picName, picPath;
  213. CSystemManager::GetPicNameArray(picName, picPath);
  214. int size = picName.GetSize();
  215. for ( int i = 0; i < size; i++)
  216. {
  217. int nPos = picPath[i].Find("\\\\");
  218. if( nPos!=-1 )
  219. {
  220. picPath[i].Delete( nPos );
  221. }
  222. int nLen = picPath[i].GetLength();
  223. nPos = picPath[i].Find("View");
  224. CString sTemp;
  225. if( nPos<nLen-5 )
  226. sTemp = picPath[i].Right( nLen-nPos-5 );
  227. //sTemp = sTemp+"\\"+picName[i];
  228. pComVar->AddString(sTemp);
  229. pComPath->AddString(picPath[i]);
  230. TRACE1("%s\r\n", picPath[i]);
  231. TRACE("%s\r\n", picName[i]);
  232. }
  233. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  234. pStatic->ShowWindow(SW_HIDE);
  235. }
  236. break;
  237. case 4:
  238. case 5:
  239. {
  240. pComVar->ShowWindow(SW_HIDE);
  241. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  242. pStatic->ShowWindow(SW_HIDE);
  243. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  244. pStatic1->ShowWindow(SW_HIDE);
  245. }
  246. break;
  247. case 6:
  248. {
  249. pComVar->ShowWindow(SW_HIDE);
  250. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  251. pStatic->ShowWindow(SW_HIDE);
  252. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  253. pStatic1->ShowWindow(SW_HIDE);
  254. }
  255. break;
  256. case 7: //
  257. case 8: //
  258. case 9: //
  259. case 10: //
  260. case 11: //
  261. case 12: //
  262. case 13: //
  263. case 14: //
  264. case 15: //
  265. {
  266. //pComVar->ShowWindow(SW_HIDE);
  267. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  268. pStatic->ShowWindow(SW_HIDE);
  269. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  270. pStatic1->ShowWindow(SW_HIDE);
  271. pComVar->ShowWindow( SW_HIDE );
  272. }
  273. break;
  274. }
  275. UpdateData(TRUE);
  276. if( m_strVariant!="" )
  277. pComVar->SetWindowText(m_strVariant);
  278. if( m_strPicPath!="" )
  279. pComPath->SetWindowText(m_strPicPath);
  280. UpdateData(FALSE);
  281. return TRUE;
  282. }
  283. int CActionDlg::GetActionTypeNo(CString strType)
  284. {
  285. for ( int i = 0; i < 16; i++)
  286. {
  287. if (strType == m_arrayActionType[i])
  288. {
  289. return i;
  290. }
  291. }
  292. return -1;
  293. }
  294. void CActionDlg::ChangeCtrlInfo()
  295. {
  296. CComboBox* pComVar = (CComboBox*)GetDlgItem(IDC_VARIANTS);
  297. CComboBox* pComPath = (CComboBox*)GetDlgItem(IDC_PIC_PATH);
  298. CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
  299. int nType = pActionType->GetCurSel();
  300. int nIndex = pComVar->GetCurSel();
  301. switch (nType)
  302. {
  303. case 3:
  304. pComPath->SetCurSel(nIndex);
  305. break;
  306. }
  307. }
  308. void CActionDlg::OnBnClickedOk()
  309. {
  310. // TODO: 在此添加控件通知处理程序代码
  311. CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
  312. int nType = pActionType->GetCurSel();
  313. if( nType>=0 && nType<=2 )
  314. {
  315. CDlg_Pwd dlg(0);
  316. if( dlg.DoModal()!=IDOK )
  317. return;
  318. }
  319. ChangeCtrlInfo();
  320. OnOK();
  321. }
  322. void CActionDlg::OnCbnSelendokVariants()
  323. {
  324. // TODO: 在此添加控件通知处理程序代码
  325. ChangeCtrlInfo();
  326. }