当前位置: 首页>>代码示例>>C#>>正文


C# IFeatureLayer.Select方法代码示例

本文整理汇总了C#中IFeatureLayer.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IFeatureLayer.Select方法的具体用法?C# IFeatureLayer.Select怎么用?C# IFeatureLayer.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFeatureLayer的用法示例。


在下文中一共展示了IFeatureLayer.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnMouseUp

        /// <summary>
        /// Overrides the OnMouseUp event to handle the situation where we are trying to
        /// identify the vector features in the specified area.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(GeoMouseArgs e)
        {
            
            if (e.Button != MouseButtons.Left) return;
            Rectangle rtol = new Rectangle(e.X - 8, e.Y - 8, 16, 16);
            Rectangle rstr = new Rectangle(e.X - 1, e.Y - 1, 2, 2);
            Extent tolerant = e.Map.PixelToProj(rtol);
            Extent strict = e.Map.PixelToProj(rstr);

            if (_frmFeatureIdentifier == null)
            {
                _frmFeatureIdentifier = new FeatureIdentifier();
            }

            _frmFeatureIdentifier.treFeatures.BeginUpdate();
            _frmFeatureIdentifier.SuspendLayout();
            _frmFeatureIdentifier.Clear();

            Identify(e.Map.MapFrame.GetLayers(), strict, tolerant);
 
            _frmFeatureIdentifier.ReSelect();
            _frmFeatureIdentifier.ResumeLayout();

             if (_frmFeatureIdentifier.Visible == false)
             {
                 _frmFeatureIdentifier.Show(Map.MapFrame != null ? Map.MapFrame.Parent : null);
             }
             base.OnMouseUp(e);

                //Code for making the Identify Tool actually highlight what is being clicked.  
                //However, it needs more adjusting to work properly and will be shelved for now
            try
            {
                
                feature = _frmFeatureIdentifier.treFeatures.SelectedNode.Tag as IFeature;
                layer = _frmFeatureIdentifier.treFeatures.SelectedNode.Parent.Tag as IFeatureLayer;

                /* This logic is used to clear all selections on the entire map and only select a single feature when using the identify tool
                 To get it exactly as desired, I had to get the top layer, which is the mapframe, and perform a ClearSelection from there and then return
                 to the original layer selected in the legend. */
                var layers = e.Map.MapFrame.GetAllLayers();
                ILayer tempLayer = null;
                foreach (var mapLayer in layers)
                {
                    if (mapLayer.IsSelected)
                    {
                        tempLayer = mapLayer;
                        mapLayer.IsSelected = false;
                    }
                }
                if (tempLayer == null)
                {
                    tempLayer = e.Map.MapFrame;
                }
                e.Map.MapFrame.IsSelected = true;
                IEnvelope env = new Envelope();
                e.Map.MapFrame.ClearSelection(out env);
                e.Map.MapFrame.IsSelected = false;
                tempLayer.IsSelected = true;
              

                if (feature != null && layer != null && layer.IsVisible == true)
                {
                    layer.Select(feature);
                }
            }
            catch (NullReferenceException)
            {
                Debug.WriteLine("Clicked area has a null reference");
            }
            finally
            {
                _frmFeatureIdentifier.treFeatures.EndUpdate();
            }
        }
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:80,代码来源:MapFunctionIdentify.cs


注:本文中的IFeatureLayer.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。