GIS大奔

enjoyGIS

AE+C#通过多线程向GlobeControl中增加图层

闲话少说直接将源码贴出

 

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.Diagnostics;

using System.Threading;

using System.Collections;

using ESRI.ArcGIS.Carto;

using ESRI.ArcGIS.Analyst3D;

using ESRI.ArcGIS.Controls;

using ESRI.ArcGIS.GlobeCore;

 

namespaceWindowsFormsApplication2

{

    publicpartialclassForm1 : Form

    {

        // 声明新的进程

        privateThread _thread;

        // 声明图层文件

        privateILayerFile _layerFile;

        // 声明进程完成时候的数据

        privateeventEventHandler OnNumberClear;

 

        public Form1()

        {

           InitializeComponent();

 

 

        }

       

        //执行完成之后,停止所有线程

        void ThreadDemo_OnNumberClear(object sender, EventArgs e)

        {

           _thread.Abort();

 

        }

 

        privatevoid btnAdd_Click(object sender, EventArgs e)

        {

            _layerFile= newLayerFileClass();

            _thread = newThread(newThreadStart(addLayer));

 

           OnNumberClear += newEventHandler(ThreadDemo_OnNumberClear);

 

           addLayerStart();

        }

        ///<summary>

        ///进程开始

        ///</summary>

        privatevoid addLayerStart()

        {

           _thread.Start();

        }

        ///<summary>

        ///进程执行的内容

        ///</summary>

        privatevoid addLayer()

        {

            //Monitor.Enter(this);//锁定,保持同步

            string sFile = @"D:\CCCache\GlobeCache\Buildings_1CE1FE05-D138-4361-8C50-E3EB26B02858\cache.lyr";

           _layerFile.Open(sFile);

            ILayer pLayer = _layerFile.Layer;

 

            IGlobeControl pGlobeControl =globeCtrl.Object asIGlobeControl;

            IGlobeDisplayLayers2pGlobeDisplayLayers2 = pGlobeControl.GlobeDisplay asIGlobeDisplayLayers2;

           pLayer.Visible = true;

            // 加载图层到globeCtrl

           pGlobeDisplayLayers2.AddLayer(pLayer);

            //globeCtrl.GlobeDisplay.Scene.AddLayer(pLayer);

            //globeCtrl.GlobeCamera.SetToZoomToExtents(pLayer.AreaOfInterest,globeCtrl.Globe,globeCtrl.GlobeVieweras ISceneViewer);

 

           OnNumberClear(this,newEventArgs());//引发完成事件

            //Monitor.Exit(this);//取消锁定

        }

 

    }

}

 

加载前:

 

加载后:

阅读更多
文章标签: ArcGIS c# esri
个人分类: 本地开发
上一篇AE+C#控制影像数据的清晰度和高程数据的平滑度
下一篇C#+ArcEngine:设置矢量图层的透明度
想对作者说点什么? 我来说一句

Globe

LandSim3D viewterra

hayaqi0504 hayaqi0504

2016-03-17 11:09:09

阅读数:257

没有更多推荐了,返回首页

关闭
关闭