Wednesday, September 10, 2014

Tạo chế độ bắt dính bằng Snapping Extension

 Private SnappingType As ESRI.ArcGIS.Controls.esriSnappingType
    Public Sub LoadSnap()
        Dim extensionManager As IExtensionManager = m_hookHelper2.ExtensionManager
        If Not extensionManager Is Nothing Then
            Dim guid As UID = New UID
            guid.Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}" 'Snapping extension.
            Dim extension As IExtension = extensionManager.FindExtension(guid)
            m_snappingEnv = TryCast(extension, ISnappingEnvironment)
        End If

        SnappingType = m_snappingEnv.SnappingType
        TypePoint = (SnappingType And esriSnappingType.esriSnappingTypePoint) = esriSnappingType.esriSnappingTypePoint
        TypeVertex = (SnappingType And esriSnappingType.esriSnappingTypeVertex) = esriSnappingType.esriSnappingTypeVertex
        TypeEdge = (SnappingType And esriSnappingType.esriSnappingTypeEdge) = esriSnappingType.esriSnappingTypeEdge
        TypeEndpoint = (SnappingType And esriSnappingType.esriSnappingTypeEndpoint) = esriSnappingType.esriSnappingTypeEndpoint

        TypeIntersection = (SnappingType And esriSnappingType.esriSnappingTypeIntersection) = esriSnappingType.esriSnappingTypeIntersection
        TypeMidpoint = (SnappingType And esriSnappingType.esriSnappingTypeMidpoint) = esriSnappingType.esriSnappingTypeMidpoint
        TypeTangent = (SnappingType And esriSnappingType.esriSnappingTypeTangent) = esriSnappingType.esriSnappingTypeTangent
        ShowSnapTips = m_snappingEnv.ShowSnapTips
        Tolerance = m_snappingEnv.Tolerance
        Enabled = m_snappingEnv.Enabled
        ShowSnapTipBackground = m_snappingEnv.ShowSnapTipBackground
        Dim excludedLayerSet As ISet = Nothing
        m_snapper = m_snappingEnv.PointSnapper
        m_snapper.ExcludedLayers(excludedLayerSet)
        m_snapper.ClearCache()
    End Sub

No comments:

Post a Comment