示例#1
0
 /// <summary>
 /// 当鼠标移出,缩小图标并隐藏文字,恢复原状
 /// </summary>
 private void setButtonTextAndImageEmpty()
 {
     if (listQuickToolBar != null)
     {
         foreach (string key in listQuickToolBar.Keys)
         {
             GSOHudButtonInfo button = listQuickToolBar[key];
             if (button != null)
             {
                 button.SetImage(Application.StartupPath + button.imagePath);
                 button.Text = "";
             }
         }
     }
 }
示例#2
0
        /// <summary>
        /// 配置HUD
        /// </summary>
        private void HUDToolBar()
        {
            //配置按钮属性
            GSOHudButtonInfo navigate = new GSOHudButtonInfo(
                "navigate",                   //按钮名称
                EnumAction3D.ActionNull,      //按钮事件
                "/Resource/image/hand32.png", //按钮小图标
                "/Resource/image/hand36.png", //按钮大图标
                -180, 30,                     //按钮左上角的坐标
                "浏览对象");                      //按钮文字
            GSOHudButtonInfo select = new GSOHudButtonInfo(
                "select",
                EnumAction3D.SelectObject,
                "/Resource/image/select32.png",
                "/Resource/image/select36.png",
                -140, 30,
                "选中对象");
            GSOHudButtonInfo line = new GSOHudButtonInfo(
                "line",
                EnumAction3D.DrawPolyline,
                "/Resource/image/Polyline32.png",
                "/Resource/image/Polyline36.png",
                -100, 30,
                "绘制线");
            GSOHudButtonInfo polygon = new GSOHudButtonInfo(
                "polygon",
                EnumAction3D.DrawPolygon,
                "/Resource/image/Polygon32.png",
                "/Resource/image/Polygon36.png",
                -60, 30,
                "绘制面");
            GSOHudButtonInfo showFrom = new GSOHudButtonInfo(
                "showFrom",
                EnumAction3D.ActionNull,
                "/Resource/image/Model32.png",
                "/Resource/image/Model36.png",
                180, 30,
                "显示窗口");
            //Hud背景
            GSOHudButtonInfo toolBar = new GSOHudButtonInfo(
                "toolbar",
                EnumAction3D.ActionNull,
                "/Resource/image/ToolBar.png",
                "/Resource/image/ToolBar.png",
                -195, 25,
                "");

            //添加进HudControl中
            globeControl1.Globe.AddHudControl(navigate);
            globeControl1.Globe.AddHudControl(select);
            globeControl1.Globe.AddHudControl(line);
            globeControl1.Globe.AddHudControl(polygon);
            globeControl1.Globe.AddHudControl(showFrom);
            globeControl1.Globe.AddHudControl(toolBar);
            //添加进字典中
            listQuickToolBar = new Dictionary <string, GSOHudButtonInfo>();
            listQuickToolBar.Add(navigate.Name, navigate);
            listQuickToolBar.Add(select.Name, select);
            listQuickToolBar.Add(line.Name, line);
            listQuickToolBar.Add(polygon.Name, polygon);
            listQuickToolBar.Add(showFrom.Name, showFrom);
            listQuickToolBar.Add(toolBar.Name, toolBar);

            //鼠标按下事件
            globeControl1.HudControlMouseDownEvent += (sender, e) =>
            {
                if (e.HudControl != null)   //如果按钮不为空
                {
                    GSOHudButton button = e.HudControl as GSOHudButton;
                    if (button == null)
                    {
                        return;
                    }
                    //在字典中找到按钮
                    if (listQuickToolBar.ContainsKey(button.Name) == true)
                    {
                        GSOHudButtonInfo buttonInfo = listQuickToolBar[button.Name];
                        if (buttonInfo != null)
                        {
                            //把字典中的动作赋给球
                            globeControl1.Globe.Action = buttonInfo.action;
                            //判断名称,显示窗口
                            if (buttonInfo.Name == "showFrom")
                            {
                                MessageBox.Show("显示窗口");
                            }
                        }
                    }
                }
            };

            //鼠标移入事件
            globeControl1.HudControlMouseIntoEvent += (sender, e) =>
            {
                if (e.HudControl != null)
                {
                    isMouseInHudControl = true;
                    //先恢复默认
                    setButtonTextAndImageEmpty();
                    GSOHudButton button = e.HudControl as GSOHudButton;
                    if (button == null)
                    {
                        return;
                    }
                    if (listQuickToolBar.ContainsKey(button.Name) == true)
                    {
                        GSOHudButtonInfo buttonInfo = listQuickToolBar[button.Name];
                        if (buttonInfo == null)
                        {
                            return;
                        }
                        //改变鼠标滑过的按钮图标和文字
                        button.SetImage(Application.StartupPath + buttonInfo.bigImagePath);
                        button.Text = " " + buttonInfo.toolTip;
                    }
                }
            };

            //鼠标移出事件
            globeControl1.HudControlMouseOutEvent += (sender, e) =>
            {
                if (e.HudControl != null)
                {
                    isMouseInHudControl = false;
                    GSOHudButton button = e.HudControl as GSOHudButton;
                    if (button == null)
                    {
                        return;
                    }
                    //恢复原样
                    setButtonTextAndImageEmpty();
                }
            };
        }