ARCGIS合作伙伴开发培训之ArcENGINE资料 2

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Copyright©2004ESRI.Allrightsreserved.DevelopingApplicationswithArcGISEngineArcGISEngine应用开发基础2-2DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.课2目录‹ArcObjects库‹ArcObjectsEngineAPIs‹Engine应用程序开发‹许可2-3DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ArcGIS体系结构‹共享ArcObjects‹Engine包括了ArcObjects的核心功能ArcGISDesktopArcGISEngineArcGISServer2-4DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ArcGIS库‹共享AO库‹有些库不可以共享‹如:esriArcMapUI‹识别属于不同产品的库‹理解库的从属关系‹开发工具‹ArcGISDeveloperHelp‹ESRIAutomaticReferenceadd-in2-5DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ArcGISEngine类库体系结构2-6DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ArcObjects‹由ArcObjects组成的‹ArcObjects是C++对象‹通过不同的APIs来访问‹本地接口是COM2-7DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.Component(Map.dll)ClientArcMapCOM‹软件模块之间连接的协议‹跨语言‹二进制规范‹使用接口和组件来设计模型‹客户调用服务器并等待服务器的响应‹所有的通信都是通过接口来进行2-8DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ArcObjects和COMAPI‹所有ArcObjectsCOM类型都在类型库中定义‹类型库是二进制的文件,描述:‹Classes:CLSIDs和ProgIDs‹Interfaces:IIDs‹Constants和enumerations‹接口的实现在DLL和EXE文件‹开发者工具‹ArcGISDeveloperHelp(VB6或VC++)‹LibraryLocator,EOBrowserandOleView*ArcObjectsC++*.dllfiles*COMTypeLibraries*.olbfiles2-9DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.COMclasses‹COM类实现接口‹所有类都实现Iunknown接口‹管理对象生命周期‹成员:QueryInterface,AddRef和Release‹Coclasses是可创建的PublicSubmapName()DimpMapAsIMap'YoucancreateanewinstanceofacoclassSetpMap=NewMapEndSubPublicSubmapName()DimpMapAsIMap'YoucancreateanewinstanceofacoclassSetpMap=NewMapEndSubIUnknown2-10DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.COM接口‹定义了函数和属性的一个逻辑组‹从IUnknown(默认)继承‹ArcObjects支持‹自定义interfaces‹通过QueryInterface(QI)来访问接口PublicSubmapName()DimpMapAsIMapSetpMap=NewMap'YouhaveaccesstopropertiesandmethodsofIMapthroughpMapMsgBoxpMap.NameEndSubPublicSubmapName()DimpMapAsIMapSetpMap=NewMap'YouhaveaccesstopropertiesandmethodsofIMapthroughpMapMsgBoxpMap.NameEndSub2-11DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.COM出接口‹提供了一种激活客户端事件的途径‹连接到一个对象并接收它的出接口‹在ArcObjects中可获得多级别的事件‹例如:documentloadevents,mapdrawingevents,editingevents,…PrivateWithEventsMxDocEventsAsMxDocumentPrivateSubsetNewValues()...SetMxDocEvents=pMxDoc'NowcanaccesseventsEndSubPrivateFunctionMxDocEvents_NewDocument()AsBooleanMsgBoxNewArcMapdocumentEndFunctionPrivateWithEventsMxDocEventsAsMxDocumentPrivateSubsetNewValues()...SetMxDocEvents=pMxDoc'NowcanaccesseventsEndSubPrivateFunctionMxDocEvents_NewDocument()AsBooleanMsgBoxNewArcMapdocumentEndFunction2-12DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.其它‹类型库包括了所有COM类型‹每一个类型有一个全球唯一标识符(GUID)‹CLSID,IID,Progid,…‹esriSystem.UID表示对象的GUID(例子代码)‹指定CLSID或ProgID(ProjectName.ClassName)DimuAsNewUIDu.Value={4FDD8858-DF31-4D6B-8679-1FED633262DA}'CLSIDofControlsMapRotateToolDimuAsNewUIDu.Value=esriControlCommands.ControlsMapRotateTool“'ProgIDofControlsMapRotateToolDimuAsNewUIDu.Value={4FDD8858-DF31-4D6B-8679-1FED633262DA}'CLSIDofControlsMapRotateToolDimuAsNewUIDu.Value=esriControlCommands.ControlsMapRotateTool“'ProgIDofControlsMapRotateToolDimcommandAsICommandcommand=AxToolbarControl1.CommandPool.FindByUID(u)IfNotcommandIsNothingThenMsgBox(command.Name)EndIfDimcommandAsICommandcommand=AxToolbarControl1.CommandPool.FindByUID(u)IfNotcommandIsNothingThenMsgBox(command.Name)EndIf2-13DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ArcObjects和.NETAPI‹所有ArcObjects类型在.NETassemblies(汇编集)中定义‹PrimaryInteropAssemblies(主互操作程序集)在导入COM类库后产生‹PIA暴露所有的类,接口和常量,作为.NET托管类‹需要.NETFramework1.1‹开发工具‹ArcGISDeveloperHelp(.NET)‹ILDASM.exeArcObjectsC++COMTypeLibraries.NETAssembliesInterop2-14DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ArcGIS.NETassemblies和namespaces‹所有.NET工程必须引用ESRIassemblies‹Example:ESRI.ArcGIS.Carto.dll‹导入命名空间来访问ArcObjects.NET类型‹Example:ESRI.ArcGIS.Carto‹Assemblies有从属...ImportsESRI.ArcGIS.CatalogUIImportsESRI.ArcGIS.ArcMapUIImportsESRI.ArcGIS.Framework......ImportsESRI.ArcGIS.CatalogUIImportsESRI.ArcGIS.ArcMapUIImportsESRI.ArcGIS.Framework...2-15DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved..NET类‹.NET托管类代表ArcObjects对象‹有两种类型‹COMobjectName”Class”:在类中实现所有的接口和成员函数‹COMobjectName:代表真正的ArcObjects对象‹创建类实例化真正的COM对象DimmapasMapClassmap=NewMapClass()map.Extent=envelopeDimmapasMapClassmap=NewMapClass()map.Extent=envelope2-16DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved..NET接口‹.NET接口代表ArcObjects接口‹QueryInterface的不同技巧‹Implicitcasting(常用)‹Explicitcasting(语法复杂且易丢失数据,不常用)‹VB.NET中使用TypeOf以避免处理ImplicitCasting带来的InvalidCastException异常(C#中通常使用as符)geometry=point‘Implicitcastgeometry=CType(point,IGeometry)‘Explicitcastgeometry=point‘Implicitcastgeometry=CType(point,IGeometry)‘ExplicitcastDimpointAsNewPointClassDimgeometryAsIGeometryIf(TypeOfpointIsIGeometry)Thengeometry=pointEndIfDimpoint

1 / 34
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功