About the ArcReaderGlobeControl play animation Sample
[C#]
PlayAnimation.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace PlayAnimation
{
public partial class PlayAnimation : Form
{
public PlayAnimation()
{
InitializeComponent();
}
private void btnLoad_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "Select Published Map Document";
openFileDialog1.Filter = "Published Map Documents (*.pmf)|*.pmf";
openFileDialog1.ShowDialog();
// Exit if no map document is selected
string sFilePath = "";
sFilePath = openFileDialog1.FileName;
if (sFilePath == null)
{
return;
}
// Load the specified pmf
if (axArcReaderGlobeControl1.CheckDocument(sFilePath))
{
axArcReaderGlobeControl1.LoadDocument(sFilePath, "");
}
else
{
System.Windows.Forms.MessageBox.Show("This document cannot be loaded!");
return;
}
if (axArcReaderGlobeControl1.ARGlobe.AnimationCount != 0)
{
//Enable Controls
enableCommands(true);
//Populate combo with animations, clearing any existing animations listed previously
cboAnimations.Items.Clear();
for (int i = 0; i < axArcReaderGlobeControl1.ARGlobe.AnimationCount; i++)
{
cboAnimations.Items.Add(axArcReaderGlobeControl1.ARGlobe.get_AnimationName(i));
cboAnimations.SelectedIndex=0;
}
}
else
{
System.Windows.Forms.MessageBox.Show("This sample requires you load a PMF that contains animations");
//Disable Controls
enableCommands(false);
}
}
private void btnPlay_Click(object sender, EventArgs e)
{
//Play animation showing or hiding window depending if checkbox is checked
axArcReaderGlobeControl1.ARGlobe.PlayAnimation(axArcReaderGlobeControl1.ARGlobe.get_AnimationName(cboAnimations.SelectedIndex));
}
private void chkShowWindow_CheckedChanged(object sender, EventArgs e)
{
//Show or hide window if checkbox is changed
axArcReaderGlobeControl1.ShowARGlobeWindow(ESRI.ArcGIS.PublisherControls.esriARGlobeWindows.esriARGlobeWindowsAnimation, chkShowWindow.Checked, axArcReaderGlobeControl1.ARGlobe.get_AnimationName(cboAnimations.SelectedIndex));
}
private void cboAnimations_SelectedIndexChanged(object sender, EventArgs e)
{
//Updates the combo box of the animation window if its present
axArcReaderGlobeControl1.ShowARGlobeWindow(ESRI.ArcGIS.PublisherControls.esriARGlobeWindows.esriARGlobeWindowsAnimation, chkShowWindow.Checked, axArcReaderGlobeControl1.ARGlobe.get_AnimationName(cboAnimations.SelectedIndex));
}
private void PlayAnimation_Load(object sender, EventArgs e)
{
//Disable commands
enableCommands(false);
}
private void enableCommands(bool enable)
{
cboAnimations.Enabled = enable;
chkShowWindow.Enabled = enable;
btnPlay.Enabled = enable;
}
}
}
[Visual Basic .NET]
PlayAnimation.vb
Imports ESRI.ArcGIS
Public Class PlayAnimation
<STAThread()> _
Shared Sub Main()
'Load runtime
If Not RuntimeManager.Bind(ProductCode.ArcReader) Then
If Not RuntimeManager.Bind(ProductCode.EngineOrDesktop) Then
MessageBox.Show("Unable to bind to ArcGIS runtime. Application will be shut down.")
System.Environment.Exit(1) ' Force exit or other indication in the application
End If
End If
Application.Run(New PlayAnimation())
End Sub
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
'Open a file dialog for selecting map documents
OpenFileDialog1.Title = "Select Published Map Document"
OpenFileDialog1.Filter = "Published Map Documents (*.pmf)|*.pmf"
OpenFileDialog1.ShowDialog()
'Exit if no map document is selected
Dim sFilePath As String
sFilePath = OpenFileDialog1.FileName
If sFilePath = "" Then Exit Sub
'Load the specified pmf
If AxArcReaderGlobeControl1.CheckDocument(sFilePath) = True Then
AxArcReaderGlobeControl1.LoadDocument(sFilePath)
Else
MsgBox("This document cannot be loaded!")
Exit Sub
End If
If AxArcReaderGlobeControl1.ARGlobe.AnimationCount <> 0 Then
'Enable Controls
enableCommands(True)
'Populate combo with animations, clearing any existing animations listed previously
cboAnimations.Items.Clear()
Dim i As Integer = 0
Do Until i = AxArcReaderGlobeControl1.ARGlobe.AnimationCount - 1
cboAnimations.Items.Add(AxArcReaderGlobeControl1.ARGlobe.AnimationName(i))
cboAnimations.SelectedIndex = 0
i = i + 1
Loop
Else
System.Windows.Forms.MessageBox.Show("This sample requires you load a PMF that contains animations")
'Disable Controls
enableCommands(False)
End If
End Sub
Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click
'Play animation showing or hiding window depending if checkbox is checked
AxArcReaderGlobeControl1.ARGlobe.PlayAnimation(AxArcReaderGlobeControl1.ARGlobe.AnimationName(cboAnimations.SelectedIndex))
End Sub
Private Sub chkShowWindow_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkShowWindow.CheckedChanged
'Show or hide window if checkbox is changed
AxArcReaderGlobeControl1.ShowARGlobeWindow(ESRI.ArcGIS.PublisherControls.esriARGlobeWindows.esriARGlobeWindowsAnimation, chkShowWindow.Checked, AxArcReaderGlobeControl1.ARGlobe.AnimationName(cboAnimations.SelectedIndex))
End Sub
Private Sub cboAnimations_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboAnimations.SelectedIndexChanged
'Updates the combo box of the animation window if its present
AxArcReaderGlobeControl1.ShowARGlobeWindow(ESRI.ArcGIS.PublisherControls.esriARGlobeWindows.esriARGlobeWindowsAnimation, chkShowWindow.Checked, AxArcReaderGlobeControl1.ARGlobe.AnimationName(cboAnimations.SelectedIndex))
End Sub
Private Sub PlayAnimation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Disable commands
enableCommands(False)
End Sub
Private Sub enableCommands(ByVal enable As Boolean)
cboAnimations.Enabled = enable
chkShowWindow.Enabled = enable
btnPlay.Enabled = enable
End Sub
End Class