Пример #1
0
        public static void FlyByPath(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath,GISFunction.SceneBookmark pSceneBookmark)
        {
            try
            {
                string FlyFilePath = FlyFoldPath + "\\" + _FlyPathName + ".aga";
                if (!File.Exists(FlyFilePath))    //如果此文件不存在
                {
                    return;
                }
                IGlobe globe = _axGlobeControl.Globe;
                IBasicScene2 basicScene = (IBasicScene2)globe;
                basicScene.LoadAnimation(FlyFilePath);

                double duration = 10;
                int numCycles = 1;  //循环次数

                PlayAnimationTrack(duration, numCycles, FlyFilePath, globe, pSceneBookmark);
            }
            catch
            { }
        }
Пример #2
0
        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
            { }
        }