Assembly: ESRI.ArcGISExplorer.Application (in ESRI.ArcGISExplorer.Application.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public abstract class CheckBox |
Visual Basic (Declaration) |
---|
Public MustInherit Class CheckBox |
Remarks
The CheckBox class provides an extension point in ArcGIS Explorer. A class which inherits from the CheckBox class can be shown as a checkbox in the ArcGIS Explorer application Ribbon, providing an opportunity to run code when the user clicks on the control on the ribbon to check or uncheck it. Other extension points are Button, DockWindow, ComboBox, Gallery and Extension.
The simplest way to create a new CheckBox is to use the templates provided in the Visual Studio Tools for ArcGIS Explorer. For step by step instructions on creating a new CheckBox using these templates, see the Creating a custom Checkbox walkthrough.
Override the OnClick()()() method to run code when the user clicks the checkbox; the majority of code in a custom CheckBox is generally found in this method. Optionally, override the OnUpdate()()() method to periodically run code; note that the OnUpdate method should only perform brief operations to maintain responsiveness of the application.
Note: |
---|
A CheckBox 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 CheckBox is created by using the Visual Studio Tools for ArcGIS Explorer templates. |
An alternative approach is to use a Button add-in instead, making use of the Button.Checked property.
Examples
using System; using System.Text; using ESRI.ArcGISExplorer.Application; using ESRI.ArcGISExplorer.Mapping; namespace NewCheckBox { public class NewCheckBox : ESRI.ArcGISExplorer.Application.CheckBox { Basemap lastBasemap = null; MapDisplay disp = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay; public NewCheckBox() { // Set up initial state of the checkbox if (disp.Map.Basemap == null) { this.Checked = false; } else { this.Checked = true; } } public override void OnClick() { // Toggle the basemap on or off if (this.Checked) { if (lastBasemap != null) { disp.Map.Basemap = lastBasemap; } } else { // Unchecking clears basemap - store it for replacing it later. if (disp.Map.Basemap != null) { lastBasemap = disp.Map.Basemap; disp.Map.Basemap = null; } } } } }
Imports System.Text Imports ESRI.ArcGISExplorer.Application Imports ESRI.ArcGISExplorer.Mapping Namespace NewCheckBox Public Class NewCheckBox Inherits ESRI.ArcGISExplorer.Application.CheckBox Private lastBasemap As Basemap = Nothing Private disp As MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay Public Sub New() ' Set up initial state of the checkbox If disp.Map.Basemap Is Nothing Then Me.Checked = False Else Me.Checked = True End If End Sub Public Overrides Sub OnClick() ' Toggle the basemap on or off If Me.Checked Then If lastBasemap IsNot Nothing Then disp.Map.Basemap = lastBasemap End If Else ' Unchecking clears basemap - store it for replacing it later. If disp.Map.Basemap IsNot Nothing Then lastBasemap = disp.Map.Basemap disp.Map.Basemap = Nothing End If End If End Sub End Class End Namespace