Building GisLink Applications

Commands

Whenever a command is invoked, this can be from the Ribbon, within the Map Window or the Maps or Libraries Control Bars, then that command is shown in the Developer Control Bar, providing the Developer tickbox is checked in the Show/Hide group of the View tab. The command is shown as a system command in the form "ACom... ", for example, if the Polygon [Create-Simple] command is selected the ACom command will be; "AComAreaEx" (followed by "::Snap" or "::DblClick", depending on the mouse action taken). The ACom form enables developers to find the system name and use it when customising SIS.

As stated above all system command names begin with the letters "ACom". For example:

AComRedraw will redraw the Graphical View, and

CallCommand "AComRedraw" will redraw the view by command.

Note: ACom is case sensitive and must be in this form. If any other combination of upper and lower case letters are used, for example if "acom" is used SIS will not recognise the command.

Click here to see a full list of ACom commands available in SIS.

Adding Custom Commands

GisLink customisations can add custom commands to both the ribbon Applications tab, using the RibbonButton method, and the local, right-mouse menu, using the MenuItem method.

The following code example creates a button on the Applications tab and defines the properties for the SisRibbonButton:

        This is the application group in Cadcorp SIS desktop Applications Tab
        Dim group As SisRibbonGroup = APP.RibbonGroup
        group.Text = "Batch Translator"

        ' Define a large command button
        Dim BigButton As SisRibbonButton = New SisRibbonButton("Translate", New SisClickHandler(AddressOf Translate))
        BigButton.LargeImage = True
        BigButton.Icon = My.Resources.ButtonImage
        BigButton.Help = "Translates multiple files between supported formats"
        BigButton.Description = "Batch Translator"
       
        ' Add the button to the main add-in group
        group.Controls.Add(BigButton)

 

The following code example creates a local menu and defines the properties for the SisMenuItem:

     Dim mMainMenu As SisMenuItem = New SisMenuItem("Batch Translator", New SisClickHandler(AddressOf Translate))
        
        mMainMenu.Text = "Batch Translator"
        mMainMenu.Help = "Translates multiple files between supported formats"
        mMainMenu.Class = ""
        mMainMenu.Filter = ""
        mMainMenu.Image = My.Resources.MenuImage
        mMainMenu.Locus = ""
        mMainMenu.MinSelection = 0
        mMainMenu.MaxSelection = -1
        mMainMenu.MinStatus = 2
        mMainMenu.Enabled = True

       
     APP.ContextMenu.MenuItems.Add(mMainMenu)

See Command Methods (GisLink) for a list of methods which allow a GisLink customisation to action commands.

Custom Command Buttons

Command buttons may have any name, but their captions must match exactly the menu$ argument which appears in the RibbonButton statement.

When the user selects a custom command from the SIS Applications tab, the corresponding command button is pressed automatically.

Removing System Commands

A customisation may choose to remove built-in system commands in order to simplify the SIS application user interface presented to the user. System commands are removed (and re-added if necessary), typically the “Public Sub New()” of the Loader.vb of the project, using the AllowCommands method:

'Remove all system commands.
SIS.AllowCommands(SIS_COM_NONE, "")

'Put the zoom in and zoom out commands back.
SIS.AllowCommands(SIS_COM_ADD, "AComZoomIn2 AComZoomOut")

or:

' Allow all system commands.
SIS.AllowCommands(SIS_COM_ALL, "")

' Remove the zoom in and zoom out commands.
SIS.AllowCommands(SIS_COM_REMOVE, "AComZoomIn2 AComZoomOut")

Running System Commands

Although the GisLink API contains many functions to perform operations in SIS applications, it is sometimes easier to invoke one of the system commands than to write Visual Basic code to produce the same result. Any of the commands available to the user may also be invoked through Visual Basic, although some are obviously more useful than others.

System commands fall into two categories: One-shot commands (those which perform an action without user mouse or positional input, e.g. Redraw [Home-Map]; and Callback commands (those which require user mouse or positional input, e.g. LineString).

One-shot commands are run using the CallCommand method. Callback commands are started using the SwitchCommand method:

'Redraw the view by command.
SIS.CallCommand("AComRedraw")

'Start drawing a line.
SIS.SwitchCommand("AComLine")

'Release control back to the user
SIS.Release()

The one-shot redraw command will be started and completed in the duration of the CallCommand method. The callback command however exists beyond the duration of the SwitchCommand method, in this case until the user presses Enter or Ctrl-Enter to complete the line, or Escape to quit the command. The progress of callback commands is monitored using Triggers.

Note: The DoCommand method can be called with either a one-shot or a callback command, and will choose the appropriate action.


Send comments on this topic.

Click to return to www.cadcorp.com

© Copyright 2000-2017 Computer Aided Development Corporation Limited (Cadcorp).