Visual Studio UI Plugin Template

This template enables developers to build an STK UI Plugin quickly by setting up a properly configured, blank plugin. The template includes several useful code sample and libraries:

  • Examples for adding a progress bar, a link to the plugin from the context menu, a link to the plugin from the main menu, and a link to the plugin from the toolbar
  • An example of a persistent preference page, which keeps user selections even after STK is closed
  • The STK code library, which is used for interacting with STK and manipulating STK objects, including simple methods to subscribe to events in STK and get a list of objects in an STK scenario
  • Globe mouse events code that are commented out

To use the template to build a UI Plugin, follow the instructions below.

Copy the templates

Copy the following zip files to your Visual Studio user folder (<user area>Visual Studio<version number>Templates\ProjectTemplates\Visual C#):

Template used for creating UI plugin
<stk install folder>/CodeSamples/STKCodeSamples.zip/Extend/Ui.Plugins/Visual Studio Templates/STK13.UiPlugin.Template.zip

Do not unzip these files.

Create a new Visual Studio project

Launch Visual Studio and follow these instructions:

  1. Create a new project; the New Project dialog box will appear.
  2. If you are using Visual Studio 2019, do not filter or search for templates. Scroll to the bottom of this list and select the STK13.UIPlugin.Template, and then skip to Step 4.

  3. In the left pane of the dialog box, select Visual C# under templates.
  4. In the right pane, select STK13.UIPlugin.Template.
  5. Enter a unique name for your project. If the name is not unique, your plugin will be in conflict with other UI plugins that have the same name.
  6. Click OK.

Build your project

  1. Open Setup.cs in the Visual Studio editor.
  2. Build the project.
  3. Instructions for installing your plugin can be found here.

Debugging your plugin

If you want to debug the plugin, you need to point your manifest file to your debug binary folder. Here are instructions for setting up the plugin for debugging:

  1. In Windows Explorer, go to the debug folder for the plugin and copy path.
  2. Go to your manifest file (C:\ProgramData\AGI\STK 13\Plugins).
  3. Open the XML file in the text editor of your choice and change the code path to your debug folder:
  4. Copy

    XML Manifest File

    <?xml version = "1.0"?>
    <AGIRegistry version = "1.0">
    <CategoryRegistry>
    <Category Name = "UiPlugins">
    <NETUiPlugin
    DisplayName="Demo plugin"
    TypeName="Stk13.UiPlugin.Demo.Setup"
    AssemblyName="Stk13.UiPlugin.Demo"
    CodeBase="D:\MyProjects\UIPlugin\Stk13.UiPlugin.Demo\Stk13.UiPlugin.Demo\bin\Debug">
    </NETUiPlugin>
    </Category>
    </CategoryRegistry>
    </AGIRegistry>
  5. Back in Visual Studio, switch the startup project back to the plugin and make sure that the configuration is set to Debug.
  6. Open the plugin project properties and select the Debug tab. Change Start Action to Start External Program and select AgUiApplication.exe in the STK installed bin folder.

Related topics: