public bool get_Enabled(ISchematicLayer schematicLayer)
{
if (schematicLayer == null)
return false;
// an algorithm needs the diagram to be in editing mode in order to run
if (!schematicLayer.IsEditingSchematicDiagram())
return false;
IEnumSchematicFeature enumFeatures = schematicLayer.GetSchematicSelectedFeatures(true);
if (enumFeatures == null)
return false;
// Count the selected nodes
int iCount = 0;
ISchematicFeature feature;
enumFeatures.Reset();
feature = enumFeatures.Next();
while (feature != null && iCount < 2)
{
ISchematicInMemoryFeatureClass inMemoryFeatureClass;
// just want SchematicFeatureNode
inMemoryFeatureClass = (ISchematicInMemoryFeatureClass)feature.Class;
if (inMemoryFeatureClass.SchematicElementClass.SchematicElementType == esriSchematicElementType.esriSchematicNodeType)
iCount++;
feature = enumFeatures.Next();
}
if (iCount == 1)
return true; // just want one selected node
else
return false;
}