/////////////////////////////////////////////////////////////////////////////////////// // // ISchematicAlgorithm interface : Defines its properties and methods (mandatory) // #region Implements ISchematicAlgorithm 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); } }
protected override void OnUpdate() { // the tool is enable only if the diagram is in memory try { if (ArcMap.Application == null) { Enabled = false; return; } SetTargetLayer(); if (m_schematicLayer == null) { Enabled = false; return; } if (m_schematicLayer.IsEditingSchematicDiagram() == false) { Enabled = false; if (m_dockableWindow != null) { m_dockableWindow.Show(false); } return; } ISchematicInMemoryDiagram inMemoryDiagram = m_schematicLayer.SchematicInMemoryDiagram; if (inMemoryDiagram == null) { Enabled = false; } else { Enabled = true; } } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); } return; }
/////////////////////////////////////////////////////////////////////////////////////// // // ISchematicAlgorithm interface : Defines its properties and methods (mandatory) // #region Implements ISchematicAlgorithm 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; }