ActionDlg.cpp 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. if( pComType->GetCurSel()==0 )
  72. GetDlgItem( IDC_STA_SHOW)->ShowWindow(true);
  73. else
  74. GetDlgItem( IDC_STA_SHOW)->ShowWindow(false);
  75. switch(pComType->GetCurSel())
  76. {
  77. case 0:
  78. case 1:
  79. case 2:
  80. {
  81. //pComVar->ResetContent();
  82. CStringArray aAnalogName;
  83. pVariantsManager->GetAnalogNameArray(aAnalogName);
  84. int size = aAnalogName.GetSize();
  85. for ( int i = 0; i < size; i++)
  86. {
  87. pComVar->AddString(aAnalogName[i]);
  88. }
  89. pComVar->SetCurSel(0);
  90. pComVar->ShowWindow(SW_SHOW);
  91. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  92. pStatic->ShowWindow(SW_SHOW);
  93. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  94. pStatic1->ShowWindow(SW_HIDE);
  95. }
  96. break;
  97. case 3: // 画面链接
  98. {
  99. //pComVar->ResetContent();
  100. //pComPath->ResetContent();
  101. CStringArray picName, picPath;
  102. CSystemManager::GetPicNameArray(picName, picPath);
  103. int size = picName.GetSize();
  104. for ( int i = 0; i < size; i++)
  105. {
  106. int nPos = picPath[i].Find("\\\\");
  107. if( nPos!=-1 )
  108. {
  109. picPath[i].Delete( nPos );
  110. }
  111. int nLen = picPath[i].GetLength();
  112. nPos = picPath[i].Find("View");
  113. CString sTemp;
  114. if( nPos<nLen-5 )
  115. sTemp = picPath[i].Right( nLen-nPos-5 );
  116. //sTemp = sTemp+"\\"+picName[i];
  117. pComVar->AddString(sTemp);
  118. pComPath->AddString(picPath[i]);
  119. TRACE1("%s\r\n", picPath[i]);
  120. }
  121. pComVar->SetCurSel(0);
  122. pComPath->SetCurSel(0);
  123. pComVar->ShowWindow(SW_SHOW);
  124. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC23);
  125. pStatic->ShowWindow(SW_SHOW);
  126. }
  127. break;
  128. case 4: // 组态
  129. case 5: // 退出
  130. {
  131. //pComVar->ShowWindow(SW_HIDE);
  132. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  133. pStatic->ShowWindow(SW_HIDE);
  134. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  135. pStatic1->ShowWindow(SW_HIDE);
  136. pComVar->ShowWindow( SW_HIDE );
  137. }
  138. case 6://外部链接
  139. {
  140. //pComVar->ShowWindow(SW_HIDE);
  141. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  142. pStatic->ShowWindow(SW_HIDE);
  143. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  144. pStatic1->ShowWindow(SW_HIDE);
  145. pComVar->ShowWindow( SW_HIDE );
  146. }
  147. break;
  148. case 7: //
  149. case 8: //
  150. case 9: //
  151. case 10: //
  152. case 11: //
  153. case 12: //
  154. case 13: //
  155. case 14: //
  156. case 15: //
  157. {
  158. //pComVar->ShowWindow(SW_HIDE);
  159. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  160. pStatic->ShowWindow(SW_HIDE);
  161. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  162. pStatic1->ShowWindow(SW_HIDE);
  163. pComVar->ShowWindow( SW_HIDE );
  164. }
  165. break;
  166. }
  167. }
  168. BOOL CActionDlg::OnInitDialog()
  169. {
  170. CDialog::OnInitDialog();
  171. CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
  172. pActionType->AddString( g_strControl );
  173. pActionType->AddString( g_strSet );
  174. pActionType->AddString( g_strAdjust );
  175. pActionType->AddString( g_strPictureLink );
  176. pActionType->AddString( g_strExit );
  177. pActionType->AddString( g_strExLink );
  178. pActionType->AddString( g_strTestAlarm);
  179. pActionType->AddString( g_strAlarmRed );
  180. pActionType->AddString( g_strNoticeRed );
  181. pActionType->AddString( g_strDeviceLog );
  182. pActionType->AddString( g_strSystemLog );
  183. pActionType->AddString( g_strVarManage );
  184. pActionType->AddString( g_strUserManage );
  185. pActionType->AddString( g_strPwdManage );
  186. pActionType->AddString( g_strFirstPage );
  187. pActionType->AddString( g_strNativageTree );
  188. CComboBox* pComVar = (CComboBox*)GetDlgItem(IDC_VARIANTS);
  189. CComboBox* pComPath = (CComboBox*)GetDlgItem(IDC_PIC_PATH);
  190. GetDlgItem( IDC_STA_SHOW)->ShowWindow(false);
  191. int nType = GetActionTypeNo(m_strActionType);
  192. if(nType==0)
  193. GetDlgItem( IDC_STA_SHOW)->ShowWindow(true);
  194. switch (nType)
  195. {
  196. case 0:
  197. case 1:
  198. case 2:
  199. {
  200. //pComVar->ResetContent();
  201. CStringArray aAnalogName;
  202. pVariantsManager->GetAnalogNameArray(aAnalogName);
  203. int size = aAnalogName.GetSize();
  204. for ( int i = 0; i < size; i++)
  205. {
  206. pComVar->AddString(aAnalogName[i]);
  207. }
  208. if( m_strVariant=="" )
  209. pComVar->SetCurSel(0);
  210. pComVar->ShowWindow(SW_SHOW);
  211. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  212. pStatic->ShowWindow(SW_SHOW);
  213. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  214. pStatic1->ShowWindow(SW_HIDE);
  215. }
  216. break;
  217. case 3:
  218. {
  219. CStringArray picName, picPath;
  220. CSystemManager::GetPicNameArray(picName, picPath);
  221. int size = picName.GetSize();
  222. for ( int i = 0; i < size; i++)
  223. {
  224. int nPos = picPath[i].Find("\\\\");
  225. if( nPos!=-1 )
  226. {
  227. picPath[i].Delete( nPos );
  228. }
  229. int nLen = picPath[i].GetLength();
  230. nPos = picPath[i].Find("View");
  231. CString sTemp;
  232. if( nPos<nLen-5 )
  233. sTemp = picPath[i].Right( nLen-nPos-5 );
  234. //sTemp = sTemp+"\\"+picName[i];
  235. pComVar->AddString(sTemp);
  236. pComPath->AddString(picPath[i]);
  237. TRACE1("%s\r\n", picPath[i]);
  238. TRACE("%s\r\n", picName[i]);
  239. }
  240. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  241. pStatic->ShowWindow(SW_HIDE);
  242. }
  243. break;
  244. case 4:
  245. case 5:
  246. {
  247. pComVar->ShowWindow(SW_HIDE);
  248. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  249. pStatic->ShowWindow(SW_HIDE);
  250. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  251. pStatic1->ShowWindow(SW_HIDE);
  252. }
  253. break;
  254. case 6:
  255. {
  256. pComVar->ShowWindow(SW_HIDE);
  257. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  258. pStatic->ShowWindow(SW_HIDE);
  259. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  260. pStatic1->ShowWindow(SW_HIDE);
  261. }
  262. break;
  263. case 7: //
  264. case 8: //
  265. case 9: //
  266. case 10: //
  267. case 11: //
  268. case 12: //
  269. case 13: //
  270. case 14: //
  271. case 15: //
  272. {
  273. //pComVar->ShowWindow(SW_HIDE);
  274. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
  275. pStatic->ShowWindow(SW_HIDE);
  276. CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
  277. pStatic1->ShowWindow(SW_HIDE);
  278. pComVar->ShowWindow( SW_HIDE );
  279. }
  280. break;
  281. }
  282. UpdateData(TRUE);
  283. if( m_strVariant!="" )
  284. pComVar->SetWindowText(m_strVariant);
  285. if( m_strPicPath!="" )
  286. pComPath->SetWindowText(m_strPicPath);
  287. UpdateData(FALSE);
  288. return TRUE;
  289. }
  290. int CActionDlg::GetActionTypeNo(CString strType)
  291. {
  292. for ( int i = 0; i < 16; i++)
  293. {
  294. if (strType == m_arrayActionType[i])
  295. {
  296. return i;
  297. }
  298. }
  299. return -1;
  300. }
  301. void CActionDlg::ChangeCtrlInfo()
  302. {
  303. CComboBox* pComVar = (CComboBox*)GetDlgItem(IDC_VARIANTS);
  304. CComboBox* pComPath = (CComboBox*)GetDlgItem(IDC_PIC_PATH);
  305. CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
  306. int nType = pActionType->GetCurSel();
  307. int nIndex = pComVar->GetCurSel();
  308. switch (nType)
  309. {
  310. case 3:
  311. pComPath->SetCurSel(nIndex);
  312. break;
  313. }
  314. }
  315. void CActionDlg::OnBnClickedOk()
  316. {
  317. // TODO: 在此添加控件通知处理程序代码
  318. if( g_bHaveControlPwd==1 )
  319. {
  320. CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
  321. int nType = pActionType->GetCurSel();
  322. if( nType>=0 && nType<=2 )
  323. {
  324. CDlg_Pwd dlg(0);
  325. if( dlg.DoModal()!=IDOK )
  326. return;
  327. }
  328. }
  329. ChangeCtrlInfo();
  330. OnOK();
  331. }
  332. void CActionDlg::OnCbnSelendokVariants()
  333. {
  334. // TODO: 在此添加控件通知处理程序代码
  335. ChangeCtrlInfo();
  336. }