About the Layer effects animation in ArcMap Sample
[C#]
AnimationTypeLayerEffects.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.Animation;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.ADF.CATIDs;
namespace AnimationDeveloperSamples
{
[Guid("52b48920-7eb0-4e3b-8be6-b3983e59e739")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("AnimationDeveloperSamples.AnimationTypeLayerEffects")]
public class AnimationTypeLayerEffects : IAGAnimationType, IAGAnimationTypeUI
{
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType);
//
// TODO: Add any COM registration code here
//
}
[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType);
//
// TODO: Add any COM unregistration code here
//
}
#region ArcGIS Component Category Registrar generated code
/// <summary>
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryRegistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MapAnimationTypes.Register(regKey);
}
/// <summary>
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryUnregistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MapAnimationTypes.Unregister(regKey);
}
#endregion
#endregion
private string[] propName;
private esriAnimationPropertyType[] propType;
private string typeName;
#region constructor
public AnimationTypeLayerEffects()
{
propName = new string[2];
propName[0] = "Brightness";
propName[1] = "Contrast";
propType = new esriAnimationPropertyType[2];
propType[0] = esriAnimationPropertyType.esriAnimationPropertyInt;
propType[1] = esriAnimationPropertyType.esriAnimationPropertyInt;
typeName = "Layer Effects";
}
#endregion
#region IAGAnimationType members
public esriAnimationClass AnimationClass
{
get
{
return esriAnimationClass.esriAnimationClassGeneric;
}
}
public object get_AnimationObjectByID(IAGAnimationContainer pContainer, int objectID)
{
IArray objectArray = get_ObjectArray(pContainer);
return (object)objectArray.get_Element(objectID);
}
public int get_AnimationObjectID(IAGAnimationContainer pContainer, object pObject)
{
IArray objectArray = get_ObjectArray(pContainer);
int objCount = objectArray.Count;
int i = 0;
for (i = 0; i < objCount; i++)
{
if (pObject == objectArray.get_Element(i))
break;
}
return i;
}
public string get_AnimationObjectName(IAGAnimationContainer pContainer, object pObject)
{
ILayer layer = (ILayer)pObject;
if (layer != null)
{
return layer.Name;
}
else
return "";
}
public bool get_AppliesToObject(object pObject)
{
if (pObject is ILayer)
{
ILayerEffects layerEffects = (ILayerEffects)pObject;
if (layerEffects.SupportsBrightnessChange && layerEffects.SupportsContrastChange)
return true;
else
return false;
}
else
{
return false;
}
}
public UID CLSID
{
get
{
UID uid = new UIDClass();
uid.Value = "{52b48920-7eb0-4e3b-8be6-b3983e59e739}";
return uid;
}
}
public UID KeyframeCLSID
{
get
{
UID uid = new UIDClass();
uid.Value = "{965a7a4e-6371-427a-b8f7-ca433c262dc8}";
return uid;
}
}
public string Name
{
get
{
return typeName;
}
}
public IArray get_ObjectArray(IAGAnimationContainer pContainer)
{
IActiveView view = pContainer.CurrentView as IActiveView;
IArray array = new ArrayClass();
ILayer layer1;
int layerCount = view.FocusMap.LayerCount;
int i = 0;
for (i = 0; i < layerCount; i++)
{
layer1 = view.FocusMap.get_Layer(i);
if (get_AppliesToObject(layer1))
{
array.Add(layer1);
}
}
return array;
}
public int PropertyCount
{
get
{
return 2;
}
}
public string get_PropertyName(int index)
{
if (index >= 0 && index < 2)
return propName[index];
else
return null;
}
public esriAnimationPropertyType get_PropertyType(int index)
{
return propType[index];
}
public void ResetObject(IAGAnimationContainer pContainer, object pObject)
{
return;
}
public void UpdateTrackExtensions(IAGAnimationTrack pTrack)
{
return;
}
#endregion
#region IAGAnimationTypeUI members
public IStringArray get_ChoiceList(int propIndex, int columnIndex)
{
return null;
}
public int get_ColumnCount(int propIndex)
{
if (propIndex == 0)
return 1;
else
return 1;
}
public string get_ColumnName(int propIndex, int columnIndex)
{
if (propIndex == 0)
{
return "Brightness";
}
else if (propIndex == 1)
{
return "Contrast";
}
return null;
}
#endregion
}
}
[Visual Basic .NET]
AnimationTypeLayerEffects.vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.Animation
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.ADF.CATIDs
Namespace AnimationDeveloperSamples
<Guid("AA9B2E14-686F-4411-BB84-C44B706C83E4"), ClassInterface(ClassInterfaceType.None), ProgId("AnimationDeveloperSamples.AnimationTypeLayerEffects")> _
Public Class AnimationTypeLayerEffects : Implements IAGAnimationType, IAGAnimationTypeUI
#Region "COM Registration Function(s)"
<ComRegisterFunction(), ComVisible(False)> _
Private Shared Sub RegisterFunction(ByVal registerType As Type)
' Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType)
'
' TODO: Add any COM registration code here
'
End Sub
<ComUnregisterFunction(), ComVisible(False)> _
Private Shared Sub UnregisterFunction(ByVal registerType As Type)
' Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType)
'
' TODO: Add any COM unregistration code here
'
End Sub
#Region "ArcGIS Component Category Registrar generated code"
''' <summary>
''' Required method for ArcGIS Component Category registration -
''' Do not modify the contents of this method with the code editor.
''' </summary>
Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
MapAnimationTypes.Register(regKey)
End Sub
''' <summary>
''' Required method for ArcGIS Component Category unregistration -
''' Do not modify the contents of this method with the code editor.
''' </summary>
Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
MapAnimationTypes.Unregister(regKey)
End Sub
#End Region
#End Region
Private propName As String()
Private propType As esriAnimationPropertyType()
Private typeName As String
#Region "constructor"
Public Sub New()
propName = New String(1) {}
propName(0) = "Brightness"
propName(1) = "Contrast"
propType = New esriAnimationPropertyType(1) {}
propType(0) = esriAnimationPropertyType.esriAnimationPropertyInt
propType(1) = esriAnimationPropertyType.esriAnimationPropertyInt
typeName = "Layer Effects"
End Sub
#End Region
#Region "IAGAnimationType members"
Public ReadOnly Property AnimationClass() As esriAnimationClass Implements IAGAnimationType.AnimationClass
Get
Return esriAnimationClass.esriAnimationClassGeneric
End Get
End Property
Public ReadOnly Property AnimationObjectByID(ByVal pContainer As IAGAnimationContainer, ByVal objectID As Integer) As Object Implements IAGAnimationType.AnimationObjectByID
Get
Dim objectArray As IArray = Me.ObjectArray(pContainer)
Return CObj(objectArray.Element(objectID))
End Get
End Property
Public ReadOnly Property AnimationObjectID(ByVal pContainer As IAGAnimationContainer, ByVal pObject As Object) As Integer Implements IAGAnimationType.AnimationObjectID
Get
Dim objectArray As IArray = Me.ObjectArray(pContainer)
Dim objCount As Integer = objectArray.Count
Dim i As Integer = 0
i = 0
Do While i < objCount
If pObject Is objectArray.Element(i) Then
Exit Do
End If
i += 1
Loop
Return i
End Get
End Property
Public ReadOnly Property AnimationObjectName(ByVal pContainer As IAGAnimationContainer, ByVal pObject As Object) As String Implements IAGAnimationType.AnimationObjectName
Get
Dim layer As ILayer = CType(pObject, ILayer)
If Not layer Is Nothing Then
Return layer.Name
Else
Return ""
End If
End Get
End Property
Public ReadOnly Property AppliesToObject(ByVal pObject As Object) As Boolean Implements IAGAnimationType.AppliesToObject
Get
If TypeOf pObject Is ILayer Then
Dim layerEffects As ILayerEffects = CType(pObject, ILayerEffects)
If layerEffects.SupportsBrightnessChange AndAlso layerEffects.SupportsContrastChange Then
Return True
Else
Return False
End If
Else
Return False
End If
End Get
End Property
Public ReadOnly Property CLSID() As UID Implements IAGAnimationType.CLSID
Get
Dim uid As UID = New UIDClass()
uid.Value = "{AA9B2E14-686F-4411-BB84-C44B706C83E4}"
Return uid
End Get
End Property
Public ReadOnly Property KeyframeCLSID() As UID Implements IAGAnimationType.KeyframeCLSID
Get
Dim uid As UID = New UIDClass()
uid.Value = "{EB5D227B-4814-4720-877B-D19519B2BBD6}"
Return uid
End Get
End Property
Public ReadOnly Property Name() As String Implements IAGAnimationType.Name
Get
Return typeName
End Get
End Property
Public ReadOnly Property ObjectArray(ByVal pContainer As IAGAnimationContainer) As IArray Implements IAGAnimationType.ObjectArray
Get
Dim view As IActiveView = TryCast(pContainer.CurrentView, IActiveView)
Dim array As IArray = New ArrayClass()
Dim layer1 As ILayer
Dim layerCount As Integer = view.FocusMap.LayerCount
Dim i As Integer = 0
i = 0
Do While i < layerCount
layer1 = view.FocusMap.Layer(i)
If AppliesToObject(layer1) Then
array.Add(layer1)
End If
i += 1
Loop
Return array
End Get
End Property
Public ReadOnly Property PropertyCount() As Integer Implements IAGAnimationType.PropertyCount
Get
Return 2
End Get
End Property
Public ReadOnly Property PropertyName(ByVal index As Integer) As String Implements IAGAnimationType.PropertyName
Get
If index >= 0 AndAlso index < 2 Then
Return propName(index)
Else
Return Nothing
End If
End Get
End Property
Public ReadOnly Property PropertyType(ByVal index As Integer) As esriAnimationPropertyType Implements IAGAnimationType.PropertyType
Get
Return propType(index)
End Get
End Property
Public Sub ResetObject(ByVal pContainer As IAGAnimationContainer, ByVal pObject As Object) Implements IAGAnimationType.ResetObject
Return
End Sub
Public Sub UpdateTrackExtensions(ByVal pTrack As IAGAnimationTrack) Implements IAGAnimationType.UpdateTrackExtensions
Return
End Sub
#End Region
#Region "IAGAnimationTypeUI members"
Public ReadOnly Property ChoiceList(ByVal propIndex As Integer, ByVal columnIndex As Integer) As IStringArray Implements IAGAnimationTypeUI.ChoiceList
Get
Return Nothing
End Get
End Property
Public ReadOnly Property ColumnCount(ByVal propIndex As Integer) As Integer Implements IAGAnimationTypeUI.ColumnCount
Get
If propIndex = 0 Then
Return 1
Else
Return 1
End If
End Get
End Property
Public ReadOnly Property ColumnName(ByVal propIndex As Integer, ByVal columnIndex As Integer) As String Implements IAGAnimationTypeUI.ColumnName
Get
If propIndex = 0 Then
Return "Brightness"
ElseIf propIndex = 1 Then
Return "Contrast"
End If
Return Nothing
End Get
End Property
#End Region
End Class
End Namespace