ApplicativeAlgorithmsCS.TranslateTree.get_Enabled C# (CSharp) Method

get_Enabled() public method

public get_Enabled ( ISchematicLayer schematicLayer ) : bool
schematicLayer ISchematicLayer
return bool
        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;
        }