Click here to Skip to main content
15,894,646 members
Articles / Desktop Programming / Windows Forms

Wobbly Menu - An Inspiration from iPhone

Rate me:
Please Sign up or sign in to vote.
4.87/5 (33 votes)
17 Mar 2010CPOL3 min read 72.3K   2.5K   75  
iPhone like menu system and wobbly re-arrangement technique with a useful sample application
Imports System.Drawing
Imports System.Windows.Forms
'*******************************************************************
'
'       Copyright © 2010 Thulasee Shan
'
'*******************************************************************

''' <summary>
''' The data structure for creating menu items
''' </summary>
''' <remarks></remarks>
Public Class MenuItem

    Public Text As String
    Public TextAlign As ContentAlignment
    Public Image As Image
    Public ImageAlign As ContentAlignment
    Public BackgroundColor As Color = Color.FromArgb(255, 62, 135, 235)
    Public ForeColor As Color = Color.White
    Friend Parent As DimmableMenu
    Public Font As Font
    Public Tag As String
    Public Tooltip As String
    Public Event OnClick(ByVal e As MenuItem)

    Friend Sub New(ByVal parent As DimmableMenu, _
                    Optional ByVal text As String = "", _
                    Optional ByVal img As Image = Nothing, _
                    Optional ByVal textAlign As ContentAlignment = ContentAlignment.BottomCenter, _
                    Optional ByVal imageAlign As ContentAlignment = ContentAlignment.TopCenter)
        Me.Parent = parent
        Me.Font = parent.Font
        Me.Text = text
        Me.Image = img
        Me.TextAlign = textAlign
        Me.ImageAlign = imageAlign
    End Sub

    Friend Sub ItemClicked()
        RaiseEvent OnClick(Me)
    End Sub
End Class

Public Class MenuItems
    Inherits List(Of MenuItem)

    Private m_Parent As DimmableMenu

    Friend Sub New(ByVal parent As DimmableMenu)
        m_Parent = parent
    End Sub

    Public Function AddMenuItem(Optional ByVal text As String = "", _
                    Optional ByVal img As Image = Nothing) _
                    As MenuItem
        Dim oItem As New MenuItem(m_Parent, text, img)
        Me.Add(oItem)
        Return oItem
    End Function
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) eHips Ltd
United Kingdom United Kingdom
Having more than 10 years experience in software development and currently working for eHips Ltd in Oxford, UK. Expert in C# and VB.NET. Also Expert in technologies such as GDI+, ADO.NET, XML, XSD etc. Started the career as a VB6.0 developer and moved on to .NET with its beta release. Experience includes real-time system development, distributed systems, Work flow systems, control system development and web 2.0 systems.

Comments and Discussions