Exemple #1
0
        /// <summary>
        /// 取得当前所有图层的list
        /// </summary>
        /// <param name="axGlobeControl">AxGlobeControl</param>
        /// <returns>List<LayerInfo></returns>
        public static List<LayerInfo> getLayerNameList(AxGlobeControl axGlobeControl)
        {
            List<LayerInfo> LayerInfoList = new List<LayerInfo>();
            //判断图层数
            if (axGlobeControl.GlobeDisplay.Scene.LayerCount == 0)
            {
                return LayerInfoList;
            }
            try
            {

                ILayer layer = null;
                LayerInfo pLayerInfo;
                for (int index = 0; index < axGlobeControl.GlobeDisplay.Scene.LayerCount; index++)
                {
                    layer = axGlobeControl.GlobeDisplay.Scene.get_Layer(index);  //取得图层

                    pLayerInfo = new LayerInfo();   //实例化一个图层信息类
                    pLayerInfo.LayerName = "btn_" + layer.Name;
                    pLayerInfo.LayerIndex = index;
                    pLayerInfo.isVisible = layer.Visible;

                    LayerInfoList.Add(pLayerInfo);  //添加到list
                }

                return LayerInfoList;
            }
            catch
            {
                return LayerInfoList;
            }
        }
Exemple #2
0
        public static void ShowLayerOrNot(AxGlobeControl axGlobeControl, List <LayerInfo> LayerNameList, string layerName, bool isVisible)
        {
            try
            {
                LayerInfo layerInfo = LayerNameList.Find(delegate(LayerInfo li) { return(li.LayerName == layerName); }); //利用委托查找

                ILayer layer = axGlobeControl.GlobeDisplay.Scene.get_Layer(layerInfo.LayerIndex);                        //getLayerByName(axGlobeControl, layerName);  //有名称取得这个图层
                if (layer == null)                                                                                       //如果没有找到图层
                {
                    return;
                }
                layer.Visible = isVisible;                    //设置图层可见性
                axGlobeControl.GlobeDisplay.RefreshViewers(); //刷新
            }
            catch { }
        }
Exemple #3
0
 private static ButtonItem AddLayerSubItem(LayerInfo layerInfo, System.EventHandler btnItemClickEvent)
 {
     DevComponents.DotNetBar.ButtonItem bi = new DevComponents.DotNetBar.ButtonItem();
     try
     {
         bi.Name = layerInfo.LayerName;         //包含字符串头的名称,防止用“非字母,下划线,”开头。
         bi.Text = layerInfo.LayerName.Substring(4, layerInfo.LayerName.Length - 4);       //去除"btn_"字符串头
         bi.AutoCheckOnClick = true; //点击后自动选中或不选中
         bi.Checked = layerInfo.isVisible;   //是否被选中代表着图层是否显示
         bi.Click += new EventHandler(btnItemClickEvent);        //添加事件
     }
     catch { }
     return bi;
 }