本文整理汇总了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();
}
}