Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                //初始化系统路径
                DataFoldPath    = AppStartPath;                      // +"\\Data\\"; //系统数据文件夹路径
                GlobeMapPath    = DataFoldPath + Globe3ddMapName;    //定义三维地图路径
                MxdGlobeEyePath = DataFoldPath + MapMxdGlobeEyeName; //定义鹰眼地图路径

                //加载地图
                if (System.IO.File.Exists(GlobeMapPath))                    //如果该路径存在
                {
                    this.axGlobeControl1.Load3dFile(GlobeMapPath);          //加载三维地图
                }
                if (System.IO.File.Exists(MxdGlobeEyePath))                 //如果该路径存在
                {
                    this.axMapControl_GlobeEye.LoadMxFile(MxdGlobeEyePath); //加载鹰眼地图
                }

                this.axMapControl_GlobeEye.ShowScrollbars = false;       //隐藏条。

                this.axGlobeControl1.GlobeDisplay.GestureEnabled = true; //手势启用?
                this.axGlobeControl1.Navigate = true;                    //浏览模式
                GISBrowseTools.Navigate(this.axGlobeControl1);           //地图的默认工具为浏览

                //指北针
                this.axGlobeControl1.GlobeViewer.NorthArrowEnabled = !this.axGlobeControl1.GlobeViewer.NorthArrowEnabled;

                btnFlyToSubItemDefaultCount    = btnFlyTo.SubItems.Count;                                          //飞行动画按钮默认字按钮个数
                btnBookmarkSubItemDefaultCount = btnBookmark.SubItems.Count;                                       //场景书签按钮默认子按钮个数
                btnLayerManagerSubDefaultCount = btnLayerManager.SubItems.Count;                                   //图层管理的子按钮个数

                #region                                                                                            //场景书签按钮
                if (pSceneBookmark == null)                                                                        //如果类为空
                {
                    pSceneBookmark = new SceneBookmark(this.axGlobeControl1, this.btnBookmark, btnBookmark_Click); //实例化书签类,并传入axGlobeControl
                }
                if (this.btnBookmark.SubItems.Count <= btnBookmarkSubItemDefaultCount)                             //如果子按钮少于三个,就说明没有加载场景书签
                {
                    pSceneBookmark.LoadBookmarksAsButton();                                                        //加载场景按钮
                }
                #endregion

                #region                                             //沿路径飞行
                FlyPathFoldPath = AppStartPath + "\\Data\\FlyPath"; //飞行文件的文件夹
                if (!Directory.Exists(FlyPathFoldPath))             //如果路径不存在
                {
                    MessageBox.Show("飞行路径文件丢失,请确保程序的完整性", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    //取得飞行路径list
                    if (FlyPathNameList == null)
                    {
                        FlyPathNameList = FlyAccordingPath.Fly.getFileListFromFoldPath(FlyPathFoldPath);
                    }
                    //添加飞行路径子按钮
                    if (this.btnFlyTo.SubItems.Count == btnFlyToSubItemDefaultCount)                //如果按钮个数为默认个数,则说明没有添加
                    {
                        UIControl.AddFlyPathButton(FlyPathNameList, this.btnFlyTo, btnFlyTo_Click); //以飞行路径名,加载按钮
                    }
                }
                #endregion

                #region //图层管理
                //取得图层list
                if (LayerNameList == null)
                {
                    LayerNameList = CommonBaseTool.BaseGISTools.getLayerNameList(this.axGlobeControl1);
                }
                //添加子按钮
                if (this.btnLayerManager.SubItems.Count == btnLayerManagerSubDefaultCount)
                {
                    UIControl.AddLayerNameButons(LayerNameList, this.btnLayerManager, btnLayerManager_Click);   //添加图层子按钮
                }
                #endregion
            }
            catch
            { }
        }
Example #2
0
        private void AllButton_Click(object sender, EventArgs e)
        {
            try
            {
                ButtonItem btn = (ButtonItem)sender;

                switch (btn.Name)
                {
                //位置信息
                case "btnCoordinatesInfo":
                    isShowCoordinates = !isShowCoordinates;     //取反
                    break;

                //鹰眼
                case "btnGlobeEyeShow":
                    //isShowGlobeEyeInfo = !isShowGlobeEyeInfo;   //bool取反
                    this.axMapControl_GlobeEye.LoadMxFile(MxdGlobeEyePath);
                    this.panelEx_GlobeEye.Visible = !this.panelEx_GlobeEye.Visible;
                    //this.btnGlobeEyeShow.Checked = this.panelEx_GlobeEye.Visible;
                    this.axMapControl_GlobeEye.ActiveView.Refresh();        //刷新一下地图
                    break;

                //显示指北针
                case "btnShowNorthArrow":
                    this.axGlobeControl1.GlobeViewer.NorthArrowEnabled = !this.axGlobeControl1.GlobeViewer.NorthArrowEnabled;
                    this.axGlobeControl1.GlobeDisplay.RefreshViewers();     //刷新
                    break;

                    #region //各种浏览工具
                //浏览工具
                case "btnToolNavigate":
                    GISBrowseTools.Navigate(this.axGlobeControl1);
                    break;

                //平移工具
                case "btnToolPan":
                    GISBrowseTools.PanGlobe(this.axGlobeControl1);
                    break;

                //飞行工具
                case "btnToolFlyTo":
                    GISBrowseTools.FlyTool(this.axGlobeControl1);
                    break;

                //全图
                case "btnToolFullExtent":
                    GISBrowseTools.FullExtentGlobe(this.axGlobeControl1);
                    break;

                //俯视
                case "btnToolNavigationMode":
                    //pGISBrowseTool.NavigationMode(this.axGlobeControl1);
                    pSceneBookmark.ZoomToScene("全球视图");
                    break;

                //保存
                case "btnToolSaveGlobe":
                    GISBrowseTools.SaveAsDoc(this.axGlobeControl1);
                    break;

                //向北看
                case "btnToolLookNorth":
                    GISBrowseTools.LookNorth(this.axGlobeControl1);
                    break;

                //绕一点旋转查看
                case "btnToolFixedLineOfSight":
                    GISBrowseTools.FixedLineOfSight(this.axGlobeControl1);
                    break;

                //快速缩放
                case "btnToolZoomInOut":
                    GISBrowseTools.ZoomInZoomOut(this.axGlobeControl1);
                    break;

                //测距
                case "btnToolMeasure":
                    GISBrowseTools.MeasureInGlobe(this.axGlobeControl1);
                    break;

                //信息查询
                case "btnToolIdentify":
                    GISBrowseTools.Identify(this.axGlobeControl1);
                    break;

                //逐渐放大
                case "btnToolFixedZoomIn":
                    GISBrowseTools.FixedZoomIn(this.axGlobeControl1);
                    break;

                //逐级缩小
                case "btnToolFixedZoomOut":
                    GISBrowseTools.FixedZoomOut(this.axGlobeControl1);
                    break;
                    #endregion

                    #region //图层管理


                    #endregion
                }
            }
            catch { }
        }