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

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

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

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

资源描述

Copyright©2004ESRI.Allrightsreserved.DevelopingApplicationswithArcGISEngine控件的定制和扩展5-2DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.课5概述‹ToolbarControl框架‹定制命令和工具‹定制COM命令,工具,工具条,和菜单‹定制COM扩展‹定制对话框‹ToolbarMenus5-3DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.定制和扩展的类型‹可以有多种不同定制方法‹允许用户在运行时增加和移除命令(通过CustomizeDialog)‹自动保存和加载命令到工具条上‹运行时创建和显示菜单‹可以实现不同的扩展‹创建定制的命令,工具,菜单,和工具条‹定制扩展MapControlToolbarTOCToolToolRead/WriteApplicationDataToolToolMenuMenu5-4DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ToolbarControl框架‹ToolbarControl‹ToolbarItems‹CommandPool‹ToolBarMenu‹ToolbarItems‹CommandPool‹CustomizeDialog5-5DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ToolbarItems工具条项目‹ToolbarControl为每一个加载的项创建一个ToolbarItem类‹用于管理相应的项目‹项目类别‹命令,工具,工具控件,和工具条菜单5-6DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.CommandPool命令池‹管理命令的集合‹只有两个对象直接访问命令池‹ToolbarControl‹ToolbarMenu‹提供低水平的访问‹ICommandPool::Created‹ICommandPool::Exists‹ICommandPoolEdit::CallOnCreate‹ICommandPoolEdit::Hook‹开发者通常不使用5-7DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.项目怎样被加载到命令池中‹方法1:传递一个新命令对象的实例‹NewCommandItemiscreatedforthisobject‹Notshared‹方法2:传递命令的UID‹NewCommandItemiscreatedifitdoesnotexist‹AllreferenceswillsharetheinstanceDimpUidAsNewesriSystem.UIDpUid.Value=esriControlCommands.ControlsMapZoomInToolToolbarControl1.AddItempUid,0,-1,True,,esriCommandStyleIconAndTextDimpUidAsNewesriSystem.UIDpUid.Value=esriControlCommands.ControlsMapZoomInToolToolbarControl1.AddItempUid,0,-1,True,,esriCommandStyleIconAndTextDimcommandasICommand=NewesriControlCommands.ControlsMapZoomInToolToolbarControl1.AddItemcommand,0,-1,True,,esriCommandStyleIconAndTextDimcommandasICommand=NewesriControlCommands.ControlsMapZoomInToolToolbarControl1.AddItemcommand,0,-1,True,,esriCommandStyleIconAndText5-8DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ToolbarControl命令创建过程‹每一项被加载到命令池ToolbarisinitializedPoolispopulatedCommandPoolCmdCmdIToolbarItemIToolbarItemCmd1IToolbarItemTool2IToolbarItemMenu3ItemsareaddedCommand,toolormenuiscreatedUpdateInterval5-9DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.ToolbarItems和Commands‹ToolbarItems封装了commands‹IToolbarItem‹Command:提供对command的访问‹Style:控制command的风格‹UID:command的全局唯一ID号DimtoolbarItemAsIToolbarItemFori=0ToAxToolbarControl1.Count-1toolbarItem=AxToolbarControl1.GetItem(i)DimcommandasICommandcommand=toolbarItem.CommandMsgBox(command.Name&toolbarItem.Style&toolbarItem.UID.Value)NextDimtoolbarItemAsIToolbarItemFori=0ToAxToolbarControl1.Count-1toolbarItem=AxToolbarControl1.GetItem(i)DimcommandasICommandcommand=toolbarItem.CommandMsgBox(command.Name&toolbarItem.Style&toolbarItem.UID.Value)Next5-10DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.实现定制命令‹框架提供了创建自定义command的机制‹无缝地加载到ToolbarControl‹作为一个CommandItem加载‹外观和行为和其它项一样‹执行任何ArcObjects代码‹步骤1.创建一个类2.实现ICommand3.将类加载到工具条上PublicClassZoomToLayerClassImplementsICommandPublicClassZoomToLayerClassImplementsICommand5-11DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.定制命令:属性设置‹当command被创建属性就可存取属性‹ICommand‹Name‹Caption‹Category‹Tooltip‹Message‹Bitmap‹HelpContext‹HelpFilePublicReadOnlyPropertyBitmap()AsIntegerImplementsESRI.ArcGIS.SystemUI.ICommand.BitmapGetreturnm_bitmapEndGetEndPropertyPublicReadOnlyPropertyCaption()AsStringImplementsESRI.ArcGIS.SystemUI.ICommand.CaptionGetreturnIdentifyEndGetEndPropertyPublicReadOnlyPropertyCategory()AsStringImplementsESRI.ArcGIS.SystemUI.ICommand.CategoryGetreturnDAAECommandsEndGetEndPropertyPublicReadOnlyPropertyName()AsStringImplementsESRI.ArcGIS.SystemUI.ICommand.NameGetreturnDAAECustomCommand_IdentifyEndGetEndPropertyPublicReadOnlyPropertyBitmap()AsIntegerImplementsESRI.ArcGIS.SystemUI.ICommand.BitmapGetreturnm_bitmapEndGetEndPropertyPublicReadOnlyPropertyCaption()AsStringImplementsESRI.ArcGIS.SystemUI.ICommand.CaptionGetreturnIdentifyEndGetEndPropertyPublicReadOnlyPropertyCategory()AsStringImplementsESRI.ArcGIS.SystemUI.ICommand.CategoryGetreturnDAAECommandsEndGetEndPropertyPublicReadOnlyPropertyName()AsStringImplementsESRI.ArcGIS.SystemUI.ICommand.NameGetreturnDAAECustomCommand_IdentifyEndGetEndProperty5-12DevelopingApplicationswithArcGISEngineCopyright©2004ESRI.Allrightsreserved.定制命令:访问hook(钩子)对象‹Hook(钩子)是一个对创建command的对象的向后引用‹可以是不同的对象‹ToolbarControl,MapControl,PageLayoutControl,…‹当command创建的时候传递进来‹ICommand‹OnCreatePrivateSubICommand_OnCreate(ByValhookAsObject)If(TypeOfhookIsesriToolbarControl.IToolbarControl)ThenDimToolBarConAsesriToolbarControl.IToolbarControlSetToolBarCon=hookIf(TypeOfToolBarCon.BuddyisMapControl)ThenDimmapControlasIMapControlSetMapControl=ToolBarCon.BuddySetm_map=mapControl.MapEndIfElseIf(TypeOfhookisIMapControl3)thenDimmapControlasIMapControlSetmapControl=hookSetm_map=mapControl.MapEndIfEndSubPrivateSubICommand_OnCreate(ByValhookAsObject)If(TypeOfhookIsesriToolbarControl.IToolbarControl)The

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

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

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

×
保存成功