Exemple #1
0
        private void CtrlFeatureAttribute_Load(object sender, EventArgs e)
        {
            if (m_Feature != null)
            {
                // 属性信息相关
                m_Ballonex = new GSOBalloonEx(this.Handle);
                GSOBalloonParam param = m_Ballonex.ParseParam(m_Feature.Description);
                textBoxAttribute.Text = param.Content;
                switch (param.ShowMode)
                {
                case EnumShowModeEx.BALLOONEX:
                    cbbShowMode.SelectedIndex = 0;
                    break;

                case EnumShowModeEx.BALLOON:
                    cbbShowMode.SelectedIndex = 1;
                    break;

                case EnumShowModeEx.EXPLORER:
                    cbbShowMode.SelectedIndex = 2;
                    break;

                default:
                    cbbShowMode.SelectedIndex = 0;
                    break;
                }
                switch (param.ContentType)
                {
                case EnumContentTypeEx.TEXT:
                    cbbContentType.SelectedIndex = 0;
                    break;

                case EnumContentTypeEx.LINK:
                    cbbContentType.SelectedIndex = 1;
                    break;

                default:
                    cbbContentType.SelectedIndex = 0;
                    break;
                }

                tbbWidth.Text  = param.GetSize(EnumSizeIndexEx.CONTENT_CX).ToString();
                tbbHeight.Text = param.GetSize(EnumSizeIndexEx.CONTENT_CY).ToString();
            }

            CheckBallonSetingEnable();
        }
        public Form1()
        {
            InitializeComponent();

            globeControl1 = new GSOGlobeControl();
            panel1.Controls.Add(globeControl1);
            globeControl1.Dock = DockStyle.Fill;

            //点击节点飞行到要素全貌
            treeView1.NodeMouseDoubleClick += (sender, e) =>
            {
                if (e.Node.Tag.GetType() == typeof(GSOFeature))
                {
                    GSOFeature feature = e.Node.Tag as GSOFeature;
                    if (feature.Geometry.CameraState == null)
                    {
                        GSORect2d latLonBounds = feature.Geometry.Bounds;
                        if ((latLonBounds.Left.Equals(0.0) == false) &&
                            (latLonBounds.Bottom.Equals(0.0) == false) &&
                            (latLonBounds.Top.Equals(0.0) == false) &&
                            (latLonBounds.Right.Equals(0.0) == false))
                        {
                            Utility.flyToLayerOrTerrain(globeControl1, latLonBounds);
                        }
                    }
                }
            };

            #region Balloon初始化

            featureTooltip = new GSOBalloon(globeControl1.Handle);             //实例化GSOBalloon对象
            featureTooltip.SetSize(EnumSizeIndex.ROUNDED_CX, 5);               // 设置边角的圆润度
            featureTooltip.SetSize(EnumSizeIndex.ROUNDED_CY, 5);               // 设置边角的圆润度
            featureTooltip.SetSize(EnumSizeIndex.MARGIN_CX, 3);                // 设置空白边缘宽度
            featureTooltip.SetSize(EnumSizeIndex.MARGIN_CY, 3);                // 设置空白边缘宽度
            featureTooltip.SetSize(EnumSizeIndex.ANCHOR_HEIGHT, 30);           // 设置GSOBalloon 锚的高度
            featureTooltip.EscapeSequencesEnabled = true;
            featureTooltip.HyperlinkEnabled       = true;                      // 设置是否可以点击GSOBalloon里面的超链接
            featureTooltip.Opaque   = 0;                                       // 透明度,取值范围是0~100,0为不透明,100为全透明
            featureTooltip.MaxWidth = 300;                                     // 最大宽度
            featureTooltip.SetBorder(Color.FromArgb(255, 255, 128, 64), 1, 1); // 边框
            featureTooltip.SetColorBkType(EnumBkColorType.SILVER);             //填充颜色
            // 也可以下面方法设置
            //featureTooltip.SetColorBk(Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255,240, 247, 250), Color.FromArgb(255,192, 192, 200));
            featureTooltip.SetEffectBk(EnumBkEffect.VBUMP, 10); //渐变效果
            featureTooltip.SetShadow(0, 0, 50, true, 0, 0);     // 阴影
            //featureTooltip.CloseButtonVisible = true;  //显示关闭按钮

            //鼠标进入显示气泡
            globeControl1.FeatureMouseIntoEvent += (sender, e) =>
            {
                if (!featureTooltip.IsVisible())
                {
                    String str1 = "<table><tr><td valign=vcenter><center><h2> " + e.Feature.Name + "</h2><br><hr color=blue></center></td></tr></table>";
                    String str2 = e.Feature.Description;

                    // 显示GSOBalloon
                    featureTooltip.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1 + str2);
                }
            };

            //鼠标移出时隐藏气泡
            globeControl1.FeatureMouseOutEvent += (sender, e) =>
            {
                if (featureTooltip.IsVisible())
                {
                    globeControl1.SwapBuffer(); //为了避免闪屏
                    featureTooltip.HideBalloon();
                }
            };

            #endregion

            #region BalloonEx初始化

            balloonEx = new GSOBalloonEx(globeControl1.Handle);
            //点击要素显示
            globeControl1.FeatureMouseClickEvent += (sender, e) =>
            {
                GSOBalloonParam balloonParam = balloonEx.ParseParam(e.Feature.Description);
                balloonEx.ShowBalloonEx((int)e.MousePos.X, (int)e.MousePos.Y, balloonParam);
            };

            #endregion

            //移动视角时,隐藏气泡
            globeControl1.CameraBeginMoveEvent += (sender, args) =>
            {
                balloonEx.HideBalloon();
            };
        }