您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > ArcMap扩展开发指南(英文版)
269IllustratedcodesamplesCTheillustratedcodesamplesinthisappendixshowthefundamentalsofprogrammingwithArcObjects.Eachsampleisaccompaniedbyillustrationsoftheassociatedobjectsandtheirrelationships.ThecodecanbetypedorcopiedintoVBA,afterwhichyoucanfollowthroughwiththeVBAdebugger.AppendixC-ics.pmd1/26/2005,7:12AM269270•ArcGISDesktopDeveloperGuideITransform2DIBoundsPropertiesICloneIElementIElementPropertiesIPersistIPersistStreamIPropertySupportIElementProperties2Theobjectmodeldiagramsrevealastructurenotevidentinstandardobjectbrowsers.Shownhereisanabstractclass,Element,withnineinterfaces.TheIElementinterfaceisshownbecauseacodesamplemadeacalltoit.ReadingtheillustratedcodesamplesTheillustratedcodesamplesinthissectionshowyouthefundamentalsofprogrammingwithCOMcomponentsinArcObjects.StartbyenteringtheVBAenvironmentinArcMaporArcCatalogandtypeinthecode.StepthroughthecodeintheVBAdebugger.Lookatthesepagesandstudytherelationshipsbetweencoclassesandinterfaces.AcarefulreadingofthesamplesinthissectiongivesyoualltheimportantconceptsyouneedfordevelopingwithArcObjects,aswellasanintroductiontothemostimportantArcObjectscomponents.TheinterfaceTypeinheritanceInterfaceinheritanceAninterfaceisaspecificationofpropertiesandmethods.Manycoclassescanimplementthesameinterface.Interfacesallowahighdegreeofinteroperabilityandsharedbehavioramongasetofobjects.AreaFieldisareturnpropertyoftypeIField.FeatureClassIDisoftypelong.TheCreateFeaturemethodcreatesanobjectoftypeIFeature.FeatureCounttakesinaqueryfilterandreturnsalong.IFeatureClass:IObjectClassAreaField:IFieldFeatureClassID:LongFeatureDataset:IFeatureDatasetFeatureType:esriFeatureTypeLengthField:IFieldShapeFieldName:StringCreateFeature:IFeatureCreateFeatureBuffer:IFeatureBufferFeatureCount(inQueryFilter:IQueryFilter):LongGetFeature(inID:Long):IFeatureGetFeatures(infids:Variant,inRecycling:Boolean):IFeatureCursorInsert(inuseBuffering:Boolean):IFeatureCursorSearch(inFilter:IQueryFilter,inRecycling:Boolean):IFeatureCursorSelect(inQueryFilter:IQueryFilter,inselType:esriSelectionType,inselOption:esriSelectionOption,inselectionContainer:IWorkspace):ISelectionSetUpdate(inFilter:IQueryFilter,inRecycling:Boolean):IFeatureCursorShapeType:tagesriGeometryTypeAGraphicElementisanabstractclassthatspecifiestheoneinterfaceshownhereaswellasthenineinterfacesontheElementabstractclass.TextElementisacoclassthatimplementsfiveinterfacesinadditiontotheonefromGraphicElementandninefromElement.IGraphicElementGraphic-ElementIElementEditVerticesIGroupSymbolElementITextElementITransformEventsTextElementIElementEditCalloutITextElement:IUnknownScaleText:BooleanSymbol:ITextSymbolText:StringElementIElement:IUnknownLocked:BooleanSelectionTracker:ISelectionTrackerActivate(inDisplay:IDisplay)DeactivateDraw(inDisplay:IDisplay,intrackCancel:ITrackCancel)HitTest(inX:Double,inY:Double,inTolerance:Double):BooleanQueryBounds(inDisplay:IDisplay,inBounds:IEnvelope)QueryOutline(inDisplay:IDisplay,inOutline:IPolygon)Geometry:IGeometryIMapFrameandIMapSurroundFrameinheritfromIFrameElement.AllpropertiesandmethodsofIFrameElementareaccessibletothedeveloperwhoaccessesIMapFrameorIMapSurroundFrame.IFrameElement:IUnknownBackground:IBackgroundBorder:IBorderDraftMode:BooleanObject:VariantThumbnail:LongIMapFrame:IFrameElementContainer:IGraphicsContainerExtentType:esriExtentTypeEnumLocatorRectangleCount:LongMap:IMapMapBounds:IEnvelopeMapScale:DoubleRemoveAllLocatorRectanglesRemoveLocatorRectangle(inLocator:ILocatorRectangle)AddLocatorRectangle(inLocator:ILocatorRectangle)CreateSurroundFrame(inCLSID:IUID,inoptionalStyle:IMapSurround):IMapSurroundFrameLocatorRectangle(inIndex:Long):ILocatorRectangleIMapSurroundFrame:IFrameElementMapSurround:IMapSurroundMapFrame:IMapFrameQueryInterfaceQueryInterfaceisamethodintheIUnknowninterface,whichallCOMobjectsinheritfrom.Thismethodletsyouqueryforandnavigatetomethodsinotherinterfacesimplementedbyanobject.classinterface1method1method2method3method4interface2QueryInterfaceAppendixC-ics.pmd1/26/2005,7:12AM270AppendixCIllustratedcodesamples271LOCATEANDEXECUTECOMMANDONTOOLBARLocateandExecuteCommandonToolbarThissampleillustrateshowtoprogrammaticallyexecuteexistingcommandsoncommandbarswithinArcMap.ICommandItem:IUnknownAction:StringBuiltIn:BooleanCaption:StringCategory:StringCommand:ICommandFaceID:VariantGroup:BooleanHelpContextID:LongHelpFile:StringID:IUIDIndex:LongMessage:StringName:StringParent:ICommandBarStyle:esriCommandStylesTag:StringTooltip:StringType:esriCommandTypesDeleteExecuteRefreshResetDimpCommandItemAsICommandItemSetpCommandItem=ThisDocument.CommandBars.Find(ArcID.Query_ZoomToSelected)If(pCommandItemIsNothing)ThenExitSubpCommandItem.ExecuteSetpCommandItem=ThisDocument.CommandBars.Find(ArcID.ReportObject_CreateReport)If(pCommandItemIsNothing)ThenExitSubpCommandItem.Execute123AddthiscodetotheClickeventofacommandinArcMap.FrameworkArcMapUITofindthecommandtoexecute,youcanusetheCommandBarscollection.ThecommandbarscollectionisapropertyontheIDocumentinterface(ThisDocument).UsingtheFindmethod,searchusingtheArcIDmoduleto
本文标题:ArcMap扩展开发指南(英文版)
链接地址:https://www.777doc.com/doc-4827617 .html