📄 poszonedlg.cpp
字号:
// PosZoneDlg.cpp : implementation file
//
#include "stdafx.h"
#include "gtmpeg.h"
#include "PosZoneDlg.h"
#include "MapDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CPosZoneDlg::CPosZoneDlg(int nIndex,CMapDlg* pParent /*=NULL*/)
: CDialog(CPosZoneDlg::IDD, (CWnd *)pParent)
{
//{{AFX_DATA_INIT(CPosZoneDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pParent=pParent;
m_nIndex=nIndex;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPosZoneDlg)
DDX_Control(pDX, IDC_NOT_BELONG_LIST, m_cNotBelongLst);
DDX_Control(pDX, IDC_BELONG_LIST, m_cBelongLst);
DDX_Control(pDX, IDC_CHUNNEL_BOX, m_cChunnelBox);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CPosZoneDlg, CDialog)
//{{AFX_MSG_MAP(CPosZoneDlg)
ON_LBN_DBLCLK(IDC_BELONG_LIST, OnDblclkBelongList)
ON_CBN_CLOSEUP(IDC_CHUNNEL_BOX, OnCloseupChunnelBox)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_LBN_DBLCLK(IDC_NOT_BELONG_LIST, OnDblclkNotBelongList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BOOL CPosZoneDlg::OnInitDialog()
{
CDialog::OnInitDialog();
int nChunnel=m_pParent->GetChunnel(m_nIndex);
for(int i=0;i<theApp.m_nChunnel;i++)
{
CString sTxt;
sTxt.Format("报警通道%d",i+1);
m_cChunnelBox.AddString(sTxt);
}
m_cChunnelBox.SetCurSel(nChunnel);
BuildBelongLst(m_nIndex);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::BuildBelongLst(int nIndex)
{
m_cBelongLst.ResetContent();
if(nIndex!=-1)
{
CUIntArray Zones;
m_pParent->GetPosZones(nIndex,Zones);
for(int i=0;i<Zones.GetSize();i++)
{
CString sTmp;
sTmp.Format("%d",Zones.GetAt(i));
m_cBelongLst.AddString(sTmp);
}
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::BuildNotBelongLst(int nIndex)
{
m_cNotBelongLst.ResetContent();
if(nIndex!=-1)
{
for(int i=0;i<16;i++)
{
CString sTmp1,sTmp2="";
BOOL bHave=FALSE;
sTmp1.Format("%d",i+1);
for(int j=0;j<m_cBelongLst.GetCount();j++)
{
m_cBelongLst.GetText(j,sTmp2);
if(sTmp2==sTmp1)
{
bHave=TRUE;
break;
}
}
if(!bHave)
{
m_cNotBelongLst.AddString(sTmp1);
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::OnDblclkBelongList()
{
OnDelete();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::OnCloseupChunnelBox()
{
int nIndex=m_cChunnelBox.GetCurSel();
int nChunnel=m_pParent->GetChunnel(m_nIndex);
if(nIndex!=nChunnel)
{
m_cBelongLst.ResetContent();
m_cNotBelongLst.ResetContent();
for(int i=0;i<16;i++)
{
CString sTmp;
sTmp.Format("%d",i+1);
m_cNotBelongLst.AddString(sTmp);
}
}
else
{
BuildBelongLst(m_nIndex);
BuildNotBelongLst(m_nIndex);
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::OnAdd()
{
int nIndex=m_cNotBelongLst.GetCurSel();
if(nIndex!=-1)
{
int nZone;
CString sTxt;
m_cNotBelongLst.GetText(nIndex,sTxt);
nZone=StringToInt(sTxt)-1;
m_cNotBelongLst.DeleteString(nIndex);
m_cBelongLst.AddString(sTxt);
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::OnDelete()
{
int nIndex=m_cBelongLst.GetCurSel();
if(nIndex!=-1)
{
CString sTxt;
m_cBelongLst.GetText(nIndex,sTxt);
m_cBelongLst.DeleteString(nIndex);
m_cNotBelongLst.AddString(sTxt);
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::OnDblclkNotBelongList()
{
OnAdd();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosZoneDlg::OnOK()
{
CUIntArray Zones;
Zones.SetSize(0);
for(int i=0;i<m_cBelongLst.GetCount();i++)
{
CString sTmp;
m_cBelongLst.GetText(i,sTmp);
Zones.Add(StringToInt(sTmp));
}
int nIndex=m_cChunnelBox.GetCurSel();
m_pParent->WritePosZones(m_nIndex,Zones);
m_pParent->WriteChunnel(m_nIndex,nIndex);
CDialog::OnOK();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -