123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- // ActionDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "IDE.h"
- #include "ActionDlg.h"
- //#include "Afxcoll.h"
- //#include <io.h>
- #include "SystemManager.h"
- #include ".\actiondlg.h"
- #include "Dlg_Pwd.h"
- //
- //const CString actionType[] =
- //{
- // g_strControl, g_strSet, g_strAdjust, g_strPictureLink, g_strExit, g_strExLink
- //};
- /////////////////////////////////////////////////////////////////////////////
- // CActionDlg dialog
- CActionDlg::CActionDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CActionDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CActionDlg)
- m_strActionType = _T("");
- m_strActionValue = _T("");
- m_strVariant = _T("");
- m_strPicPath = _T("");
- m_arrayActionType[0] = g_strControl;
- m_arrayActionType[1] = g_strSet;
- m_arrayActionType[2] = g_strAdjust;
- m_arrayActionType[3] = g_strPictureLink;
- m_arrayActionType[4] = g_strExit;
- m_arrayActionType[5] = g_strExLink;
- m_arrayActionType[6] = g_strTestAlarm;
- m_arrayActionType[7] = g_strAlarmRed;
- m_arrayActionType[8] = g_strNoticeRed;
- m_arrayActionType[9] = g_strDeviceLog;
- m_arrayActionType[10] = g_strSystemLog;
- m_arrayActionType[11] = g_strVarManage;
- m_arrayActionType[12] = g_strUserManage;
- m_arrayActionType[13] = g_strPwdManage;
- m_arrayActionType[14] = g_strFirstPage;
- m_arrayActionType[15] = g_strNativageTree;
- //}}AFX_DATA_INIT
- }
- void CActionDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CActionDlg)
- DDX_CBString(pDX, IDC_ACTION_TYPE, m_strActionType);
- DDX_Text(pDX, IDC_ACTION_VALUE, m_strActionValue);
- DDX_CBString(pDX, IDC_VARIANTS, m_strVariant);
- DDX_CBString(pDX, IDC_PIC_PATH, m_strPicPath);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CActionDlg, CDialog)
- //{{AFX_MSG_MAP(CActionDlg)
- ON_CBN_SELCHANGE(IDC_ACTION_TYPE, OnSelchangeActionType)
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDOK, OnBnClickedOk)
- ON_CBN_SELENDOK(IDC_VARIANTS, OnCbnSelendokVariants)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CActionDlg message handlers
- void CActionDlg::OnSelchangeActionType()
- {
- // 根据不同操作类型,列变量列表
- CComboBox* pComType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
- CComboBox* pComVar = (CComboBox*)GetDlgItem(IDC_VARIANTS);
- CComboBox* pComPath = (CComboBox*)GetDlgItem(IDC_PIC_PATH);
- pComVar->ResetContent();
- pComPath->ResetContent();
- if( pComType->GetCurSel()==0 )
- GetDlgItem( IDC_STA_SHOW)->ShowWindow(true);
- else
- GetDlgItem( IDC_STA_SHOW)->ShowWindow(false);
-
- switch(pComType->GetCurSel())
- {
- case 0:
- case 1:
- case 2:
- {
- //pComVar->ResetContent();
- CStringArray aAnalogName;
- pVariantsManager->GetAnalogNameArray(aAnalogName);
- int size = aAnalogName.GetSize();
- for ( int i = 0; i < size; i++)
- {
- pComVar->AddString(aAnalogName[i]);
- }
- pComVar->SetCurSel(0);
- pComVar->ShowWindow(SW_SHOW);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_SHOW);
- CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic1->ShowWindow(SW_HIDE);
- }
- break;
- case 3: // 画面链接
- {
- //pComVar->ResetContent();
- //pComPath->ResetContent();
- CStringArray picName, picPath;
- CSystemManager::GetPicNameArray(picName, picPath);
- int size = picName.GetSize();
- for ( int i = 0; i < size; i++)
- {
- int nPos = picPath[i].Find("\\\\");
- if( nPos!=-1 )
- {
- picPath[i].Delete( nPos );
- }
-
- int nLen = picPath[i].GetLength();
- nPos = picPath[i].Find("View");
- CString sTemp;
- if( nPos<nLen-5 )
- sTemp = picPath[i].Right( nLen-nPos-5 );
- //sTemp = sTemp+"\\"+picName[i];
- pComVar->AddString(sTemp);
- pComPath->AddString(picPath[i]);
- TRACE1("%s\r\n", picPath[i]);
- }
- pComVar->SetCurSel(0);
- pComPath->SetCurSel(0);
- pComVar->ShowWindow(SW_SHOW);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic->ShowWindow(SW_SHOW);
- }
- break;
- case 4: // 组态
- case 5: // 退出
- {
- //pComVar->ShowWindow(SW_HIDE);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_HIDE);
- CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic1->ShowWindow(SW_HIDE);
- pComVar->ShowWindow( SW_HIDE );
- }
- case 6://外部链接
- {
- //pComVar->ShowWindow(SW_HIDE);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_HIDE);
- CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic1->ShowWindow(SW_HIDE);
- pComVar->ShowWindow( SW_HIDE );
- }
- break;
- case 7: //
- case 8: //
- case 9: //
- case 10: //
- case 11: //
- case 12: //
- case 13: //
- case 14: //
- case 15: //
- {
- //pComVar->ShowWindow(SW_HIDE);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_HIDE);
- CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic1->ShowWindow(SW_HIDE);
- pComVar->ShowWindow( SW_HIDE );
- }
- break;
- }
- }
- BOOL CActionDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
- pActionType->AddString( g_strControl );
- pActionType->AddString( g_strSet );
- pActionType->AddString( g_strAdjust );
- pActionType->AddString( g_strPictureLink );
- pActionType->AddString( g_strExit );
- pActionType->AddString( g_strExLink );
- pActionType->AddString( g_strTestAlarm);
- pActionType->AddString( g_strAlarmRed );
- pActionType->AddString( g_strNoticeRed );
- pActionType->AddString( g_strDeviceLog );
- pActionType->AddString( g_strSystemLog );
- pActionType->AddString( g_strVarManage );
- pActionType->AddString( g_strUserManage );
- pActionType->AddString( g_strPwdManage );
- pActionType->AddString( g_strFirstPage );
- pActionType->AddString( g_strNativageTree );
- CComboBox* pComVar = (CComboBox*)GetDlgItem(IDC_VARIANTS);
- CComboBox* pComPath = (CComboBox*)GetDlgItem(IDC_PIC_PATH);
- GetDlgItem( IDC_STA_SHOW)->ShowWindow(false);
- int nType = GetActionTypeNo(m_strActionType);
- if(nType==0)
- GetDlgItem( IDC_STA_SHOW)->ShowWindow(true);
- switch (nType)
- {
- case 0:
- case 1:
- case 2:
- {
- //pComVar->ResetContent();
- CStringArray aAnalogName;
- pVariantsManager->GetAnalogNameArray(aAnalogName);
- int size = aAnalogName.GetSize();
- for ( int i = 0; i < size; i++)
- {
- pComVar->AddString(aAnalogName[i]);
- }
- if( m_strVariant=="" )
- pComVar->SetCurSel(0);
- pComVar->ShowWindow(SW_SHOW);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_SHOW);
- CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic1->ShowWindow(SW_HIDE);
- }
- break;
- case 3:
- {
- CStringArray picName, picPath;
- CSystemManager::GetPicNameArray(picName, picPath);
- int size = picName.GetSize();
- for ( int i = 0; i < size; i++)
- {
- int nPos = picPath[i].Find("\\\\");
- if( nPos!=-1 )
- {
- picPath[i].Delete( nPos );
- }
-
- int nLen = picPath[i].GetLength();
- nPos = picPath[i].Find("View");
- CString sTemp;
- if( nPos<nLen-5 )
- sTemp = picPath[i].Right( nLen-nPos-5 );
- //sTemp = sTemp+"\\"+picName[i];
- pComVar->AddString(sTemp);
- pComPath->AddString(picPath[i]);
- TRACE1("%s\r\n", picPath[i]);
- TRACE("%s\r\n", picName[i]);
- }
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_HIDE);
- }
- break;
- case 4:
- case 5:
- {
- pComVar->ShowWindow(SW_HIDE);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_HIDE);
- CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic1->ShowWindow(SW_HIDE);
- }
- break;
- case 6:
- {
- pComVar->ShowWindow(SW_HIDE);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_HIDE);
- CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic1->ShowWindow(SW_HIDE);
- }
- break;
- case 7: //
- case 8: //
- case 9: //
- case 10: //
- case 11: //
- case 12: //
- case 13: //
- case 14: //
- case 15: //
- {
- //pComVar->ShowWindow(SW_HIDE);
- CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC22);
- pStatic->ShowWindow(SW_HIDE);
- CStatic* pStatic1 = (CStatic*)GetDlgItem(IDC_STATIC23);
- pStatic1->ShowWindow(SW_HIDE);
- pComVar->ShowWindow( SW_HIDE );
- }
- break;
- }
- UpdateData(TRUE);
- if( m_strVariant!="" )
- pComVar->SetWindowText(m_strVariant);
- if( m_strPicPath!="" )
- pComPath->SetWindowText(m_strPicPath);
- UpdateData(FALSE);
- return TRUE;
- }
- int CActionDlg::GetActionTypeNo(CString strType)
- {
- for ( int i = 0; i < 16; i++)
- {
- if (strType == m_arrayActionType[i])
- {
- return i;
- }
- }
- return -1;
- }
- void CActionDlg::ChangeCtrlInfo()
- {
- CComboBox* pComVar = (CComboBox*)GetDlgItem(IDC_VARIANTS);
- CComboBox* pComPath = (CComboBox*)GetDlgItem(IDC_PIC_PATH);
- CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
-
- int nType = pActionType->GetCurSel();
- int nIndex = pComVar->GetCurSel();
- switch (nType)
- {
- case 3:
- pComPath->SetCurSel(nIndex);
- break;
- }
- }
- void CActionDlg::OnBnClickedOk()
- {
- // TODO: 在此添加控件通知处理程序代码
- if( g_bHaveControlPwd==1 )
- {
- CComboBox* pActionType = (CComboBox*)GetDlgItem(IDC_ACTION_TYPE);
- int nType = pActionType->GetCurSel();
- if( nType>=0 && nType<=2 )
- {
- CDlg_Pwd dlg(0);
- if( dlg.DoModal()!=IDOK )
- return;
- }
- }
- ChangeCtrlInfo();
- OnOK();
- }
- void CActionDlg::OnCbnSelendokVariants()
- {
- // TODO: 在此添加控件通知处理程序代码
- ChangeCtrlInfo();
- }
|