private void PlayAnimation(double duration, int numCycles) { IGlobe globe = axGlobeControl1.Globe; IAnimationTracks tracks = (IAnimationTracks)globe; IViewers3D viewers3D = globe.GlobeDisplay; //exit if document doesn't contain animation.. string sError; if (tracks.TrackCount == 0) { sError = m_AnimFilePath; if (sError == "") { sError = "To get a Sample animation file, Developer Kit Samples need to be installed!"; System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + sError); } else { System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + "Load " + m_AnimFilePath + @"\AnimationSample.aga for sample."); } return; } DateTime startTime; TimeSpan timeSpan; int j; double elapsedTime; for (int i = 1; i <= numCycles; i++) { startTime = DateTime.Now; j = 0; do { timeSpan = (DateTime.Now).Subtract(startTime); elapsedTime = timeSpan.TotalSeconds; if (elapsedTime > duration) { elapsedTime = duration; } tracks.ApplyTracks(null, elapsedTime, duration); viewers3D.RefreshViewers(); j = j + 1; }while (elapsedTime < duration); } }
private static void PlayAnimationTrack(double duration, int numCycles, string FlyFilePath, IGlobe globe, GISFunction.SceneBookmark pSceneBookmark) { try { IAnimationTracks tracks = (IAnimationTracks)globe; IViewers3D viewers3D = globe.GlobeDisplay; //exit if document doesn't contain animation.. string sError; if (tracks.TrackCount == 0) { sError = FlyFilePath; if (sError == "") { sError = "飞行路径文件可能丢失,请确保程序的完整性"; System.Windows.Forms.MessageBox.Show(sError, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { System.Windows.Forms.MessageBox.Show("加载飞行文件失败,请尝试重新安装程序。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } return; } DateTime startTime; TimeSpan timeSpan; int j; double elapsedTime; for (int i = 1; i <= numCycles; i++) { startTime = DateTime.Now; j = 0; do { timeSpan = (DateTime.Now).Subtract(startTime); elapsedTime = timeSpan.TotalSeconds; if (elapsedTime > duration) { elapsedTime = duration; } tracks.ApplyTracks(null, elapsedTime, duration); viewers3D.RefreshViewers(); j = j + 1; }while (elapsedTime < duration); } //if(FlyFilePath.Length>4) //{ // int index = FlyFilePath.IndexOf("飞行"); // int indexFlyPath = FlyFilePath.IndexOf("FlyPath"); // if (index > 0&&indexFlyPath>0) // { // string cityName = FlyFilePath.Substring(indexFlyPath + 8, index - indexFlyPath-8); // pSceneBookmark.ZoomToScene(cityName); // } //} } catch { } }