Black Knight

Chameleon





VB.net Tutorial

To write a Chameleon plug-in in VB.net, follow these steps:

1. Create a new VB.net project in Visual Studio 2005 (or another .Net development environment)

2. Add a reference to Chameleon_Plugin.dll

3. Copy and paste the code skeleton below into your empty .vb file.


    Imports System
    Imports System.ComponentModel
    Imports BKTech.Chameleon.Plugins

Namespace Your.Namespace

    ''You must implement IChameleonPlugin from
    ''BKTech.Chameleon.Plugins (in Chameleon_Plugin.dll)
    Public Class YourPluginName
        Implements IChameleonPlugin

        #region "Private Members"
        ''the array of input files from the client
        private  myDataFiles as string()

        ''a delegate that allows this plug-in to
        ''send progress updates to the client
        private  myReporter as FeedBack.sendFeedBack

        #End Region

        #region "Public Properties"

        ''Returns author string for display in GUI
        ''Browsable(false) prevents from showing up in custom property tab
        <Browsable(false)> _
         Public ReadOnly Property Author() As _
                                   String Implements IChameleonPlugin.Author
            Get
                Return ""
            End Get
        End Property

        ''Returns category string for display in GUI ''no effect on plug-in
            placement in tree
        <Browsable(false)> _
         Public ReadOnly Property Category() As _
                                String Implements IChameleonPlugin.Category
            Get
                Return ""
            End Get
        End Property

        ''Returns description string for display in GUI
        <Browsable(false)> _
         Public ReadOnly Property Description() As _
                               String Implements IChameleonPlugin.Description
            Get
                Return ""
            End Get
        End Property

        ''Returns expected input string for display in GUI
        <Browsable(false)> _
         Public ReadOnly Property ExpectedInput() As _
                             String Implements IChameleonPlugin.ExpectedInput
            Get
                Return ""
            End Get
        End Property

        ''Returns output string for display in GUI
        <Browsable(false)> _
         Public ReadOnly Property Output() As _
                                    String Implements IChameleonPlugin.Output
            Get
                Return ""
            End Get
        End Property

        #End Region

        #region "Public Methods"
        ''' <summary> ''' Initializes this plug-in
        ''' </summary>
        ''' <param name="dataFiles">The array of
        ''' input files from the client</param>
        ''' <param name="feedback">A delegate for reporting status updates
        ''' to  the client</param>
        ''' <returns>True if we are clear to begin execution, false if we have
        ''' invalid input and need to abort</returns>
        Public Function Initialize(ByVal dataFiles() As String, _
                    ByVal feedBack As FeedBack.sendFeedBack) _
                     As Boolean Implements IChameleonPlugin.Initialize

            myDataFiles = dataFiles
            myReporter = feedBack

            myReporter("Plug-in initialized successfully", _
                          BKTech.Chameleon.Plugins.FeedBack.ReturnCode.Success )

            Return True
        End Function

        ''' <summary>
        ''' The core logic of this plug-in
        ''' </summary>
        ''' <returns>True if executed successfully, false otherwise</returns>
        Public Function Execute() As Boolean Implements IChameleonPlugin.Execute

            ' Plug-in implementation goes here

           Return True
        End Function

        
        ''' <summary>
        ''' Loads saved custom properties
        ''' </summary>
        ''' <param name="loadValue">The value saved by the client in
        '''the .cham file for this plug-in</param>
        ''' <returns>True if loaded successfully, false if there was
        ''' a problem</returns>
        Public Function Load(ByVal loadValue As String) As _
                        Boolean Implements IChameleonPlugin.Load
            Return True
        End Function

         ''' <summary>
        ''' Saves this plug-in's data
        ''' </summary>
        Public Function Save() As String Implements IChameleonPlugin.Save
            Return ""
        End Function

        
        ''' <summary>
        ''' Cleans up this plug-in
        ''' </summary>
        Public Function Clean() As Boolean Implements IChameleonPlugin.Clean
            Return True
        End Function

        #End Region
    End Class
End Namespace
                

4. Implement desired logic

5. Compile

6. Copy to the plug-ins directory

7. Start Chameleon