CurveConversionCmd.cs
// Copyright 2010 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // using ESRI.ArcGIS.Editor; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Framework; namespace CurveConversion { public class CurveConversionCmd : ESRI.ArcGIS.Desktop.AddIns.Button { public IEditor _Editor; public static IFeature _Feature; private static IDockableWindow _DockWindow; public CurveConversionCmd() { UID eUID = new UIDClass(); eUID.Value = "esriEditor.Editor"; _Editor = ArcMap.Application.FindExtensionByCLSID(eUID) as IEditor; // Get dockable window. UID dockWinID = new UIDClass(); dockWinID.Value = @"ESRI_Employee_CurveConversion_CurveConversionDockWin"; _DockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID); } public static IDockableWindow GetCurveConversionWindow { get { return _DockWindow; } } protected override void OnClick() { if (_DockWindow == null) return; CurveConversionDockWin._MFields = _Feature.Fields; CurveConversionDockWin.UpdateFieldList(); _DockWindow.Show(!_DockWindow.IsVisible()); } /// <summary> /// The command enabled is true if the edit state is editing and a feature is selected. /// </summary> protected override void OnUpdate() { if (ArcMap.Application != null) { if (_Editor.EditState != esriEditState.esriStateEditing || _Editor.SelectionCount == 0) { Enabled = false; return; } IEnumFeature enumFeat = _Editor.EditSelection; _Feature = enumFeat.Next(); //Check the first selected feature and make sure it is a polyline. bool CorrectShape = _Feature.Shape.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline; Enabled = CorrectShape & _DockWindow != null; } } } }