关闭

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

标签: ArcGISc#esri
1116人阅读 评论(0) 收藏 举报
分类:

闲话少说直接将源码贴出

 

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);//取消锁定

        }

 

    }

}

 

加载前:

 

加载后:

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:418503次
    • 积分:7005
    • 等级:
    • 排名:第3450名
    • 原创:292篇
    • 转载:3篇
    • 译文:1篇
    • 评论:36条
    最新评论