Beispiel #1
0
        // 创建书签
        private void barButtonItem19_ItemClick(object sender, ItemClickEventArgs e)
        {
            using (frmBookmarkAdd frm = new frmBookmarkAdd())
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    // 创建书签
                    ISceneBookmarks pBookmarks  = MainCtrl.GlobeMapContainer.globeCtrl.axGlobeControl1.Globe.GlobeDisplay.Scene as ISceneBookmarks;
                    ICamera         camera      = MainCtrl.GlobeMapContainer.globeCtrl.axGlobeControl1.Globe.GlobeDisplay.ActiveViewer.Camera;
                    string          name        = frm.GetName();
                    string          remark      = frm.GetRemark();
                    IBookmark3D     pBookmark3D = new Bookmark3DClass();
                    pBookmark3D.Name = name;
                    pBookmark3D.Capture(camera);
                    pBookmarks.AddBookmark(pBookmark3D);

                    // 保存书签
                    Bookmark bm = new Bookmark();
                    bm.Altitude        = camera.Observer.Z;
                    bm.Azimuth         = camera.Azimuth;
                    bm.Inclination     = camera.Inclination;
                    bm.Latitude        = camera.Observer.Y;
                    bm.Longitude       = camera.Observer.X;
                    bm.Name            = name;
                    bm.Remark          = remark;
                    bm.RollAngle       = camera.RollAngle;
                    bm.Show            = "true";
                    bm.ViewFieldAngle  = camera.ViewFieldAngle;
                    bm.ViewingDistance = camera.ViewingDistance;

                    string       xmlFile      = AppDomain.CurrentDomain.BaseDirectory + "Config\\Bookmark.xml";
                    BookmarkList bookmarkList = null;
                    if (File.Exists(xmlFile))
                    {
                        bookmarkList = XmlHelper.XmlDeserializeFromFile <BookmarkList>(xmlFile, Encoding.UTF8);
                    }

                    if (bookmarkList == null)
                    {
                        bookmarkList = new BookmarkList();
                        bookmarkList.BookmarkArr.Add(bm);
                    }
                    else
                    {
                        bookmarkList.BookmarkArr.Add(bm);
                    }
                    // 发布事件,通知主窗体添加按钮
                    EventPublisher.PublishShowBookmarkEvent(this, new ShowBookmarkEventArgs()
                    {
                        NameList = new System.Collections.Generic.List <string> {
                            name
                        }, Append = true
                    });
                    // 将书签信息保存到xml配置文件
                    XmlHelper.XmlSerializeToFile(bookmarkList, xmlFile, Encoding.UTF8);
                }
            }
        }
Beispiel #2
0
        public void CraeteBookmark(string markName)
        {
            ISceneBookmarks pBookmarks  = globe.GlobeDisplay.Scene as ISceneBookmarks;
            IBookmark3D     pBookmark3D = new Bookmark3DClass();

            pBookmark3D.Name = markName;
            pBookmark3D.Capture(globe.GlobeDisplay.ActiveViewer.Camera);
            pBookmarks.AddBookmark(pBookmark3D);
            m_bookmarkName = markName;
        }
Beispiel #3
0
        private void cmdCaptureBookmark_Click(object sender, System.EventArgs e)
        {
            IBookmark3D bookmark3d = new Bookmark3DClass();

            bookmark3d.Name = txtNewBookmarkName.Text;
            bookmark3d.Capture(axSceneControl1.Camera);
            ISceneBookmarks bookmarks = (ISceneBookmarks)axSceneControl1.Scene;

            bookmarks.AddBookmark(bookmark3d);

            UpdateBookmarks();
        }
Beispiel #4
0
        // 初始化书签
        private void InitBookmark()
        {
            return;

            string xmlFile = AppDomain.CurrentDomain.BaseDirectory + "Config\\Bookmark.xml";

            if (!File.Exists(xmlFile))
            {
                return;
            }

            BookmarkList bookmarkList = XmlHelper.XmlDeserializeFromFile <BookmarkList>(xmlFile, Encoding.UTF8);

            if (bookmarkList == null || bookmarkList.BookmarkArr == null || bookmarkList.BookmarkArr.Count <= 0)
            {
                return;
            }

            List <string> names = new List <string>();

            foreach (Bookmark mark in bookmarkList.BookmarkArr)
            {
                // 创建书签
                ISceneBookmarks pBookmarks = axGlobeControl1.Globe.GlobeDisplay.Scene as ISceneBookmarks;
                IPoint          point      = new PointClass();
                point.X = mark.Longitude;
                point.Y = mark.Latitude;
                point.Z = mark.Altitude;

                ICamera camera = new CameraClass();
                camera.ProjectionType  = esri3DProjectionType.esriPerspectiveProjection;
                camera.Inclination     = mark.Inclination;
                camera.Azimuth         = mark.Azimuth;
                camera.RollAngle       = mark.RollAngle;
                camera.ViewFieldAngle  = mark.ViewFieldAngle;
                camera.ViewingDistance = mark.ViewingDistance;
                camera.Observer        = point;

                IBookmark3D pBookmark3D = new Bookmark3DClass();
                pBookmark3D.Name = mark.Name;
                pBookmark3D.Capture(camera);
                pBookmarks.AddBookmark(pBookmark3D);

                // 发布事件,通知主窗体添加按钮
                EventPublisher.PublishShowBookmarkEvent(this, new ShowBookmarkEventArgs()
                {
                    NameList = new System.Collections.Generic.List <string> {
                        mark.Name
                    }, Append = true
                });
            }
        }
Beispiel #5
0
        /// <summary>
        /// 添加书签方法,使用bookmark3D接口和ISceneBookmarks接口
        /// </summary>
        /// <param name="bookmarkName">书签名称</param>
        /// <param name="camera">相机</param>
        /// <param name="scene">视图</param>
        /// <returns>返回一个场景图</returns>
        private ISceneBookmarks AddBookmark3DToSceneBookmarks(string bookmarkName, ICamera camera, IScene scene)
        {
            IBookmark3D bookmark3D = new Bookmark3DClass();

            bookmark3D.Name = bookmarkName; //获得书签名
            bookmark3D.Capture(camera);     //捕获相机
            //创建ISceneBookmarks对象,并将摄影机当前位置添加到里面
            ISceneBookmarks sceneBookmarks = scene as ISceneBookmarks;

            sceneBookmarks.AddBookmark(bookmark3D);
            //返回当前场景
            return(sceneBookmarks);
        }
		private void cmdCaptureBookmark_Click(object sender, System.EventArgs e)
		{
			IBookmark3D bookmark3d = new Bookmark3DClass(); 
			bookmark3d.Name = txtNewBookmarkName.Text;
			bookmark3d.Capture(axSceneControl1.Camera);
			ISceneBookmarks bookmarks = (ISceneBookmarks) axSceneControl1.Scene;
			bookmarks.AddBookmark(bookmark3d);

			UpdateBookmarks();
		}