📄 zonebelong.cpp
字号:
// ZoneBelong.cpp : implementation file
//
#include "stdafx.h"
#include "gtmpeg.h"
#include "gtmpegWnd.h"
#include "ZoneBelong.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CZoneBelong::CZoneBelong(CChunnel* pCurChunnel,CWnd* pParent /*=NULL*/)
: CDialog(CZoneBelong::IDD, pParent)
{
//{{AFX_DATA_INIT(CZoneBelong)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pCurChunnel=pCurChunnel;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZoneBelong)
DDX_Control(pDX, IDC_OPEN_ZONE, m_cOpenZone);
DDX_Control(pDX, IDC_NOT_BELONG_LIST, m_cNotBelongLst);
DDX_Control(pDX, IDC_BELONG_LIST, m_cBelongLst);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CZoneBelong, CDialog)
//{{AFX_MSG_MAP(CZoneBelong)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_LBN_DBLCLK(IDC_BELONG_LIST, OnDblclkBelongList)
ON_LBN_DBLCLK(IDC_NOT_BELONG_LIST, OnDblclkNotBelongList)
ON_CBN_CLOSEUP(IDC_OPEN_ZONE, OnCloseupOpenZone)
ON_BN_CLICKED(IDC_ZONE_INIT, OnZoneInit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BOOL CZoneBelong::OnInitDialog()
{
CDialog::OnInitDialog();
for(int i=0;i<16;i++)
{
CZone *pZone=m_pCurChunnel->GetZone(i);
if(pZone->m_nType==7)
{
CString sTmp;
sTmp.Format("%d",pZone->GetSort()+1);
m_cOpenZone.AddString(sTmp);
}
}
int nIndex=-1;
if(m_cOpenZone.GetCount()>0)
nIndex=0;
m_cOpenZone.SetCurSel(nIndex);
BuildBelongLst(nIndex);
BuildNotBelongLst(nIndex);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::BuildBelongLst(int nIndex)
{
int nZone;
m_cBelongLst.ResetContent();
if(nIndex==-1)
nZone=-1;
else
{
CString sTxt;
m_cOpenZone.GetLBText(nIndex,sTxt);
nZone=StringToInt(sTxt)-1;
CZone *pZone=m_pCurChunnel->GetZone(nZone);
for(int i=0;i<16;i++)
{
if(pZone->m_Zone[i]!=-1)
{
sTxt.Format("%d",pZone->m_Zone[i]+1);
m_cBelongLst.AddString(sTxt);
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::BuildNotBelongLst(int nIndex)
{
m_cNotBelongLst.ResetContent();
if(nIndex!=-1)
{
for(int i=0;i<16;i++)
{
CZone *pZone=m_pCurChunnel->GetZone(i);
if(pZone->m_nType!=7)
{
if(pZone->m_nBelong==-1)
{
CString sTxt;
sTxt.Format("%d",pZone->GetSort()+1);
m_cNotBelongLst.AddString(sTxt);
}
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::OnAdd()
{
int nIndex=m_cNotBelongLst.GetCurSel();
if(nIndex!=-1)
{
int nZone;
CString sTxt;
m_cNotBelongLst.GetText(nIndex,sTxt);
nZone=StringToInt(sTxt)-1;
CZone *pZone=m_pCurChunnel->GetZone(nZone);
CString sTmp;
m_cOpenZone.GetLBText(m_cOpenZone.GetCurSel(),sTmp);
int nOpenZone=StringToInt(sTmp)-1;
CZone *pOpenZone=m_pCurChunnel->GetZone(nOpenZone);
pZone->m_nBelong=pOpenZone->GetSort();
pOpenZone->m_Zone[pZone->GetSort()]=pZone->GetSort();
m_cNotBelongLst.DeleteString(nIndex);
m_cBelongLst.AddString(sTxt);
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::OnDelete()
{
int nIndex=m_cBelongLst.GetCurSel();
if(nIndex!=-1)
{
int nZone;
CString sTxt;
m_cBelongLst.GetText(nIndex,sTxt);
nZone=StringToInt(sTxt)-1;
CZone *pZone=m_pCurChunnel->GetZone(nZone);
pZone->m_nBelong=-1;
CString sTmp;
m_cOpenZone.GetLBText(m_cOpenZone.GetCurSel(),sTmp);
int nOpenZone=StringToInt(sTmp)-1;
CZone *pOpenZone=m_pCurChunnel->GetZone(nOpenZone);
pOpenZone->m_Zone[pZone->GetSort()]=-1;
m_cBelongLst.DeleteString(nIndex);
m_cNotBelongLst.AddString(sTxt);
}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::OnDblclkBelongList()
{
OnDelete();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::OnDblclkNotBelongList()
{
OnAdd();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::OnOK()
{
CDialog::OnOK();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::OnCloseupOpenZone()
{
CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
pWnd->SaveAlarmSet();
int nIndex=m_cOpenZone.GetCurSel();
BuildBelongLst(nIndex);
BuildNotBelongLst(nIndex);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CZoneBelong::OnZoneInit()
{
CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
pWnd->SaveAlarmSet();
CString sTxt;
int nIndex=m_cOpenZone.GetCurSel();
m_cOpenZone.GetLBText(nIndex,sTxt);
int nZone=StringToInt(sTxt)-1;
CZone *pOpenZone=m_pCurChunnel->GetZone(nZone);
//if(pOpenZone->GetZoneTxt()!="")
//{
if(pOpenZone->m_nType==7)
{
/*if(j==3)
{
if(pOpenZone->GetSort()==2||pOpenZone->GetSort()==5||pOpenZone->GetSort()==8)
pOpenZone->m_bStates2=FALSE;
}*/
NMHDR Msg;
Msg.hwndFrom=m_hWnd;
UINT uInfoID;
Msg.idFrom=IDC_ZONE_STATES_1+nZone;
uInfoID=_ALARM_ZONE_INFO;
Msg.code=m_pCurChunnel->m_nSort;
Msg.code<<=16;
Msg.code+=1;
pWnd->SendMessage(WM_NOTIFY,uInfoID,(LPARAM)&Msg);
pOpenZone->SetStates(TRUE);
}
//}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -