1. 程式人生 > >C#+ArcEngine:載入開啟 Tin 資料(VS2010窗體+程式碼)

C#+ArcEngine:載入開啟 Tin 資料(VS2010窗體+程式碼)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using ESRI.ArcGIS.Analyst3D;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesFile;


namespace 載入開啟Tin
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }


        private void 載入開啟TinToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog xjTinFolderBrowserDialog = new FolderBrowserDialog();
            if (xjTinFolderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                string xjTinPath = xjTinFolderBrowserDialog.SelectedPath;
                FileInfo xjFileInfo = new FileInfo(xjTinPath);


                IWorkspaceFactory xjTinWorkspaceFactory = new TinWorkspaceFactoryClass();//using ESRI.ArcGIS.Geodatabase;DataSourcesFile;
                ITinWorkspace xjTinWorkspace = xjTinWorkspaceFactory.OpenFromFile(xjFileInfo.DirectoryName, 0) as ITinWorkspace;
                if (xjTinWorkspaceFactory.IsWorkspace(xjFileInfo.DirectoryName))
                {
                    ITin xjTin = xjTinWorkspace.OpenTin(xjFileInfo.Name);
                    ITinLayer xjTinLayer = new TinLayerClass();
                    xjTinLayer.Dataset = xjTin;


                    ISceneGraph xjSceneGraph = this.axSceneControl1.SceneGraph;
                    IScene xjScene = xjSceneGraph.Scene;
                    xjScene.AddLayer(xjTinLayer as ILayer, true);
                }
            }
            this.axSceneControl1.SceneGraph.RefreshViewers();
        }
    }

}



VS2010+ArcEngine10.1具體窗體+程式碼見:點選開啟連結