This document is archived and information here might be outdated.  Recommended version.


Using the swipe and transparency commands (ArcObjects .NET 10.5 SDK)

Using the swipe and transparency commands


Summary
This topic describes using the out-of-the box 2D and 3D swipe and transparency commands with the ArcGIS Engine controls.

In this topic


Using the 2D swipe and transparency commands

To successfully utilize the ControlsMapSwipeTool and ControlsLayerTransparencyCommand on a ToolbarControl buddied to a MapControl or PageLayoutControl, the commands must be used in conjunction with the CommandsEnvironment singleton object and the ControlsLayerListToolControl.
When an end user selects a layer from the ControlsLayerListToolControl, this layer is set to the ILayerEffectProperties.SwipeLayer and ILayerEffectProperties.TransparencyLayer properties on the CommandsEnvironment singleton object. The ControlsMapSwipeTool and ControlsLayerTransparencyCommand use the ILayerEffectProperties.SwipeLayer and ILayerEffectProperties.TransparencyLayer properties to determine which layer to swipe or make transparent. See the following screen shot:
Failure to instantiate the CommandsEnvironment singleton object results in the ControlsMapSwipeTool and ControlsLayerTransparencyCommand internally using their instance of the CommandsEnvironment object, and appearing disabled to the end user.
The following code example assumes a MapControl, ToolbarControl, and LicenseControl have been embedded into a form:
[VB.NET]
Public Class Form1
    
    Private m_CommandsEnvironment As New CommandsEnvironmentClass
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Set buddy control.
        AxToolbarControl1.SetBuddyControl(AxMapControl1)
        'Add items to ToolbarControl.
        AxToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        AxToolbarControl1.AddItem("esriControls.ControlsMapSwipeTool", -1, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly)
        AxToolbarControl1.AddItem("esriControls.ControlsLayerTransparencyCommand", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        AxToolbarControl1.AddItem("esriControls.ControlsLayerListToolControl", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
    End Sub
    
End Class
[C#]
public partial class Form1: Form
{
    private CommandsEnvironmentClass m_CommandsEnvironment=new
        CommandsEnvironmentClass();

    private void Form1_Load(object sender, System.EventArgs e)
    {
        //Set buddy control.
        axToolbarControl1.SetBuddyControl(axMapControl1);
        //Add items to ToolbarControl.
        axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand",  - 1,  - 1,
            false, 0, esriCommandStyles.esriCommandStyleIconOnly);
        axToolbarControl1.AddItem("esriControls.ControlsMapSwipeTool",  - 1,  - 1,
            true, 0, esriCommandStyles.esriCommandStyleIconOnly);
        axToolbarControl1.AddItem("esriControls.ControlsLayerTransparencyCommand",  
            - 1,  - 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
        axToolbarControl1.AddItem("esriControls.ControlsLayerListToolControl",  - 1,
            - 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
    }
}

Using the 3D swipe command

To successfully utilize the ControlsGlobeSwipeTool on a ToolbarControl buddied to a GlobeControl, the command must be used in conjunction with the CommandsEnvironment singleton object and the ControlsGlobeLayerListToolControl.
When an end user selects a layer from the ControlsGlobeLayerListToolControl, this layer is set to the ILayerEffectProperties.SwipeLayer property on the CommandsEnvironment singleton object. The ControlsGlobeSwipeTool uses the ILayerEffectProperties.SwipeLayer property to determine which layer to swipe. See the following screen shot:
Failure to instantiate the CommandsEnvironment singleton object results in the ControlsGlobeSwipeTool internally using its own instance of the CommandsEnvironment object and appearing disabled to the end user.
The following code example assumes GlobeControl, ToolbarControl, and LicenseControl have been embedded into a form:
[VB.NET]
Public Class Form1
    
    Private m_CommandsEnvironment As New CommandsEnvironmentClass
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Set buddy control.
        AxToolbarControl1.SetBuddyControl(AxGlobeControl1)
        'Add items to ToolbarControl.
        AxToolbarControl1.AddItem("esriControls.ControlsGlobeOpenDocCommand", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
        AxToolbarControl1.AddItem("esriControls.ControlsGlobeSwipeTool", -1, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly)
        AxToolbarControl1.AddItem("esriControls.ControlsGlobeLayerListToolControl", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
    End Sub
    
End Class
[C#]
public partial class Form1: Form
{
    private CommandsEnvironmentClass m_CommandsEnvironment=new
        CommandsEnvironmentClass();
    private void Form1_Load(object sender, System.EventArgs e)
    {
        //Set buddy control.
        axToolbarControl1.SetBuddyControl(axGlobeControl1);
        //Add items to ToolbarControl.
        axToolbarControl1.AddItem("esriControls.ControlsGlobeOpenDocCommand",  - 1, 
            - 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
        axToolbarControl1.AddItem("esriControls.ControlsGlobeSwipeTool",  - 1,  - 1,
            true, 0, esriCommandStyles.esriCommandStyleIconOnly);
        axToolbarControl1.AddItem("esriControls.ControlsGlobeLayerListToolControl", 
            - 1,  - 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
    }
}


See Also:

CommandsEnvironment class
ILayerEffectProperties interface
ControlsMapSwipeTool class
ControlsGlobeSwipeTool class
ControlsLayerTransparencyCommand class
ControlsLayerListToolControl class
ControlsGlobeLayerListToolControl class
Interacting with singleton objects




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced