Creating a non-trival custom GP tool - inputs, outputs, and responding to environment settings
' Copyright 2008 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 use restrictions at <your ArcGIS install location>/developerkit/userestrictions.txt.

Imports Microsoft.VisualBasic
Imports System
Imports ESRI.ArcGIS.Geoprocessing
Imports ESRI.ArcGIS.Geodatabase

Namespace GPPointFileInfo
  Public Class GPRecurseInputSubfolders
        Implements GPPointFileInfo.IGPRecurseInputSubfolders
    Private Shared _parameterIndex As Integer

    Private _recurseSubfolders As Boolean

    Public Sub New(ByVal parameterValueArray As IParameterValueArray)
      Dim gpValue As IGPValue = parameterValueArray.GetGPValue(_parameterIndex)

      _recurseSubfolders = GetRecurseSubfolders(gpValue)
    End Sub

    Public Shared Function GetGPParameterEdit() As IGPParameterEdit
      Dim gpParameterEdit As IGPParameterEdit = New GPParameterClass()

      Dim gpDataType As IGPDataType = New GPBooleanTypeClass()

      Dim gpBoolean As IGPBoolean = New GPBooleanClass()

      gpBoolean.Value = False

      Dim gpValue As IGPValue = TryCast(gpBoolean, IGPValue)

      gpParameterEdit.Name = "recurse_in_input_subfolders"
      gpParameterEdit.DisplayName = "Recurse Input Subfolders"
      gpParameterEdit.DataType = gpDataType
      gpParameterEdit.Value = gpValue
      gpParameterEdit.Direction = esriGPParameterDirection.esriGPParameterDirectionInput
      gpParameterEdit.ParameterType = esriGPParameterType.esriGPParameterTypeOptional

      Return gpParameterEdit
    End Function

    Public Shared Sub SetGPParameterIndex(ByVal index As Integer)
      _parameterIndex = index
    End Sub

        Public ReadOnly Property RecurseSubfolders() As Boolean Implements IGPRecurseInputSubfolders.RecurseSubfolders
                Return _recurseSubfolders
            End Get
        End Property

    Private Function GetRecurseSubfolders(ByVal gpValue As IGPValue) As Boolean
      Dim recurseSubfolders As Boolean

      Dim gpBoolean As IGPBoolean = TryCast(gpValue, IGPBoolean)

      recurseSubfolders = gpBoolean.Value

      Return recurseSubfolders
    End Function
  End Class
End Namespace