Exemplo n.º 1
0
        /// <summary>
        ///HUDButton示例
        /// </summary>
        private void GSOHUDBUTTON()
        {
            GSOHudButton btn = new GSOHudButton();                            //创建GSOHudButton对象

            btn.SetImage(Application.StartupPath + "/Resource/image/t1.png"); //设置图片路径,图片格式可以是png,jpg或ico。
            btn.Align = EnumAlign.BottomRight;
            //设置图片对齐方式为右下角对齐,EnumAlign成员分别有BottomCenter,BottomLeft,BottomRight,MiddleCenter,MiddleLeft,MiddleRight,TopCenter,TopLeft,TopRight。
            btn.SetOffset(0, 20);                   //设置图片相对于场景右下角的距离。
            btn.MinOpaque   = 1;                    //通过MaxOpaque、MinOpaque这两个属性设置GSOHudButton对象的透明度,其值为0-1。
            btn.MaxOpaque   = 1;
            btn.Height      = 200;                  //设置btn高度
            btn.Width       = 115;                  //设置宽度
            btn.HeightFixed = true;                 //设置GSOHudButton对象的图片高度与该对象的高度相同
            btn.WidthFixed  = true;                 //设置GSOHudButton对象的图片宽度与该对象的宽度相同
            globeControl1.Globe.AddHudControl(btn); //将GSOHudButton对象添加到场景中
        }
Exemplo n.º 2
0
        private void MainFrm_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;
            this.Text = m_strFormTitle;

            globeControl1.MouseDoubleClick += new MouseEventHandler(sceneControl1_MouseDoubleClick);
            globeControl1.MouseMove += new MouseEventHandler(sceneControl1_MouseMove);
            globeControl1.MouseClick += new MouseEventHandler(sceneControl1_MouseClick);
            globeControl1.MouseDown += new MouseEventHandler(sceneControl1_MouseDown);
            globeControl1.MouseUp += new MouseEventHandler(sceneControl1_MouseUp);

            globeControl1.AfterLayerAddEvent += new AfterLayerAddEventHandler(globeControl1_AfterLayerAddEvent);
            globeControl1.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(sceneControl1_FeatureMouseClick);
            globeControl1.FeatureMouseHoverEvent += new FeatureMouseHoverEventHandler(sceneControl1_FeatureMouseHover);
            globeControl1.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(sceneControl1_CameraBeginMove);
            globeControl1.DrawAddFeatureEvent += new DrawAddFeatureEventHandler(sceneControl1_DrawAddFeature);
            globeControl1.AfterKeyDownDeleteFeatureEvent += new AfterKeyDownDeleteFeatureEventHandler(sceneControl1_AfterKeyDownDeleteFeatureEvent);
            globeControl1.TrackPolylineEndEvent += new TrackPolylineEndEventHandler(sceneControl1_TrackPolylineAnalysisEndEvent);
            globeControl1.TrackPolygonEndEvent += new TrackPolygonEndEventHandler(sceneControl1_TrackPolygonAnalysisEndEvent);
            globeControl1.AfterNetLayerAddEvent += new AfterNetLayerAddEventHandler(globeControl1_AfterNetLayerAddEvent);
            globeControl1.KeyDown += new KeyEventHandler(globeControl1_KeyDown);

            //地面透明背景色
            globeControl1.Globe.UserBackgroundColorValid = true;
            globeControl1.Globe.UserBackgroundColor = Color.White;

            //globeControl1.Globe.OverviewControl.Visible = false;//鹰眼
            globeControl1.Globe.ScalerControl.Visible = false;  //比例尺

            //自定义工具栏
            GSOTextStyle textStyle = new GSOTextStyle();
            textStyle.ForeColor = Color.White;
            textStyle.FontSize = 9;

            navigate = new GSOHudButton();
            navigate.Name = "navigate";
            navigate.TextAlign = EnumAlign.BottomCenter;
            navigate.TextStyle = textStyle;
            navigate.TextOffset = new GSOPoint2d(0, -10);
            navigate.SetImage(Application.StartupPath + "/Resource/images/hand36.png");
            navigate.MinOpaque = 1;
            navigate.MaxOpaque = 1;
            navigate.Align = EnumAlign.BottomCenter;
            navigate.SetOffset(-270, 30);
            globeControl1.Globe.AddHudControl(navigate);

            select = new GSOHudButton();
            select.Name = "select";
            select.TextAlign = EnumAlign.BottomCenter;
            select.TextStyle = textStyle;
            select.TextOffset = new GSOPoint2d(0, -10);
            select.SetImage(Application.StartupPath + "/Resource/images/select36.png");
            select.MinOpaque = 1;
            select.MaxOpaque = 1;
            select.Align = EnumAlign.BottomCenter;
            select.SetOffset(-210, 30);
            globeControl1.Globe.AddHudControl(select);

            move = new GSOHudButton();
            move.Name = "move";
            move.TextAlign = EnumAlign.BottomCenter;
            move.TextStyle = textStyle;
            move.TextOffset = new GSOPoint2d(0, -10);
            move.SetImage(Application.StartupPath + "/Resource/images/move36.png");
            move.MinOpaque = 1;
            move.MaxOpaque = 1;
            move.Align = EnumAlign.BottomCenter;
            move.SetOffset(-150, 30);
            globeControl1.Globe.AddHudControl(move);

            rotate = new GSOHudButton();
            rotate.Name = "rotate";
            rotate.TextAlign = EnumAlign.BottomCenter;
            rotate.TextStyle = textStyle;
            rotate.TextOffset = new GSOPoint2d(0, -10);
            rotate.SetImage(Application.StartupPath + "/Resource/images/rotate36.png");
            rotate.MinOpaque = 1;
            rotate.MaxOpaque = 1;
            rotate.Align = EnumAlign.BottomCenter;
            rotate.SetOffset(-90, 30);
            globeControl1.Globe.AddHudControl(rotate);

            elevate = new GSOHudButton();
            elevate.Name = "elevate";
            elevate.TextAlign = EnumAlign.BottomCenter;
            elevate.TextStyle = textStyle;
            elevate.TextOffset = new GSOPoint2d(0, -10);
            elevate.SetImage(Application.StartupPath + "/Resource/images/elevate36.png");
            elevate.MinOpaque = 1;
            elevate.MaxOpaque = 1;
            elevate.Align = EnumAlign.BottomCenter;
            elevate.SetOffset(-30, 30);
            globeControl1.Globe.AddHudControl(elevate);

            line = new GSOHudButton();
            line.Name = "line";
            line.TextAlign = EnumAlign.BottomCenter;
            line.TextStyle = textStyle;
            line.TextOffset = new GSOPoint2d(0, -10);
            line.SetImage(Application.StartupPath + "/Resource/images/line36.png");
            line.MinOpaque = 1;
            line.MaxOpaque = 1;
            line.Align = EnumAlign.BottomCenter;
            line.SetOffset(30, 30);
            globeControl1.Globe.AddHudControl(line);

            measure = new GSOHudButton();
            measure.Name = "measure";
            measure.TextAlign = EnumAlign.BottomCenter;
            measure.TextStyle = textStyle;
            measure.TextOffset = new GSOPoint2d(0, -10);
            measure.SetImage(Application.StartupPath + "/Resource/images/measure36.png");
            measure.MinOpaque = 1;
            measure.MaxOpaque = 1;
            measure.Align = EnumAlign.BottomCenter;
            measure.SetOffset(90, 30);
            globeControl1.Globe.AddHudControl(measure);

            marker = new GSOHudButton();
            marker.Name = "marker";
            marker.TextAlign = EnumAlign.BottomCenter;
            marker.TextStyle = textStyle;
            marker.TextOffset = new GSOPoint2d(0, -10);
            marker.SetImage(Application.StartupPath + "/Resource/images/marker36.png");
            marker.MinOpaque = 1;
            marker.MaxOpaque = 1;
            marker.Align = EnumAlign.BottomCenter;
            marker.SetOffset(150, 30);
            globeControl1.Globe.AddHudControl(marker);

            model = new GSOHudButton();
            model.Name = "model";
            model.TextAlign = EnumAlign.BottomCenter;
            model.TextStyle = textStyle;
            model.TextOffset = new GSOPoint2d(0, -10);
            model.SetImage(Application.StartupPath + "/Resource/images/model36.png");
            model.MinOpaque = 1;
            model.MaxOpaque = 1;
            model.Align = EnumAlign.BottomCenter;
            model.SetOffset(210, 30);
            globeControl1.Globe.AddHudControl(model);

            //给工具栏绑定事件
            globeControl1.HudControlMouseDownEvent  += new HudControlMouseDownEventHandler(globeControl1_HudControlMouseDownEvent);
            globeControl1.HudControlMouseIntoEvent += new HudControlMouseIntoEventHandler(globeControl1_HudControlMouseIntoEvent);
            globeControl1.HudControlMouseOutEvent += new HudControlMouseOutEventHandler(globeControl1_HudControlMouseOutEvent);

            globeControl1.Globe.StatusBar.Visible = true;
            globeControl1.Globe.LatLonGrid.Visible = GridMenue.Checked = false;
            MarbleSurfaceMenuItem.Checked = globeControl1.Globe.MarbleVisible;
            underGroundLockedMenuItem.Checked = globeControl1.Globe.IsUnderGroundLocked;

            globeControl1.Globe.UnderGroundFloor.Visible = false;
            globeControl1.Globe.Object2DMouseOverEnable = true;
            地下网格ToolStripMenuItem.Checked = false;
            MenuItem2DObjMouseOverEnable.Checked = true;

            AtmospherMenue.Checked = true;
            StatusMenu.Checked = true;
            NavigationControlMenu.Checked = true;
            MainToolBarShowMenu.Checked = true;

            dataManagerNode = new TreeNode();
            dataManagerNode.ImageIndex = 0;
            dataManagerNode.SelectedImageIndex = 0;
            dataManagerNode.Checked = true;
            dataManagerNode.Text = "数据管理";
            layerTree.Nodes.Add(dataManagerNode);

            myPlaceNode = new TreeNode();
            myPlaceNode.ImageIndex = 0;
            myPlaceNode.SelectedImageIndex = 0;
            myPlaceNode.Checked = true;
            myPlaceNode.Tag = globeControl1.Globe.MemoryLayer;
            myPlaceNode.Text = "我的地标";
            myPlaceNode.NodeFont = new Font(layerTree.Font ,FontStyle.Bold);
            layerTree.Nodes.Add(myPlaceNode);

            layerManagerNode = new TreeNode();
            layerManagerNode.ImageIndex = 0;
            layerManagerNode.SelectedImageIndex = 0;
            layerManagerNode.Checked = true;
            layerManagerNode.Text = "图层管理";
            layerTree.Nodes.Add(layerManagerNode);

            terrainManagerNode = new TreeNode();
            terrainManagerNode.ImageIndex = 0;
            terrainManagerNode.SelectedImageIndex = 0;
            terrainManagerNode.Checked = true;
            terrainManagerNode.Text = "地形管理";
            layerTree.Nodes.Add(terrainManagerNode);

            ReadKmlToMemoryLayer(Path.GetDirectoryName(Application.ExecutablePath) + "/MyPlace.kml");
            RefreshDataTree();

            globeControl1.Globe.FlyAlongLineSpeed = m_dFlyAlongLineSpeed;
            globeControl1.Globe.FlyAlongLineRotateSpeed = m_dFlyAlongLineRotateSpeed;
            ActionToolMenuChecked();

            //修改状态栏
            globeControl1.Globe.StatusBar.SetTextVisible(EnumStatusBarText.ProCoord, false);
            globeControl1.Globe.StatusBar.SetTextVisible(EnumStatusBarText.TerrainHeight, false);

            // 加上这句Mouseover、MouseInto、MouseOut才会有反应
            globeControl1.Globe.FeatureMouseOverEnable = true;
            MenuItemMouseOverEventEnable.Checked = true;

            globeControl1.Globe.FeatureMouseOverHighLight=false;
            EnableMouseOverHighLightMenu.Checked = false;

            CameraNavigationMenu.Checked = true;
            AntiAntialiasingMenuItem.Checked = globeControl1.Globe.Antialiasing;

            globeControl1.Globe.ModelRenderDetail = EnumRenderDetail.Texture;
            ModelTextureMenuItem.Checked = true;

            globeControl1.Globe.HighlightEntityStyle3D.EntityColor = Color.FromArgb(255, 255, 255, 0);

            // 沿线飞行
            globeControl1.Globe.FlyAlongLineSpeed = 50; //单位:m/s
            globeControl1.Globe.FlyAlongLineRotateSpeed = 50; // 单位:度/s
            globeControl1.Globe.FlyToPointSpeed = 2 * globeControl1.Globe.FlyToPointSpeed;

            //状态栏的显示内容
            statusStrip1.Items[1].Text = "当前目标图层:" + "我的地标";
        }