⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modifythemedlg.cpp

📁 mapx嵌入式插件
💻 CPP
字号:
// ModifyThemeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "ModifyThemeDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CModifyThemeDlg dialog


CModifyThemeDlg::CModifyThemeDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CModifyThemeDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CModifyThemeDlg)
	m_nSelTheme = -1;
	//}}AFX_DATA_INIT
}


void CModifyThemeDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CModifyThemeDlg)
	DDX_Control(pDX, IDC_THEMES, m_lbThemes);
	DDX_LBIndex(pDX, IDC_THEMES, m_nSelTheme);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CModifyThemeDlg, CDialog)
	//{{AFX_MSG_MAP(CModifyThemeDlg)
	ON_BN_CLICKED(IDC_MODIFY, OnModify)
	ON_BN_CLICKED(IDC_LEGEND, OnLegend)
	ON_LBN_DBLCLK(IDC_THEMES, OnDblclkThemes)
	ON_BN_CLICKED(IDC_REMOVE, OnRemove)
	ON_BN_CLICKED(IDC_REMOVEALL, OnRemoveall)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CModifyThemeDlg message handlers

void CModifyThemeDlg::OnOK() 
{
	// TODO: Add extra validation here
	
	CDialog::OnOK();
}

void CModifyThemeDlg::OnModify() 
{
	int nSel = m_lbThemes.GetCurSel();

	if (nSel < 0) return;

	long l = m_lbThemes.GetItemData(nSel);

	CMapXTheme thm = m_pMapX->GetDatasets().Item(LOWORD(l)).GetThemes().Item(HIWORD(l));
	thm.ThemeDlg();
}

void CModifyThemeDlg::OnLegend() 
{
	int nSel = m_lbThemes.GetCurSel();

	if (nSel < 0) return;

	long l = m_lbThemes.GetItemData(nSel);

	CMapXTheme thm = m_pMapX->GetDatasets().Item(LOWORD(l)).GetThemes().Item(HIWORD(l));
	thm.GetLegend().LegendDlg();
}

void CModifyThemeDlg::OnDblclkThemes() 
{
	OnModify();
}

void CModifyThemeDlg::FillListBox()
{
	int nSel = m_lbThemes.GetCurSel();
	int nThemeCount=0;

	if (nSel < 0) nSel = 0;

	m_lbThemes.ResetContent();

	int n = m_pMapX->GetDatasets().GetCount();

	for (int i=1; i <= n; i++) {
		TRY {
			CMapXDataset ds = m_pMapX->GetDatasets().Item(i);

			int nThemes = ds.GetThemes().GetCount();
			for (int j=1; j <= nThemes; j++) {
				CMapXTheme thm = ds.GetThemes().Item(j);
				CString strName = thm.GetName();
				int x = m_lbThemes.AddString(strName);
				m_lbThemes.SetItemData(x, MAKELONG(i,j));
				nThemeCount++;
			}
		}
		CATCH (COleDispatchException,e) {
			//e->Delete();
			continue;
		}
		AND_CATCH (COleException,e) {
			e->ReportError();
			//e->Delete();
			continue;
		}
		END_CATCH
	}
	if (nThemeCount) {
		if (nSel >= nThemeCount) {
			nSel = nThemeCount-1;
		}
		m_lbThemes.SetCurSel(nSel);
	}
}

BOOL CModifyThemeDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	if (!m_pMapX) return FALSE;

	FillListBox();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CModifyThemeDlg::OnRemove() 
{
	int nSel = m_lbThemes.GetCurSel();

	if (nSel < 0) return;

	long l = m_lbThemes.GetItemData(nSel);

	m_pMapX->GetDatasets().Item(LOWORD(l)).GetThemes().Remove(HIWORD(l));
	FillListBox();
}

void CModifyThemeDlg::OnRemoveall() 
{
	int n = m_pMapX->GetDatasets().GetCount();

	for (int i=1; i <= n; i++) {
		TRY {
			CMapXDataset ds = m_pMapX->GetDatasets().Item(i);
			ds.GetThemes().RemoveAll();
		}
		CATCH (COleDispatchException,e) {
			//e->Delete();
			continue;
		}
		AND_CATCH (COleException,e) {
			e->ReportError();
			//e->Delete();
			continue;
		}
		END_CATCH
	}
	FillListBox();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -