在使用ArcGis Engine的独立c#/ wpf应用程序中,我加载了一些形状selected some features。
现在我想强调一个选定的功能。我可以在IFeatureSelection / Layer上找到对象/特征,我从IFeature.Shape获得了IGeometry。
是否有一种简单的方法可以标记已知的特征/形状,例如红色或类似的东西?
我使用这样的功能获得了这个功能:
AxMapControl _mapControl;
IFeatureSelection features = _mapControl.Map.Layer[0] as IFeatureSelection;
ICursor cursor;
features.SelectionSet.Search(null, true, out cursor);
IFeature feature;
while ((feature = ((IFeatureCursor)cursor).NextFeature()) != null)
{
IGeometry geometry = feature.Shape;
}
我搜查了样本,但无法找到我需要的内容。
答案 0 :(得分:0)
static public void FlashFeature(IFeature feature)
{
if (feature == null)
return;
IApplication app = ApplicationRef;
IMxDocument doc = (IMxDocument)(app.Document);
IFeatureIdentifyObj feature_identify_obj = new FeatureIdentifyObjectClass();
feature_identify_obj.Feature = feature;
((IIdentifyObj)feature_identify_obj).Flash(doc.ActiveView.ScreenDisplay);
}
ApplicationRef的位置是:
static public IApplication ApplicationRef
{
get
{
Type obj_type = Type.GetTypeFromCLSID(typeof(AppRefClass).GUID);
IApplication obj = null;
try
{
obj = (IApplication)Activator.CreateInstance(obj_type);
}
catch {}
return obj;
}
}
或者你可以通过在IGraphicsContainer中创建图形IElement元素来做到这一点,如:
void ShowFeature(IFeature feature)
{
element.Geometry = geometry.Project(mapSpatialReference, feature.Shape);
graphicsContainer.AddElement(element, 0);
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
featureHighlighted = true;
}
void HideFeature()
{
if (!featureHighlighted)
return;
graphicsContainer.DeleteElement(element);
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
featureHighlighted = false;
}