IHookHelper Interface
VB.NET:
'.............................................
Private m_hookHelper As IHookHelper
'.............................................
''' <summary>
''' Occurs when this command is created
''' </summary>
''' <param name="hook">Instance of the application</param>
Public Overrides Sub OnCreate(ByVal hook As Object)
If hook Is Nothing Then
Return
End If
If m_hookHelper Is Nothing Then
m_hookHelper = New HookHelperClass()
End If
m_hookHelper.Hook = hook
' TODO: Add other initialization code
End Sub
Public Overrides Sub OnClick()
Dim hook As Object = Nothing
If TypeOf m_hookHelper.Hook Is IToolbarControl2 Then
hook = (CType(m_hookHelper.Hook, IToolbarControl2)).Buddy
Else
hook = m_hookHelper.Hook
End If
Dim mapControl As IMapControl3 = Nothing
If TypeOf hook Is IMapControl3 Then
mapControl = CType(hook, IMapControl3)
End Sub
---------------------------------------------------------
C#:
//.....................................................
private IHookHelper m_hookHelper;
//.....................................................
/// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
if (hook == null)
return;
if (m_hookHelper == null)
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
// TODO: Add other initialization code
}
public override void OnClick()
{
//nedd to get the layer from the custom-property of the map
if (null == m_hookHelper)
return;
//get the mapControl hook
object hook = null;
if (m_hookHelper.Hook is IToolbarControl2)
{
hook = ((IToolbarControl2)m_hookHelper.Hook).Buddy;
}
else
{
hook = m_hookHelper.Hook;
}
IMapControl3 mapControl = null;
if (hook is IMapControl3)
{
mapControl = (IMapControl3)hook;
customProperty = mapControl.CustomProperty;
}
else
return;
}