import2gdatasetdlg.cpp

来自「用VC+SuperMap开发的校园GIS系统」· C++ 代码 · 共 146 行

CPP
146
字号
// Import2GDatasetDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CampusGis.h"
#include "Import2GDatasetDlg.h"
#include "sodatasources.h"
#include "sodatasource.h"
#include "sodatapump.h"
#include "soimportparams.h"

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

/////////////////////////////////////////////////////////////////////////////
// CImport2GDatasetDlg dialog


CImport2GDatasetDlg::CImport2GDatasetDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CImport2GDatasetDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CImport2GDatasetDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CImport2GDatasetDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CImport2GDatasetDlg)
	DDX_Control(pDX, IDOK, m_Ok);
	DDX_Control(pDX, IDC_EDITLAYERNAME, m_editLayerName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CImport2GDatasetDlg, CDialog)
	//{{AFX_MSG_MAP(CImport2GDatasetDlg)
	ON_EN_CHANGE(IDC_EDITLAYERNAME, OnChangeEditLayerName)
	ON_BN_CLICKED(IDBACK, OnBack)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CImport2GDatasetDlg message handlers

void CImport2GDatasetDlg::OnChangeEditLayerName() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	//判断是否存在图层名称
	m_editLayerName.GetWindowText(m_strLayerName);
	if(!m_strLayerName.GetLength())
		m_Ok.EnableWindow(FALSE);
	else
		m_Ok.EnableWindow(TRUE);
}

BOOL CImport2GDatasetDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//初始化变量
	m_bShowProgress=FALSE;

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
CMainFrame* CImport2GDatasetDlg::GetMainFramePointer()
{
	CMainFrame *pFrame=(CMainFrame *)::AfxGetMainWnd();
	return pFrame;
}
void CImport2GDatasetDlg::OnBack() 
{
	//上一步
	CDialog::OnCancel();	
	GetMainFramePointer()->ImportDataset();	
}

void CImport2GDatasetDlg::OnOK() 
{
	//完成
	CsoDataSource objDs;
	BOOL bResult;

	objDs=GetMainFramePointer()->m_SuperWorkspace.GetDatasources().GetItem(COleVariant(m_strDatasourceName));
	if(!objDs)
	{
		AfxMessageBox("数据源"+m_strDatasourceName+"内部错误,无法继续!");
		return;
	}
	CsoDataPump objDp;
	objDp=objDs.GetDataPump();
	if(!objDp)
	{
		AfxMessageBox("DataPump内部错误,无法继续!");
		objDs.ReleaseDispatch();
		return;
	}
	objDp.GetDataImportParams().SetFileName(m_strPathName);
	objDp.GetDataImportParams().SetDatasetImage(m_strLayerName);
	objDp.GetDataImportParams().SetShowProgress(m_bShowProgress);
	switch(m_nFileTypeIndex)
	{
		case 0://Bmp 图像文件 (*.bmp)|*.BMP;*.bmp
			objDp.GetDataImportParams().SetFileType(104/*scfBMP*/);break;
		case 1://GRID 图像文件 (*.grd)|*.GRD;*.grd
			objDp.GetDataImportParams().SetFileType(200/*scfGRD*/);break;
		case 2://JPG 图像文件 (*.jpg)|*.JPG;*.jpg
			objDp.GetDataImportParams().SetFileType(105/*scfJPG*/);break;
		case 3://MrSid 图像文件 (*.sid)|*.SID;*.sid
			objDp.GetDataImportParams().SetFileType(102/*scfSID*/);break;
		case 4://WMF 图像文件 (*.wmf)|*.WMF;*.wmf
			objDp.GetDataImportParams().SetFileType(36/*scfWMF*/); break;
		case 5://Idrisi 栅格文件(*.img)|*.IMG;*.img;*.Img
			objDp.GetDataImportParams().SetFileType(21/*scfVEC*/); break;
		case 6://Erdas 影像文件(*.img)|*.IMG;*.img;*.Img
			objDp.GetDataImportParams().SetFileType(101/*scfIMG*/);break;
		case 7://TIF文件(*.tif)|*.tif
			objDp.GetDataImportParams().SetFileType(103/*scfTIF*/);break;
		case 8://ECW格式文件|*.ecw
			objDp.GetDataImportParams().SetFileType(106/*scfECW*/);break;
	}
	bResult=objDp.Import();
	if(bResult)
	{
		GetMainFramePointer()->GetManager()->Refresh();
		AfxMessageBox("转入成功!");
	}
	else
		AfxMessageBox("转入失败!");
	objDs.ReleaseDispatch();
	objDp.ReleaseDispatch();

	CDialog::OnOK();
}


⌨️ 快捷键说明

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