如何使用IFeatureProgress接口?

如何使用IFeatureProgress接口?
已邀请:

刘峥 - ArcGIS多面手

赞同来自:

【解决办法】:


首先构建FeatureProgressHelper类:
private class FeatureProgressHelper : IFeatureProgress
{
private int featureCount = 0;

private int stepValue = 0;

String IFeatureProgress.FeatureClassName
{
set { Console.WriteLine(FeatureClassName: {0}, value); }
}

Boolean IFeatureProgress.IsCancelled
{
get { return false; }
}

int IFeatureProgress.MaxFeatures
{
set { Console.WriteLine(MaxFeatures: {0}, value); }
}

int IFeatureProgress.MinFeatures
{
set { Console.WriteLine(MinFeatures: {0}, value); }
}

int IFeatureProgress.Position
{
set { Console.WriteLine(Position: {0}, value); }
}

void IFeatureProgress.Step()
{
// Increment the number of features replicated and display the progress.
featureCount += stepValue;
Console.WriteLine({0} features replicated., featureCount);
}

int IFeatureProgress.StepValue
{
set { stepValue = value; }
}
}
public FeatureProgressHelper(IConnectionPointContainer connectionPointContainer)
{
// Get the event source''s connection points.
IEnumConnectionPoints enumConnectionPoints = null;
connectionPointContainer.EnumConnectionPoints(out enumConnectionPoints);
enumConnectionPoints.Reset();

// Iterate through the connection points until one for IFeatureProgress is found.
IConnectionPoint connectionPoint = null;
Guid featureProgressGuid = typeof(IFeatureProgress).GUID;
uint pcFetched = 0;
enumConnectionPoints.RemoteNext(1, out connectionPoint, out pcFetched);
while (connectionPoint != null)
{
Guid connectionInterfaceGuid;
connectionPoint.GetConnectionInterface(out connectionInterfaceGuid);
if (connectionInterfaceGuid == featureProgressGuid)
{
break;
}
enumConnectionPoints.RemoteNext(1, out connectionPoint, out pcFetched);
}

// If IFeatureProgress wasn''t found, throw an exception.
if (connectionPoint == null)
{
throw new ArgumentException(An IFeatureProgress connection point could not be found.);
}

// Tie into the connection point.
uint connectionPointCookie = 0;
connectionPoint.Advise(this, out connectionPointCookie);
}

然后在进行数据转换时调用:

IFeatureDataConverter featureDataConverter  = new FeatureDataConverterClass();
IConnectionPointContainer connectionPointContainer = (IConnectionPointContainer)featureDataConverter;
FeatureProgressHelper featureProgressHelper = new FeatureProgressHelper(connectionPointContainer);



参考链接:http://support.esri.com/en/kno ... 34908

要回复问题请先登录注册