コード例 #1
0
ファイル: IdentifyDialog.cs プロジェクト: arcpad/epsgis
        /// <summary>
        /// 加载地图窗口中的图层
        /// </summary>
        private void DisplayLayersFromMapControl()
        {
            IMap map = associateMapControl.Map;

            if (map.LayerCount < 1)
            {
                return;
            }
            //获取指定类型图层
            UID uid = new UIDClass();

            //表示搜索的是IDataLayer
            uid.Value = "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}";
            //布尔参数表示要搜索GroupLayer中的图层
            IEnumLayer layers = map.get_Layers(uid, true);

            layers.Reset(); ILayer layer = layers.Next();
            while (layer != null)
            {
                LayerFilterProperties layerProperty = new LayerFilterProperties();
                //layerProperty.HeaderImage = null;
                layerProperty.LayerCategory    = string.Empty;
                layerProperty.LayerFilterName  = layer.Name;
                layerProperty.LayerFeatureType = GetLayerFeatureType(layer);
                layerProperty.TargetLayer      = layer;
                //保存引用
                layerFilterSet.Add(layerProperty);
                layer = layers.Next();
            }
            //释放Com对象
            System.Runtime.InteropServices.Marshal.ReleaseComObject(layers);
        }
コード例 #2
0
ファイル: IdentifyDialog.cs プロジェクト: arcpad/epsgis
        /// <summary>
        /// 执行属性查询
        /// 尚未实现如何闪烁选中要素集合
        /// 以及进度条的显示
        /// </summary>
        /// <param name="searchLayers"></param>
        private void ExecuteIdentify(List <LayerFilterProperties> searchLayers, IGeometry identifyGeom)
        {
            object Missing = Type.Missing;

            //清空以前所有的查询结果先
            identifiedResultsList.Clear();
            //用于计算查询得到的要素的数量
            int identifiedObjCount = 0;
            //获取用于查询的图层的数量
            int searchLayersCount = searchLayers.Count;

            //初始化进度条
            IdentifyProgress.Visible = true;
            IdentifyProgress.Maximum = searchLayersCount;
            //初始化闪烁对象
            flashObjects.MapControl = associateMapControl.Object as IMapControl2;
            flashObjects.Init();
            //遍历所有图层
            for (int i = 0; i < searchLayersCount; i++)
            {
                LayerFilterProperties filterProps = searchLayers[i];
                ILayer layer = filterProps.TargetLayer;
                //新建查询结果列表对象
                LayerIdentifiedResult layerIdentifiedResult = new LayerIdentifiedResult();
                //先保存查询图层对象
                layerIdentifiedResult.IdentifyLayer = layer;
                layerIdentifiedResult.GeometryType  = filterProps.LayerFeatureType;
                //首先获得查询结果列表对象,以备后面往里添加结果使用
                List <IFeatureIdentifyObj> identifiedObjList = layerIdentifiedResult.IdentifiedFeatureObjList;
                //执行查询,返回查询结果
                IArray identifyResult = Identify(layer, identifyGeom);
                //处理异常情况
                if (identifyResult != null)
                {
                    //依次获取每一个查询结果对象
                    for (int k = 0; k < identifyResult.Count; k++)
                    {
                        identifiedObjCount++;
                        IFeatureIdentifyObj identifiedFeatureObj = identifyResult.get_Element(k) as IFeatureIdentifyObj;
                        //闪烁要素
                        IFeature identifiedFeature = (identifiedFeatureObj as IRowIdentifyObject).Row as IFeature;
                        //添加闪烁图形
                        flashObjects.AddGeometry(identifiedFeature.Shape);
                        //保存查询结果
                        identifiedObjList.Add(identifiedFeatureObj);
                    }
                    identifiedResultsList.Add(layerIdentifiedResult);
                }
                //显示查询进度
                IdentifyProgress.Value = i + 1;
                Application.DoEvents();
            }
            //隐藏进度条
            IdentifyProgress.Visible = false;
            //显示查询到的要素数量
            lblFeatureCount.Text = "查询到 " + identifiedObjCount + " 条记录";
        }
コード例 #3
0
ファイル: IdentifyDialog.cs プロジェクト: arcpad/epsgis
        /// <summary>
        /// 根据用户选择的下拉框获取需要进行查询的图层
        /// </summary>
        /// <returns></returns>
        private List <LayerFilterProperties> SearchIdentifyLayers()
        {
            List <LayerFilterProperties> IdentifyLayers = null;
            //获取过滤文本
            string identifyFilter = cboLayerFilter.Text.Trim();
            //获取选择的过滤器序号
            int selectedIndex = cboLayerFilter.SelectedIndex;

            if (selectedIndex >= layerFilterSet.Count)
            {
                MessageBox.Show("找不到过滤图层。");
                return(IdentifyLayers);
            }
            //获取对应的图层对象
            LayerFilterProperties layerProps = layerFilterSet[selectedIndex];

            switch (layerProps.LayerFilterName)
            {
            case AllLayers:
                IdentifyLayers = getAllLayers;
                break;

            case SelectableLayers:
                IdentifyLayers = getSelectableLayers;
                break;

            case VisibleLayers:
                IdentifyLayers = getVisibleLayers;
                break;

            case TopMostLayer:
                LayerFilterProperties layerProp = getTopmostLayer;
                if (layerProp != null)
                {
                    IdentifyLayers = new List <LayerFilterProperties>();
                    IdentifyLayers.Add(getTopmostLayer);
                }
                break;

            default:
                IdentifyLayers = new List <LayerFilterProperties>();
                IdentifyLayers.Add(getTargetLayer);
                break;
            }
            return(IdentifyLayers);
        }
コード例 #4
0
ファイル: IdentifyDialog.cs プロジェクト: arcpad/epsgis
        /// <summary>
        /// 初始化默认图层过滤器
        /// </summary>
        private void InitializeBasicLayerFilters()
        {
            //添加默认过滤器
            //最顶图层
            LayerFilterProperties topMostLayerProperty = new LayerFilterProperties();

            //topMostLayerProperty.HeaderImage = null;
            topMostLayerProperty.LayerCategory    = string.Empty;
            topMostLayerProperty.LayerFeatureType = LayerFeatureType.None;
            topMostLayerProperty.LayerFilterName  = TopMostLayer;
            topMostLayerProperty.TargetLayer      = null;
            //topMostLayerProperty.MapWindow = associateMapWindow;
            //可见图层
            LayerFilterProperties visibleLayerProperty = new LayerFilterProperties();

            //visibleLayerProperty.HeaderImage = null;
            visibleLayerProperty.LayerCategory    = string.Empty;
            visibleLayerProperty.LayerFeatureType = LayerFeatureType.None;
            visibleLayerProperty.LayerFilterName  = VisibleLayers;
            visibleLayerProperty.TargetLayer      = null;
            //visibleLayerProperty.MapWindow = associateMapWindow;
            //可选图层
            LayerFilterProperties selectableLayerProperty = new LayerFilterProperties();

            //selectableLayerProperty.HeaderImage = null;
            selectableLayerProperty.LayerCategory    = string.Empty;
            selectableLayerProperty.LayerFeatureType = LayerFeatureType.None;
            selectableLayerProperty.LayerFilterName  = SelectableLayers;
            selectableLayerProperty.TargetLayer      = null;
            //selectableLayerProperty.MapWindow = associateMapWindow;
            //所有图层
            LayerFilterProperties allLayerProperty = new LayerFilterProperties();

            //allLayerProperty.HeaderImage = null;
            allLayerProperty.LayerCategory    = string.Empty;
            allLayerProperty.LayerFeatureType = LayerFeatureType.None;
            allLayerProperty.LayerFilterName  = AllLayers;
            allLayerProperty.TargetLayer      = null;
            //allLayerProperty.MapWindow = associateMapWindow;

            //保存图层引用
            layerFilterSet.Add(topMostLayerProperty);
            layerFilterSet.Add(visibleLayerProperty);
            layerFilterSet.Add(selectableLayerProperty);
            layerFilterSet.Add(allLayerProperty);
        }
コード例 #5
0
ファイル: IdentifyDialog.cs プロジェクト: arcpad/epsgis
        /// <summary>
        /// 将图层过滤器添加到下拉框
        /// 注意过滤器的显示顺序尚未实现
        /// </summary>
        private void DisplayLayerFilters()
        {
            //保存清空前的选中状态
            int selectedIndex = cboLayerFilter.SelectedIndex;

            if (selectedIndex < 0)
            {
                selectedIndex = 0;
            }
            //清空先
            cboLayerFilter.Items.Clear();
            int filterCount = layerFilterSet.Count;

            //加载所有图层过滤条件
            for (int i = 0; i < filterCount; i++)
            {
                LayerFilterProperties filterItem = layerFilterSet[i];
                cboLayerFilter.Items.Add(filterItem.LayerFilterName);
            }
            //设定默认过滤条件
            cboLayerFilter.SelectedIndex = selectedIndex;
        }