Imports MicroFour.StrataFrame.UI.Windows.Forms
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Design
Namespace Windows.Forms
Public Class ActionLinkMenuItem
Inherits ThemedLinkMenuItem
Implements IComponent ', IExtenderProvider
'Implements IExtenderProvider
'Dim toolTips1 As New System.Windows.Forms.ToolTip
#Region " Constructors "
'''
''' Initializes a new instance of the ActionLinkMenuItem class.
'''
'''
Public Sub New()
End Sub
'''
''' Initializes a new instance of the ActionLinkMenuItem class.
'''
'''
'''
'''
'''
Public Sub New(ByVal Title As String, ByVal Key As String, ByVal Icon As Image, _
ByVal Handler As ClickHandler, ByVal Visible As Boolean)
MyBase.New()
Me.Title = Title
Me.Key = Key
Me.ItemImage = Icon
Me._Handler = Handler
Me.Visible = Visible
'toolTips1.SetToolTip(Me, Title)
End Sub
'
#End Region
#Region " Private Fields "
Private _Handler As ClickHandler
Private _Enabled As Boolean = True
#End Region
#Region " Events "
'''
''' Occurs when this action is clicked.
'''
'''
Public Custom Event Click As ClickHandler
AddHandler(ByVal value As ClickHandler)
Me._Handler = DirectCast([Delegate].Combine(Me._Handler, value), ClickHandler)
End AddHandler
RemoveHandler(ByVal value As ClickHandler)
Me._Handler = DirectCast([Delegate].Remove(Me._Handler, value), ClickHandler)
End RemoveHandler
RaiseEvent()
If Me._Handler IsNot Nothing Then
Me._Handler()
End If
End RaiseEvent
End Event
'''
''' Occurs when this object is disposed.
'''
'''
Public Event Disposed As EventHandler Implements IComponent.Disposed
#End Region
#Region " Public Properties "
'''
''' Gets or sets the permission key used to determine whether the current user has permission
''' to delete records through this child ListViews DeleteObject reference.
'''
_
Public Property SecurityKey() As String = ""
'''
''' Gets or sets the site for this component.
'''
'''
'''
'''
_
Public Property Site() As System.ComponentModel.ISite Implements System.ComponentModel.IComponent.Site
'''
''' The image that will be rendered on the item
'''
'''
'''
'''
Public Property ItemImageDisabled() As Image = Nothing
'''
''' The image that will be rendered on the item
'''
'''
'''
'''
Public Property ItemImageEnabled() As Image = ItemImage
'''
''' The enabled state of the menu item
'''
'''
'''
'''
Public Overloads Property Enabled() As Boolean
Get
Return _Enabled
End Get
Set(ByVal value As Boolean)
'-- Make sure the default icons are assigned if none has been
' assigned previously.
Select Case Me.Key
Case "Home"
If ItemImageEnabled Is Nothing Then
ItemImageEnabled = My.Resources.Home_16x16
End If
If ItemImageDisabled Is Nothing Then
ItemImageDisabled = My.Resources.Home_16x16_Disabled
End If
Case "Search"
If ItemImageEnabled Is Nothing Then
ItemImageEnabled = My.Resources.Find_16x16
End If
If ItemImageDisabled Is Nothing Then
ItemImageDisabled = My.Resources.Find_16x16_Disabled
End If
Case "Add"
If ItemImageEnabled Is Nothing Then
ItemImageEnabled = My.Resources.Add_16x16
End If
If ItemImageDisabled Is Nothing Then
ItemImageDisabled = My.Resources.Add_16x16_Disabled
End If
Case "Edit"
If ItemImageEnabled Is Nothing Then
ItemImageEnabled = My.Resources.Edit_16x16
End If
If ItemImageDisabled Is Nothing Then
ItemImageDisabled = My.Resources.Edit_16x16_Disabled
End If
Case "Delete"
If ItemImageEnabled Is Nothing Then
ItemImageEnabled = My.Resources.Delete_16x16
End If
If ItemImageDisabled Is Nothing Then
ItemImageDisabled = My.Resources.Delete_16x16_Disabled
End If
Case "Print"
If ItemImageEnabled Is Nothing Then
ItemImageEnabled = My.Resources.Print_16x16
End If
If ItemImageDisabled Is Nothing Then
ItemImageDisabled = My.Resources.Print_16x16_Disabled
End If
Case "Close"
If ItemImageEnabled Is Nothing Then
ItemImageEnabled = My.Resources.Close_16x16
End If
If ItemImageDisabled Is Nothing Then
ItemImageDisabled = My.Resources.Close_16x16_Disabled
End If
End Select
_Enabled = value
If Not value Then
State = LinkMenuItemState.Disabled
If ItemImageDisabled IsNot Nothing Then
ItemImage = ItemImageDisabled
Else
If ItemImageEnabled IsNot Nothing Then
ItemImage = ItemImageEnabled
End If
End If
Else
If State = LinkMenuItemState.Disabled Then
State = LinkMenuItemState.Normal
If ItemImageEnabled IsNot Nothing Then
ItemImage = ItemImageEnabled
End If
End If
End If
'-- Redraw the parent control
If Parent IsNot Nothing Then
Parent.Invalidate()
End If
End Set
End Property
#End Region
#Region " Public Methods "
Public Sub Dispose() Implements IDisposable.Dispose
End Sub
'''
''' Calls the internal click handler for the link menu.
'''
'''
Public Sub OnClick()
'-- Call the internal handler
RaiseEvent Click()
End Sub
#End Region
#Region " Nested Types "
'''
''' Describes a method that will be called when the link item is clicked.
'''
'''
Public Delegate Sub ClickHandler()
#End Region
'Public Function CanExtend(extendee As Object) As Boolean Implements IExtenderProvider.CanExtend
' 'If TypeOf extendee Is ActionLinkMenuItem Then
' ' Return True
' 'End If
' Return True
'End Function
End Class
End Namespace