📄 diezhifenxi.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.DataSourcesOleDB;
namespace WindowsApplication1
{
public partial class diezhifenxi : Form
{
public int Input = 0;
public int Over = 1;
AxMapControl axMapControl1;
AxMapControl axMapControl2;
AxTOCControl axTOCControl1;
public int OverType = 1;
public diezhifenxi(AxMapControl axMapControl_1,AxMapControl axMapcontrol_2, AxTOCControl axTOCControl,int k )
{
axMapControl1 = axMapControl_1;
axMapControl2 = axMapcontrol_2;
axTOCControl1 = axTOCControl;
OverType = k;
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void diezhifenxi_Load(object sender, EventArgs e)
{
comboBox1.Items.Clear();
for (int i = 0; i < axMapControl1.LayerCount; i++)
comboBox1.Items.Add(axMapControl1.get_Layer(i).Name);
comboBox1.Text = comboBox1.Items[0].ToString();
comboBox2.Items.Clear();
for (int i = 0; i < axMapControl1.LayerCount; i++)
comboBox2.Items.Add(axMapControl1.get_Layer(i).Name);
comboBox2.Text = comboBox2.Items[0].ToString();
}
private void button1_Click(object sender, EventArgs e)
{
//if(comboBox1.Text.ToString().Equals(""))
Input = comboBox1.SelectedIndex;
Over = comboBox2.SelectedIndex;
try
{
Over_analysis(OverType);
}
catch (Exception)
{
MessageBox.Show("叠置发生错误!");
return;
}
}
private void Over_analysis(int k)
{
//axTOCControl1.SetBuddyControl(null);
//叠置 pGeoprocessor = new 叠置();
//pGeoprocessor.pMap = axMapControl1.Map;
//pGeoprocessor.ShowDialog();
//if (pGeoprocessor.Enable == false) return;
//int k = pGeoprocessor.k;
//int input = pGeoprocessor.input;
//int over = pGeoprocessor.over;
ILayer pLayer;
ITable pInputTable;
ITable pOverlayTable;
IFeatureClassName pFeatClassName;
IWorkspaceName pNewWSName;
IDatasetName pDatasetName;
Double dtol;
IBasicGeoprocessor pBasicGeop;
IFeatureClass pOutputFeatClass;
IFeatureLayer pOutputFeatLayer;
pLayer = axMapControl1.get_Layer(Input);
pInputTable = (ITable)pLayer;
pLayer = axMapControl1.get_Layer(Over);
pOverlayTable = (ITable)pLayer;
if (pInputTable == null || pOverlayTable == null)
{
MessageBox.Show("Failure!!");
return;
}
pFeatClassName = new FeatureClassNameClass();
pNewWSName = new WorkspaceNameClass();
pNewWSName.WorkspaceFactoryProgID = "esriCore.ShapeFileWorkspaceFactory.1";
pNewWSName.PathName = Environment.CurrentDirectory;
pDatasetName = (IDatasetName)pFeatClassName;
//pDatasetName.Name = pGeoprocessor.FileName;
pDatasetName.WorkspaceName = pNewWSName;
dtol = 0;
pBasicGeop = new BasicGeoprocessorClass();
switch (k)
{
case 1://求交
pOutputFeatClass = pBasicGeop.Intersect(pInputTable, false, pOverlayTable, false, dtol, pFeatClassName);
pOutputFeatLayer = new FeatureLayerClass();
pOutputFeatLayer.FeatureClass = pOutputFeatClass;
//pOutputFeatLayer.Name = pOutputFeatClass.AliasName;
pOutputFeatLayer.Name = "Result_Interset";
axMapControl1.AddLayer(pOutputFeatLayer);
axMapControl2.AddLayer(pOutputFeatLayer);
axTOCControl1.SetBuddyControl(axMapControl1);
break;
case 2://求和
pOutputFeatClass = pBasicGeop.Union(pInputTable, false, pOverlayTable, false, dtol, pFeatClassName);
pOutputFeatLayer = new FeatureLayerClass();
pOutputFeatLayer.FeatureClass = pOutputFeatClass;
//pOutputFeatLayer.Name = pOutputFeatClass.AliasName;
pOutputFeatLayer.Name = "Result_Union";
axMapControl1.AddLayer(pOutputFeatLayer);
axMapControl2.AddLayer(pOutputFeatLayer);
axTOCControl1.SetBuddyControl(axMapControl1);
break;
case 3://裁减
pOutputFeatClass = pBasicGeop.Clip(pInputTable, false, pOverlayTable, false, dtol, pFeatClassName);
pOutputFeatLayer = new FeatureLayerClass();
pOutputFeatLayer.FeatureClass = pOutputFeatClass;
//pOutputFeatLayer.Name = pOutputFeatClass.AliasName;
pOutputFeatLayer.Name = "Result_Clip";
axMapControl1.AddLayer(pOutputFeatLayer);
axMapControl2.AddLayer(pOutputFeatLayer);
axTOCControl1.SetBuddyControl(axMapControl1);
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -