ArcObjects Library Reference  

AnimationTypeMapGraphic

About the Move a graphic along a path in ArcMap Sample

[C#]

AnimationTypeMapGraphic.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.Animation;
using ESRI.ArcGIS.ADF;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.ADF.CATIDs;

namespace AnimationDeveloperSamples
{
    [Guid("E0DFDD9F-1C59-4FE8-89FA-71BE8D242A9C")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("AnimationDeveloperSamples.AnimationTypeMapGraphic")]
    public class AnimationTypeMapGraphic : 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 AnimationTypeMapGraphic()
        {
            propName = new string[2];
            propName[0] = "Position";
            propName[1] = "Rotation";

            propType = new esriAnimationPropertyType[2];
            propType[0] = esriAnimationPropertyType.esriAnimationPropertyPoint;
            propType[1] = esriAnimationPropertyType.esriAnimationPropertyDouble;

            typeName = "Map Graphic";
        }
        #endregion

        #region IAGAnimationType members
        public esriAnimationClass AnimationClass
        {
            get
            {
                return esriAnimationClass.esriAnimationClassGeneric;
            }
        }
        public object get_AnimationObjectByID(IAGAnimationContainer pContainer, int objectID)
        {
            IArray array;
            array = get_ObjectArray(pContainer);
            IElement elem = (IElement)array.get_Element(objectID);

            return elem;
        }
        public int get_AnimationObjectID(IAGAnimationContainer pContainer, object pObject)
        {
            IArray array = get_ObjectArray(pContainer);
            int count = array.Count;
            int objectID = 0;
            for (int i = 0; i < count; i++)
            {
                IElement elem = (IElement)array.get_Element(i);
                if (elem == pObject)
                    break;
                objectID++;
            }

            return objectID;
        }
        public string get_AnimationObjectName(IAGAnimationContainer pContainer, object pObject)
        {
            string objectName;
            IElementProperties elemProps = (IElementProperties)pObject;
            objectName = elemProps.Name;

            return objectName;
        }
        public bool get_AppliesToObject(object pObject)
        {
            if ((pObject is IMarkerElement) || (pObject is IGroupElement) || (pObject is ITextElement))
                return true;
            else
                return false;
        }
        public UID CLSID
        {
            get
            {
                UID uid = new UIDClass();
                uid.Value = "{E0DFDD9F-1C59-4FE8-89FA-71BE8D242A9C}";
                return uid;
            }
        }
        public UID KeyframeCLSID
        {
            get
            {
                UID uid = new UIDClass();
                uid.Value = "{B2263D65-7FAF-4118-A255-5B0D47E453EE}";
                return uid;
            }
        }
        public string Name
        {
            get
            {
                return typeName;
            }
        }
        public IArray get_ObjectArray(IAGAnimationContainer pContainer)
        {
            IActiveView view = pContainer.CurrentView as IActiveView;
            IGraphicsContainer graphicsContainer = view as IGraphicsContainer;
            graphicsContainer.Reset();

            IArray array = new ArrayClass();
            IElement elem = graphicsContainer.Next();

            while (elem != null)
            {
                if(get_AppliesToObject(elem))
                    array.Add(elem);
                elem = graphicsContainer.Next();
            }

            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 2;
            else
                return 1;
        }
        public string get_ColumnName(int propIndex, int columnIndex)
        {
            if (propIndex == 0)
            {
                if (columnIndex == 0)
                    return "Position:X";
                else
                    return "Position:Y";
            }
            else if (propIndex == 1)
            {
                return "Rotation";
            }

            return null;
        }
        #endregion
    }
}

[Visual Basic .NET]

AnimationTypeMapGraphic.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.Animation
Imports ESRI.ArcGIS.ADF
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.ADF.CATIDs

<Guid("0FF67964-84F1-4B60-9FDD-ABF2A7D0FDF8"), ClassInterface(ClassInterfaceType.None), ProgId("AnimationDeveloperSamples.AnimationTypeMapGraphic")> _
Public Class AnimationTypeMapGraphic : 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) = "Position"
        propName(1) = "Rotation"

        propType = New esriAnimationPropertyType(1) {}
        propType(0) = esriAnimationPropertyType.esriAnimationPropertyPoint
        propType(1) = esriAnimationPropertyType.esriAnimationPropertyDouble

        typeName = "Map Graphic"
    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 array As IArray
            array = Me.ObjectArray(pContainer)
            Dim elem As IElement = CType(array.Element(objectID), IElement)

            Return elem
        End Get
    End Property
    Public ReadOnly Property AnimationObjectID(ByVal pContainer As IAGAnimationContainer, ByVal pObject As Object) As Integer Implements IAGAnimationType.AnimationObjectID
        Get
            Dim array As IArray = Me.ObjectArray(pContainer)
            Dim count As Integer = array.Count
            Dim objectID As Integer = 0
            Dim i As Integer = 0
            Do While i < count
                Dim elem As IElement = CType(array.Element(i), IElement)
                If elem Is pObject Then
                    Exit Do
                End If
                objectID += 1
                i += 1
            Loop

            Return objectID
        End Get
    End Property
    Public ReadOnly Property AnimationObjectName(ByVal pContainer As IAGAnimationContainer, ByVal pObject As Object) As String Implements IAGAnimationType.AnimationObjectName
        Get
            Dim objectName As String
            Dim elemProps As IElementProperties = CType(pObject, IElementProperties)
            objectName = elemProps.Name

            Return objectName
        End Get
    End Property
    Public ReadOnly Property AppliesToObject(ByVal pObject As Object) As Boolean Implements IAGAnimationType.AppliesToObject
        Get
            If (TypeOf pObject Is IMarkerElement) OrElse (TypeOf pObject Is IGroupElement) OrElse (TypeOf pObject Is ITextElement) Then
                Return True
            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 = "{0FF67964-84F1-4B60-9FDD-ABF2A7D0FDF8}"
            Return uid
        End Get
    End Property
    Public ReadOnly Property KeyframeCLSID() As UID Implements IAGAnimationType.KeyframeCLSID
        Get
            Dim uid As UID = New UIDClass()
            uid.Value = "{A9250243-7A16-4F8D-AA06-29F559ADA0C5}"
            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 graphicsContainer As IGraphicsContainer = TryCast(view, IGraphicsContainer)
            graphicsContainer.Reset()

            Dim array As IArray = New ArrayClass()
            Dim elem As IElement = graphicsContainer.Next()

            Do While Not elem Is Nothing
                If AppliesToObject(elem) Then
                    array.Add(elem)
                End If
                elem = graphicsContainer.Next()
            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 2
            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
                If columnIndex = 0 Then
                    Return "Position:X"
                Else
                    Return "Position:Y"
                End If
            ElseIf propIndex = 1 Then
                Return "Rotation"
            End If

            Return Nothing
        End Get
    End Property
#End Region
End Class