Curve conversion add-in
CurveConversionCmd.vb
' Copyright 2012 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.
' 

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