CustomCommand.vb
' Copyright 2012 ESRI ' ' All rights reserved under the copyright laws of the United States ' and applicable international laws, treaties, and conventions. ' ' You may freely redistribute and use this sample code, with or ' without modification, provided you include the original copyright ' notice and use restrictions. ' ' See the use restrictions. ' Imports ESRI.ArcGIS.Framework Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.Catalog Imports ESRI.ArcGIS.CatalogUI Public Class CustomCommand Inherits ESRI.ArcGIS.Desktop.AddIns.Button #Region "Member Variables" Private m_pApp As IGxApplication #End Region Public Sub New() End Sub Protected Overrides Sub OnClick() ' ' TODO: Sample code showing how to access button host ' My.ArcCatalog.Application.CurrentTool = Nothing ' set m_pApp = My.ArcCatalog.Application Dim pCat As IGxCatalog, pFileFilter As IGxFileFilter, pSelection As IEnumGxObject = Nothing Dim pDlg As IGxDialog, pFilter As IGxObjectFilter 'Dim pDlg As IGxDialog, pHandle As ESRI.ArcGIS.esriSystem.OLE_HANDLE, pFilter As IGxObjectFilter Try pDlg = New GxDialog pCat = pDlg.InternalCatalog pFileFilter = pCat.FileFilter If pFileFilter.FindFileType("py") < 0 Then 'enter the third parameter with the location of the icon as needed pFileFilter.AddFileType("py", "Python file", "") End If pFilter = New CustomFilter pDlg.ObjectFilter = pFilter pDlg.Title = "Please select a .Py file" pDlg.AllowMultiSelect = True pDlg.DoModalOpen(0, pSelection) Catch ex As Exception MsgBox(ex.ToString()) Finally pCat = Nothing pFileFilter = Nothing pSelection = Nothing pDlg = Nothing pFilter = Nothing End Try End Sub Protected Overrides Sub OnUpdate() Enabled = My.ArcCatalog.Application IsNot Nothing End Sub End Class