private void btnOK_Click(object sender, EventArgs e)
{
try
{
CheckError();
this.checkEdit1.Enabled = false;
checkEdit1.Checked = false;
this.Cursor = Cursors.WaitCursor; IGeoProcessorResult result = null;
ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new Geoprocessor();
gp.OverwriteOutput = true;
if (btnEdit1.Text.Contains(".shp"))
{
if (File.Exists(btnEdit3.Text))
{
if (MessageBox.Show("文件已存在,是否删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
IWorkspaceFactory pwsf = new ShapefileWorkspaceFactoryClass();
IWorkspace pws = pwsf.OpenFromFile(System.IO.Path.GetDirectoryName(btnEdit3.Text), );
App_CORE.EngineAPI.WorkspaceFunction.DeleteDataset1(pws, System.IO.Path.GetFileName(btnEdit3.Text), "featureclass");
}
else
{
btnEdit3.Text = "";
this.Cursor = Cursors.Default;
return;
}
}
ESRI.ArcGIS.DataManagementTools.Project pPro = new ESRI.ArcGIS.DataManagementTools.Project();
pPro.in_dataset = btnEdit1.Text;
pPro.in_coor_system = this.importSR;
pPro.out_dataset = btnEdit3.Text;
pPro.out_coor_system = this.exportSR;
pPro.transform_method = comboBoxEdit1.Text;
result = (IGeoProcessorResult)gp.Execute(pPro, null);
}
else
{
if (File.Exists(btnEdit3.Text))
{
if (XtraMessageBox.Show("文件已存在,是否删除", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
IWorkspaceFactory pwsf = new RasterWorkspaceFactoryClass();
IWorkspace pws = pwsf.OpenFromFile(System.IO.Path.GetDirectoryName(btnEdit3.Text), );
App_CORE.EngineAPI.WorkspaceFunction.DeleteDataset(pws, System.IO.Path.GetFileName(btnEdit3.Text), "RasterDataset");
}
else
{
btnEdit3.Text = "";
this.Cursor = Cursors.Default;
return;
}
} ProjectRaster pProject = new ProjectRaster();
pProject.in_raster = btnEdit1.Text;
pProject.in_coor_system = this.importSR;
pProject.out_raster = btnEdit3.Text;
pProject.out_coor_system = this.exportSR;
pProject.geographic_transform = comboBoxEdit1.Text;
result = (IGeoProcessorResult)gp.Execute(pProject, null);
} this.Cursor = Cursors.Default;
if (result == null)
{
string xx = "";
for (int i = ; i < gp.MessageCount; i++)
xx += gp.GetMessage(i);
XtraMessageBox.Show("投影转换失败,原因为:" + xx, "提示");
return;
}
ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(result);
ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown();
System.Runtime.InteropServices.Marshal.ReleaseComObject(result);
result = null;
XtraMessageBox.Show("成功", "提示");
this.checkEdit1.Enabled = true; }
catch (Exception ex)
{
this.Cursor = Cursors.Default;
MessageBox.Show(ex.Message, "提示");
}
}