156 lines
3.2 KiB
C++
156 lines
3.2 KiB
C++
// GoalLayerDlg.cpp :implementation file
|
|
#include "stdafx.h"
|
|
#include "GoalLayerDlg.h"
|
|
#include "Resource.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
// 创建层名为csCurLayer的新图层
|
|
void CreateLayer(const CString &csCurLayer);
|
|
|
|
// 获得层表管理器的记录,add xly 100617
|
|
void GetLayerDes(CStringArray &curLayerNameAry, CStringArray &layerCon);
|
|
|
|
|
|
CGoalLayerDlg::CGoalLayerDlg(CWnd* pParent /*=NULL*/)
|
|
: GlwCAcUiDialog(CGoalLayerDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CGoalLayerDlg)
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
CGoalLayerDlg::~CGoalLayerDlg()
|
|
{
|
|
}
|
|
|
|
void CGoalLayerDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CGoalLayerDlg)
|
|
DDX_Text(pDX, IDC_EDT_GOALLAY, m_csGoaleLayer);
|
|
DDX_Control(pDX, IDC_LST_ALLLAYER, m_wndLstLayerAll);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CGoalLayerDlg, GlwCAcUiDialog)
|
|
ON_BN_CLICKED(IDC_OK, OnOK)
|
|
ON_NOTIFY(NM_CLICK, IDC_LST_ALLLAYER, OnClickListLayer)
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CGoalLayerDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// 获得本图中的所有图层名称以及描述
|
|
GetAllLayerNames();
|
|
|
|
// 初始化表格数据
|
|
CRect rect;
|
|
m_wndLstLayerAll.GetWindowRect(rect);
|
|
m_wndLstLayerAll.InsertColumn(0, _T("层名"), LVCFMT_LEFT, rect.Width()/2);
|
|
m_wndLstLayerAll.InsertColumn(1, _T("描述"), LVCFMT_LEFT, rect.Width()*3/8);
|
|
|
|
// 初始化列表框
|
|
int nSize1 = (int)m_csAryLayerAll.GetSize(),
|
|
nSize2 = (int)m_csAryDec.GetSize();
|
|
for (int i = 0; i< nSize1; i++)
|
|
{
|
|
// 添加第一列层名
|
|
m_wndLstLayerAll.InsertItem(i, m_csAryLayerAll[i]);
|
|
|
|
// 查找该层名是否有图层描述
|
|
for (int j = 0; j<nSize2; j++)
|
|
{
|
|
if (m_csAryLayerAll[i] == m_csAryDec[j]) // 层名有描述
|
|
{
|
|
m_wndLstLayerAll.SetItemText(i, 1, m_csAryDec[j-1]);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 初始化编辑框的内容
|
|
m_csGoaleLayer = m_csAryLayerAll[0];
|
|
|
|
UpdateData(false);
|
|
return TRUE;
|
|
}
|
|
|
|
// 获得本图中的所有图层名称以及描述
|
|
void CGoalLayerDlg::GetAllLayerNames()
|
|
{
|
|
// 遍历图中的层表去掉外部参照部分的层
|
|
XSymbolList lstLayer(_T("LAYER"));
|
|
|
|
for (long l = 0; l<lstLayer.Length(); l++)
|
|
{
|
|
CString csName = lstLayer[l];
|
|
if ((csName.Find(_T('|')) == -1) && (csName.Find(_T('$')) == -1))
|
|
{
|
|
m_csAryLayerAll.Add(lstLayer[l]);
|
|
}
|
|
}
|
|
|
|
// 遍历图层管理获得图层的描述
|
|
GetLayerDes(m_csAryLayerAll, m_csAryDec);
|
|
}
|
|
|
|
// 确定按钮
|
|
void CGoalLayerDlg::OnOK()
|
|
{
|
|
UpdateData(TRUE);
|
|
// 遍历数组,查看编辑框中的层名是否存在
|
|
bool bHasLayer = false;
|
|
|
|
int nSize = (int)m_csAryLayerAll.GetSize();
|
|
for (int i = 0; i< nSize; i++)
|
|
{
|
|
if (m_csGoaleLayer == m_csAryLayerAll[i]) // 存在图层
|
|
{
|
|
bHasLayer = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!bHasLayer) // 不存在图层
|
|
{
|
|
// 询问用户是否创建图层
|
|
if (AfxMessageBox(_T("图层不存在,是否创建?"), MB_YESNO) == IDYES)
|
|
{
|
|
// 创建图层函数
|
|
CreateLayer(m_csGoaleLayer);
|
|
}
|
|
else
|
|
return;
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
// 获得目标图层
|
|
CString CGoalLayerDlg::GetGoalLayer()
|
|
{
|
|
return m_csGoaleLayer;
|
|
}
|
|
|
|
// 选择列表框事件
|
|
void CGoalLayerDlg::OnClickListLayer(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
UpdateData(true);
|
|
|
|
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
|
|
|
// 当前所选项的索引号
|
|
int iItem = pNMListView->iItem;
|
|
CString csCurSel = m_wndLstLayerAll.GetItemText(iItem, 0);
|
|
|
|
// 设置编辑框中的内容
|
|
m_csGoaleLayer = csCurSel;
|
|
|
|
UpdateData(false);
|
|
*pResult = 0;
|
|
} |