📄 datalist.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesFile;
using ESRI.ArcGIS.DataSourcesRaster;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.esriSystem;
namespace EngineData
{
/// <summary>
/// DataList 的摘要说明。
/// </summary>
public class DataList : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.Windows.Forms.ToolBarButton toolBarButton4;
private System.Windows.Forms.ToolBarButton toolBarButton5;
private System.ComponentModel.IContainer components;
public string url;
public string filename;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ToolBarButton toolBarButton6;
public string conn;
//private IEnumDataset Datasets;
private IWorkspace ws;
private ESRI.ArcGIS.MapControl.AxMapControl mapControl;
private ArrayList Datasets;
private IDataset pDataset_;
public DataList(ESRI.ArcGIS.MapControl.AxMapControl mapControl,IWorkspace ws)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.mapControl = mapControl;
Datasets = new ArrayList();
this.ws = ws;
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(DataList));
this.label1 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.button5 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton5 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton6 = new System.Windows.Forms.ToolBarButton();
this.listView1 = new System.Windows.Forms.ListView();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 16);
this.label1.TabIndex = 1;
this.label1.Text = "选择连接:";
//
// comboBox1
//
this.comboBox1.Enabled = false;
this.comboBox1.Location = new System.Drawing.Point(72, 8);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(168, 20);
this.comboBox1.TabIndex = 2;
//
// button5
//
this.button5.Location = new System.Drawing.Point(288, 264);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(56, 23);
this.button5.TabIndex = 7;
this.button5.Text = "添加";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button6
//
this.button6.Location = new System.Drawing.Point(360, 264);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(56, 23);
this.button6.TabIndex = 8;
this.button6.Text = "取消";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.White;
//
// toolBar1
//
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton2,
this.toolBarButton5,
this.toolBarButton3,
this.toolBarButton4,
this.toolBarButton6});
this.toolBar1.Divider = false;
this.toolBar1.Dock = System.Windows.Forms.DockStyle.None;
this.toolBar1.DropDownArrows = true;
this.toolBar1.ImageList = this.imageList1;
this.toolBar1.Location = new System.Drawing.Point(248, 4);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(144, 26);
this.toolBar1.TabIndex = 9;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.ImageIndex = 5;
this.toolBarButton1.ToolTipText = "上一级";
//
// toolBarButton2
//
this.toolBarButton2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton5
//
this.toolBarButton5.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton3
//
this.toolBarButton3.ImageIndex = 7;
this.toolBarButton3.ToolTipText = "图标";
//
// toolBarButton4
//
this.toolBarButton4.ImageIndex = 6;
this.toolBarButton4.ToolTipText = "列表";
//
// toolBarButton6
//
this.toolBarButton6.ImageIndex = 8;
this.toolBarButton6.ToolTipText = "详细资料";
//
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.LargeImageList = this.imageList1;
this.listView1.Location = new System.Drawing.Point(8, 40);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(408, 216);
this.listView1.SmallImageList = this.imageList1;
this.listView1.TabIndex = 10;
this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown);
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
//
// DataList
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(426, 295);
this.Controls.Add(this.listView1);
this.Controls.Add(this.toolBar1);
this.Controls.Add(this.button6);
this.Controls.Add(this.button5);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "DataList";
this.Text = "添加数据";
this.Load += new System.EventHandler(this.DataList_Load);
this.ResumeLayout(false);
}
#endregion
private void button6_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void DataList_Load(object sender, System.EventArgs e)
{
if(this.url!="" && this.filename!="")
{
switch(this.conn)
{
case "SDE":
SDE_conn();
SDE_List();
break;
case "MDB":
MDB_List();
break;
}
}
else if(this.ws!=null)
{
SDE_List();
}
else
{
MessageBox.Show("没有设置连接属性!");
this.Close();
}
}
private void SDE_List()
{
this.listView1.Items.Clear();
listView1.Columns.Add("名称", 200, HorizontalAlignment.Left);
listView1.Columns.Add("类型", 150, HorizontalAlignment.Left);
listView1.View = View.Details;
IEnumDataset pDatasets = ws.get_Datasets(esriDatasetType.esriDTAny);
Datasets.Add(pDatasets);
GetDataList(pDatasets);
}
private void SDE_conn()
{
SdeConn aaa = new SdeConn();
aaa.ReadFromSDE(this.url+this.filename);
ws = aaa.GetCorkSpace();
}
private void MDB_List()
{
this.listView1.Items.Clear();
listView1.Columns.Add("名称", 200, HorizontalAlignment.Left);
listView1.Columns.Add("类型", 150, HorizontalAlignment.Left);
listView1.View = View.Details;
IWorkspaceFactory pWorkspaceFactory = null;
pWorkspaceFactory = new AccessWorkspaceFactoryClass();
ws = pWorkspaceFactory.OpenFromFile(url+filename,0);
IEnumDataset pDatasets = ws.get_Datasets(esriDatasetType.esriDTAny);
Datasets.Add(pDatasets);
GetDataList(pDatasets);
}
private void GetDataList(IEnumDataset pDatasets)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -