About the Curve conversion add-in Sample
[C#]
CurveConversionCmd.cs
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;
}
}
}
}
[Visual Basic .NET]
CurveConversionCmd.vb
Imports ESRI.ArcGIS.Editor
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.ADF.BaseClasses
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.EditorExt
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.ArcMapUI
Imports ESRI.ArcGIS.Framework
Public Class CurveConversionCmd
Inherits ESRI.ArcGIS.Desktop.AddIns.Button
Dim _Editor As IEditor
Dim _Feature As IFeature
Private Shared _DockWindow As ESRI.ArcGIS.Framework.IDockableWindow
Public Sub New()
Dim eUID As UID = New UIDClass()
eUID.Value = "esriEditor.Editor"
_Editor = TryCast(My.ArcMap.Application.FindExtensionByCLSID(eUID), IEditor)
Dim windowID As UID = New UIDClass
windowID.Value = "ESRI_Employee_CurveConversion_CurveConversionDockWin"
_DockWindow = My.ArcMap.DockableWindowManager.GetDockableWindow(windowID)
End Sub
Shared Property GetCurveConversionWindow() As ESRI.ArcGIS.Framework.IDockableWindow
Get
Return _DockWindow
End Get
Set(ByVal value As ESRI.ArcGIS.Framework.IDockableWindow)
_DockWindow = value
End Set
End Property
Protected Overrides Sub OnClick()
If _DockWindow Is Nothing Then
Return
End If
CurveConversionDockWin._MFields = _Feature.Fields
CurveConversionDockWin.UpdateFieldList()
_DockWindow.Show((Not _DockWindow.IsVisible()))
Checked = _DockWindow.IsVisible()
End Sub
Protected Overrides Sub OnUpdate()
If My.ArcMap.Application IsNot Nothing Then
If Not _Editor.EditState = esriEditState.esriStateEditing OrElse _Editor.SelectionCount = 0 Then
Enabled = False
Return
End If
Dim enumFeat As IEnumFeature = _Editor.EditSelection
_Feature = enumFeat.Next()
'Check the first selected feature and make sure it is a polyline.
Dim CorrectShape As Boolean = _Feature.Shape.GeometryType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline
Enabled = CorrectShape And _DockWindow IsNot Nothing
Checked = _DockWindow.IsVisible()
End If
End Sub
End Class