Inherit this abstract class to create a custom extension; this class will be instantiated when the application starts up, allowing you to execute code.

Namespace:  ESRI.ArcGISExplorer.Application

Assembly:  ESRI.ArcGISExplorer.Application (in ESRI.ArcGISExplorer.Application.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public abstract class Extension
Visual Basic (Declaration)
Public MustInherit Class Extension

Remarks

The Extension class provides an extension point to the ArcGIS Explorer application. A class which inherits from the Extension class can be instantiated by the application, providing an opportunity to run code at application startup and shutdown. Other extension points are Button, DockWindow, Gallery, CheckBox and ComboBox.

The simplest way to create a new Extension is to use the templates provided in the Visual Studio Tools for ArcGIS Explorer. For step by step instructions on creating a new Extension using these templates, see the Creating a custom Extension walkthrough.

Override the OnStartup()()() and OnShutdown()()() methods to run code when the application starts up an shuts down. Both methods are optional to override; however, either or both methods should be overridden in order for the Extension to run code. Note that an Extension has no user interface component and therefore cannot be seen in the application.

Note:

An Extension must be included in an add-in project and described in the AddIns.xml file which is part of that project in order to be loaded by ArcGIS Explorer. These steps are automated if the Extension is created by using the Visual Studio Tools for ArcGIS Explorer templates.

Examples

The code below updates cached information about the current DisplayUnits selected in the Display tab. This is useful if you are providing a user interface which provides information about coordinates, as you can provide information using the same units as the rest of the application.
CopyC#
using System;
using System.Text;

// Import some typical namespaces.
using System.Windows.Forms;
using System.Drawing;

// Additional ArcGIS Explorer namespaces.
using ESRI.ArcGISExplorer.Application;
using ESRI.ArcGISExplorer.Mapping;

namespace EventExtension
{
  class SettingsChangedExtension : ESRI.ArcGISExplorer.Application.Extension
  {
    private DisplayUnits currentUnits = DisplayUnits.DecimalDegrees;

    public override void OnStartup()
    {
      // Add event handlers for the SettingsChanged event.
      ESRI.ArcGISExplorer.Application.Application.SettingsChanged += new EventHandler(Application_SettingsChanged);

      // Initialize the value of the DisplayUnits.
      currentUnits = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Settings.DisplayUnits;
    }

    public override void OnShutdown()
    {
      // Remove the handlers for the events.
      ESRI.ArcGISExplorer.Application.Application.SettingsChanged -= new EventHandler(Application_SettingsChanged);
    }

    void Application_SettingsChanged(object sender, EventArgs e)
    {
      // Update the cached settings data.
      currentUnits = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Settings.DisplayUnits;
    }


  }
}
CopyVB.NET
Imports System
Imports System.Text

' Import some typical namespaces.
Imports System.Windows.Forms
Imports System.Drawing

' Additional ArcGIS Explorer namespaces.
Imports ESRI.ArcGISExplorer.Application
Imports ESRI.ArcGISExplorer.Mapping


Namespace EventExtension

  Public Class SettingsChangedExtension
    Inherits ESRI.ArcGISExplorer.Application.Extension

    Private currentUnits As DisplayUnits = DisplayUnits.DecimalDegrees

    Public Overrides Sub OnStartup()
      ' Add event handlers for the DocumentOpened and DocumentClosed events.
      AddHandler ESRI.ArcGISExplorer.Application.Application.SettingsChanged, AddressOf Application_SettingsChanged

      ' Initialize the value of the DisplayUnits.
      currentUnits = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Settings.DisplayUnits
    End Sub


    Public Overrides Sub OnShutdown()
      ' Remove the handlers for the events.
      RemoveHandler ESRI.ArcGISExplorer.Application.Application.SettingsChanged, AddressOf Application_SettingsChanged
    End Sub


    Sub Application_SettingsChanged(ByVal sender As Object, ByVal e As EventArgs)
      ' Update the cached settings data.
      currentUnits = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Settings.DisplayUnits
    End Sub

  End Class
End Namespace

Inheritance Hierarchy

System..::.Object

  ESRI.ArcGISExplorer.Application..::.Extension

See Also