ArcGlobe三维开发之十七——书签

关于书签,主要实现创建书签,缩放至书签等功能。相关接口:ISceneBookmarks2 和IBookmark3D,实现过程很简单,代码如下:

  创建书签源码:

 public partial class CreateBookMark:DevComponents.DotNetBar.Office2007Form
    {
        public IGlobeControl m_globecontrol = null;

        public CreateBookMark (IGlobeControl globecontrol)   
        {
            this.m_globecontrol = globecontrol;
            InitializeComponent();
        }
        //创建书签
        private void buttonX_Create_Click (object sender,EventArgs e)
        {
             if (textBox_BookMarkName.Text=="")
             {
                 MessageBox.Show("请输入书签名!");
             } 
             else
             {
                 ISceneBookmarks pBookmarks = m_globecontrol.Globe.GlobeDisplay.Scene as ISceneBookmarks;
                 IBookmark3D pBookmark3D = new Bookmark3DClass();
                 pBookmark3D.Name = textBox_BookMarkName.Text;
                 pBookmark3D.Capture(m_globecontrol.Globe.GlobeDisplay.ActiveViewer.Camera);
                 pBookmarks.AddBookmark(pBookmark3D);

                 this.Close();
                 this.Dispose();
             }

        }
        private void buttonX_cancle_Click (object sender,EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

    }

书签管理器代码:

  public partial class BookmarkManager:DevComponents.DotNetBar.Office2007Form
    {
        //类成员
        private IGlobeControl m_globecontrol = null;
        private IArray m_BookmarkArray = null;
        private string m_bookmarkName = "";
       
        //构造函数
        public BookmarkManager (IGlobeControl globecontrol)
        {
            this.m_globecontrol = globecontrol;
            InitializeComponent();
        }
       
        //load
        private void BookmarkManager_Load (object sender,EventArgs e)
        {
            ISceneBookmarks2 sceneBookmarks = m_globecontrol.Globe as ISceneBookmarks2;
            m_BookmarkArray = sceneBookmarks.Bookmarks;
            for(int i = 0;i < sceneBookmarks.BookmarkCount;i++)
            {
                IBookmark3D pBookmark = new Bookmark3DClass();
                pBookmark = m_BookmarkArray.get_Element(i) as IBookmark3D;
                listBox_Bookmarks.Items.Add(pBookmark.Name);

            }

        }
         //创建书签
        private void button_CreateBookmark_Click (object sender,EventArgs e)
        {
            CreateBookMark createBookMark = new CreateBookMark(m_globecontrol);
            createBookMark.ShowDialog();
        }
        //选中书签
        private void listBox_Bookmarks_SelectedIndexChanged (object sender,EventArgs e)
        {
            m_bookmarkName = listBox_Bookmarks.Items[listBox_Bookmarks.SelectedIndex].ToString();
        }
        //删除书签
        private void buttonX_remove_Click (object sender,EventArgs e)
        {
            ISceneBookmarks2 sceneBookmarks = m_globecontrol.Globe as ISceneBookmarks2;
            IBookmark3D bookmark3D = null;
            sceneBookmarks.FindBookmark(m_bookmarkName,out bookmark3D);
            if (bookmark3D!=null)
            {
                sceneBookmarks.RemoveBookmark(bookmark3D);
                listBox_Bookmarks.Items.Remove(this.listBox_Bookmarks.SelectedIndex);
            }
        }
        //缩放至
        private void button_Zoom2Bookmark_Click (object sender,EventArgs e)
        {
            ISceneBookmarks2 sceneBookmarks = m_globecontrol.Globe as ISceneBookmarks2;
            IBookmark3D bookmark3D = null;
            sceneBookmarks.FindBookmark(m_bookmarkName,out bookmark3D);
            if (bookmark3D!=null)
            {
                bookmark3D.Apply(m_globecontrol.GlobeDisplay.ActiveViewer,true,0);
                m_globecontrol.GlobeDisplay.RefreshViewers();
            }
            
        }

        private void buttonX_close_Click (object sender,EventArgs e)
        {
            this.Close();
            this.Dispose();
        }
    }


你可能感兴趣的:(源码,Gis,3D,bookmark,ArcGlobe)